refactor: use base::ObserverList::Notify() (#46875)

* refactor: use ObserverList::Notify() in shell/browser/window_list.cc

* refactor: use ObserverList::Notify() in shell/browser/web_contents_zoom_controller.cc

* refactor: use ObserverList::Notify() in shell/browser/usb/usb_chooser_context.cc

* refactor: use ObserverList::Notify() in shell/browser/usb/electron_usb_delegate.cc

* refactor: use ObserverList::Notify() in shell/browser/ui/views/menu_delegate.cc

* refactor: use ObserverList::Notify() in shell/browser/ui/tray_icon.cc

* refactor: use ObserverList::Notify() in shell/browser/ui/electron_menu_model.cc

* refactor: use ObserverList::Notify() in shell/browser/serial/serial_chooser_context.cc

* refactor: use ObserverList::Notify() in shell/browser/native_window.cc

* refactor: use ObserverList::Notify() in shell/browser/serial/electron_serial_delegate.cc

* refactor: use ObserverList::Notify() in shell/browser/browser.cc

* refactor: use ObserverList::Notify() in shell/browser/api/electron_api_web_contents.cc

* refactor: use ObserverList::Notify() in shell/browser/hid/electron_hid_delegate.cc

* refactor: use ObserverList::Notify() in shell/browser/hid/hid_chooser_context.cc
This commit is contained in:
Charles Kerr
2025-05-02 04:10:52 -05:00
committed by GitHub
parent ede84fc327
commit f6b297a06a
14 changed files with 134 additions and 229 deletions

View File

@@ -102,19 +102,19 @@ class ElectronUsbDelegate::ContextObservation
// UsbChooserContext::DeviceObserver:
void OnDeviceAdded(const device::mojom::UsbDeviceInfo& device_info) override {
for (auto& observer : observer_list_)
observer.OnDeviceAdded(device_info);
observer_list_.Notify(&content::UsbDelegate::Observer::OnDeviceAdded,
device_info);
}
void OnDeviceRemoved(
const device::mojom::UsbDeviceInfo& device_info) override {
for (auto& observer : observer_list_)
observer.OnDeviceRemoved(device_info);
observer_list_.Notify(&content::UsbDelegate::Observer::OnDeviceRemoved,
device_info);
}
void OnDeviceManagerConnectionError() override {
for (auto& observer : observer_list_)
observer.OnDeviceManagerConnectionError();
observer_list_.Notify(
&content::UsbDelegate::Observer::OnDeviceManagerConnectionError);
}
void OnBrowserContextShutdown() override {

View File

@@ -290,8 +290,7 @@ void UsbChooserContext::OnDeviceAdded(
devices_.try_emplace(device_info->guid, device_info->Clone());
// Notify all observers.
for (auto& observer : device_observer_list_)
observer.OnDeviceAdded(*device_info);
device_observer_list_.Notify(&DeviceObserver::OnDeviceAdded, *device_info);
}
void UsbChooserContext::OnDeviceRemoved(
@@ -308,8 +307,7 @@ void UsbChooserContext::OnDeviceRemoved(
DCHECK_EQ(n_erased, 1U);
// Notify all device observers.
for (auto& observer : device_observer_list_)
observer.OnDeviceRemoved(*device_info);
device_observer_list_.Notify(&DeviceObserver::OnDeviceRemoved, *device_info);
// If the device was persistent, return. Otherwise, notify all permission
// observers that its permissions were revoked.
@@ -331,8 +329,7 @@ void UsbChooserContext::OnDeviceManagerConnectionError() {
ephemeral_devices_.clear();
// Notify all device observers.
for (auto& observer : device_observer_list_)
observer.OnDeviceManagerConnectionError();
device_observer_list_.Notify(&DeviceObserver::OnDeviceManagerConnectionError);
}
} // namespace electron