diff --git a/shell/browser/hid/electron_hid_delegate.cc b/shell/browser/hid/electron_hid_delegate.cc index 10aa32c41dc..b7078bf2633 100644 --- a/shell/browser/hid/electron_hid_delegate.cc +++ b/shell/browser/hid/electron_hid_delegate.cc @@ -46,8 +46,8 @@ class ElectronHidDelegate::ContextObservation ContextObservation(ElectronHidDelegate* parent, content::BrowserContext* browser_context) : parent_(parent), browser_context_(browser_context) { - auto* chooser_context = GetChooserContext(browser_context_); - device_observation_.Observe(chooser_context); + if (auto* chooser_context = GetChooserContext(browser_context_)) + device_observation_.Observe(chooser_context); } ContextObservation(ContextObservation&) = delete; diff --git a/shell/browser/usb/electron_usb_delegate.cc b/shell/browser/usb/electron_usb_delegate.cc index 18d833eaf9e..0f0f6c0a5d4 100644 --- a/shell/browser/usb/electron_usb_delegate.cc +++ b/shell/browser/usb/electron_usb_delegate.cc @@ -94,7 +94,8 @@ class ElectronUsbDelegate::ContextObservation content::BrowserContext* browser_context) : parent_(parent), browser_context_(browser_context) { auto* chooser_context = GetChooserContext(browser_context_); - device_observation_.Observe(chooser_context); + if (chooser_context) + device_observation_.Observe(chooser_context); } ContextObservation(ContextObservation&) = delete; ContextObservation& operator=(ContextObservation&) = delete;