Retire ScopedObserver in chrome/browser/ui/webui.
ScopedObserver is being deprecated in favor of two new classes:
- base::ScopedObservation for observers that only ever observe
a single source.
- base::ScopedMultiSourceObservation for observers that do or may
observe more than a single source.
Tbr: [email protected]
Bug: 1145565
Change-Id: I8a6c5867c2bc5e073245e1ee82aed43d44b47632
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2611553
Reviewed-by: Sigurður Ásgeirsson <[email protected]>
Reviewed-by: François Doray <[email protected]>
Commit-Queue: Sigurður Ásgeirsson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#841126}
diff --git a/chrome/browser/ui/webui/app_management/app_management_page_handler.cc b/chrome/browser/ui/webui/app_management/app_management_page_handler.cc
index 2a6b026..7ba1410 100644
--- a/chrome/browser/ui/webui/app_management/app_management_page_handler.cc
+++ b/chrome/browser/ui/webui/app_management/app_management_page_handler.cc
@@ -101,7 +101,7 @@
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (arc::IsArcAllowedForProfile(profile_)) {
- arc_app_list_prefs_observer_.Add(ArcAppListPrefs::Get(profile_));
+ arc_app_list_prefs_observation_.Observe(ArcAppListPrefs::Get(profile_));
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
diff --git a/chrome/browser/ui/webui/app_management/app_management_page_handler.h b/chrome/browser/ui/webui/app_management/app_management_page_handler.h
index 2d56a70e..144d0ad 100644
--- a/chrome/browser/ui/webui/app_management/app_management_page_handler.h
+++ b/chrome/browser/ui/webui/app_management/app_management_page_handler.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_APP_MANAGEMENT_APP_MANAGEMENT_PAGE_HANDLER_H_
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/webui/app_management/app_management.mojom-forward.h"
#include "chrome/browser/ui/webui/app_management/app_management_shelf_delegate_chromeos.h"
@@ -78,8 +78,8 @@
Profile* profile_;
#if BUILDFLAG(IS_CHROMEOS_ASH)
- ScopedObserver<ArcAppListPrefs, ArcAppListPrefs::Observer>
- arc_app_list_prefs_observer_{this};
+ base::ScopedObservation<ArcAppListPrefs, ArcAppListPrefs::Observer>
+ arc_app_list_prefs_observation_{this};
AppManagementShelfDelegate shelf_delegate_{this};
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chrome/browser/ui/webui/certificate_provisioning_ui_handler.cc b/chrome/browser/ui/webui/certificate_provisioning_ui_handler.cc
index 8fc025f0..fa72af7 100644
--- a/chrome/browser/ui/webui/certificate_provisioning_ui_handler.cc
+++ b/chrome/browser/ui/webui/certificate_provisioning_ui_handler.cc
@@ -169,9 +169,9 @@
? scheduler_for_device
: nullptr) {
if (scheduler_for_user_)
- observed_schedulers_.Add(scheduler_for_user_);
+ observed_schedulers_.AddObservation(scheduler_for_user_);
if (scheduler_for_device_)
- observed_schedulers_.Add(scheduler_for_device_);
+ observed_schedulers_.AddObservation(scheduler_for_device_);
}
CertificateProvisioningUiHandler::~CertificateProvisioningUiHandler() = default;
diff --git a/chrome/browser/ui/webui/certificate_provisioning_ui_handler.h b/chrome/browser/ui/webui/certificate_provisioning_ui_handler.h
index 8732b34..a71ce112 100644
--- a/chrome/browser/ui/webui/certificate_provisioning_ui_handler.h
+++ b/chrome/browser/ui/webui/certificate_provisioning_ui_handler.h
@@ -8,7 +8,7 @@
#include <utility>
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_multi_source_observation.h"
#include "base/timer/timer.h"
#include "base/values.h"
#include "chrome/browser/chromeos/cert_provisioning/cert_provisioning_scheduler.h"
@@ -109,7 +109,8 @@
// Keeps track of the CertProvisioningSchedulers that this UI handler
// observes.
- ScopedObserver<CertProvisioningScheduler, CertProvisioningSchedulerObserver>
+ base::ScopedMultiSourceObservation<CertProvisioningScheduler,
+ CertProvisioningSchedulerObserver>
observed_schedulers_{this};
base::WeakPtrFactory<CertificateProvisioningUiHandler> weak_ptr_factory_{
diff --git a/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc b/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc
index 1fd4297..c79de40 100644
--- a/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc
+++ b/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc
@@ -69,15 +69,17 @@
if (device_data_manager->AreDeviceListsComplete() &&
device_data_manager->AreTouchscreenTargetDisplaysValid()) {
MoveToTouchDisplay();
- } else if (!scoped_observer_.IsObserving(device_data_manager)) {
- scoped_observer_.Add(device_data_manager);
+ } else if (!scoped_observation_.IsObserving()) {
+ scoped_observation_.Observe(device_data_manager);
+ } else {
+ DCHECK(scoped_observation_.IsObservingSource(device_data_manager));
}
}
void OobeDisplayChooser::MoveToTouchDisplay() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- scoped_observer_.RemoveAll();
+ scoped_observation_.Reset();
const ui::DeviceDataManager* device_data_manager =
ui::DeviceDataManager::GetInstance();
diff --git a/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h b/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h
index d6b373c..e79cc51 100644
--- a/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h
+++ b/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h
@@ -8,7 +8,7 @@
#include "ash/public/mojom/cros_display_config.mojom.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "ui/events/devices/device_data_manager.h"
@@ -48,8 +48,8 @@
void OnTouchDeviceAssociationChanged() override;
void OnDeviceListsComplete() override;
- ScopedObserver<ui::DeviceDataManager, ui::InputDeviceEventObserver>
- scoped_observer_{this};
+ base::ScopedObservation<ui::DeviceDataManager, ui::InputDeviceEventObserver>
+ scoped_observation_{this};
mojo::Remote<ash::mojom::CrosDisplayConfigController> cros_display_config_;
base::WeakPtrFactory<OobeDisplayChooser> weak_ptr_factory_{this};
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
index 497f74d..0303b86 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
@@ -17,7 +17,6 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
#include "chrome/browser/chromeos/login/screens/error_screen.h"
#include "chrome/browser/chromeos/login/signin_specifics.h"
#include "chrome/browser/chromeos/login/ui/login_display.h"
diff --git a/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.cc b/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.cc
index 837677c7..990f81e 100644
--- a/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.cc
@@ -39,7 +39,7 @@
} // namespace
-MultideviceLogsHandler::MultideviceLogsHandler() : observer_(this) {}
+MultideviceLogsHandler::MultideviceLogsHandler() {}
MultideviceLogsHandler::~MultideviceLogsHandler() = default;
@@ -51,11 +51,11 @@
}
void MultideviceLogsHandler::OnJavascriptAllowed() {
- observer_.Add(multidevice::LogBuffer::GetInstance());
+ observation_.Observe(multidevice::LogBuffer::GetInstance());
}
void MultideviceLogsHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
+ observation_.Reset();
}
void MultideviceLogsHandler::HandleGetLogMessages(const base::ListValue* args) {
diff --git a/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.h b/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.h
index e8cb0a8..92289bb 100644
--- a/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.h
+++ b/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.h
@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_MULTIDEVICE_INTERNALS_MULTIDEVICE_INTERNALS_LOGS_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_MULTIDEVICE_INTERNALS_MULTIDEVICE_INTERNALS_LOGS_HANDLER_H_
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chromeos/components/multidevice/logging/log_buffer.h"
#include "chromeos/components/multidevice/logging/logging.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -45,8 +45,9 @@
// Message handler callback that clears the Log Buffer.
void ClearLogBuffer(const base::ListValue* args);
- ScopedObserver<multidevice::LogBuffer, multidevice::LogBuffer::Observer>
- observer_{this};
+ base::ScopedObservation<multidevice::LogBuffer,
+ multidevice::LogBuffer::Observer>
+ observation_{this};
};
} // namespace multidevice
diff --git a/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.cc b/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.cc
index d3846a4..c419ad5 100644
--- a/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.cc
@@ -205,51 +205,24 @@
}
void MultidevicePhoneHubHandler::AddObservers() {
- notification_manager_observer_.Add(
+ notification_manager_observation_.Observe(
fake_phone_hub_manager_->fake_notification_manager());
- do_not_disturb_controller_observer_.Add(
+ do_not_disturb_controller_observation_.Observe(
fake_phone_hub_manager_->fake_do_not_disturb_controller());
- find_my_device_controller_oberserver_.Add(
+ find_my_device_controller_observation_.Observe(
fake_phone_hub_manager_->fake_find_my_device_controller());
- tether_controller_observer_.Add(
+ tether_controller_observation_.Observe(
fake_phone_hub_manager_->fake_tether_controller());
- onboarding_ui_tracker_observer_.Add(
+ onboarding_ui_tracker_observation_.Observe(
fake_phone_hub_manager_->fake_onboarding_ui_tracker());
}
void MultidevicePhoneHubHandler::RemoveObservers() {
- phonehub::FakeNotificationManager* fake_notification_manager =
- fake_phone_hub_manager_->fake_notification_manager();
- if (notification_manager_observer_.IsObserving(fake_notification_manager)) {
- notification_manager_observer_.Remove(fake_notification_manager);
- }
-
- phonehub::FakeDoNotDisturbController* fake_do_not_disturb_controller =
- fake_phone_hub_manager_->fake_do_not_disturb_controller();
- if (do_not_disturb_controller_observer_.IsObserving(
- fake_do_not_disturb_controller)) {
- do_not_disturb_controller_observer_.Remove(fake_do_not_disturb_controller);
- }
-
- phonehub::FakeFindMyDeviceController* fake_find_my_device_controller =
- fake_phone_hub_manager_->fake_find_my_device_controller();
- if (find_my_device_controller_oberserver_.IsObserving(
- fake_find_my_device_controller)) {
- find_my_device_controller_oberserver_.Remove(
- fake_find_my_device_controller);
- }
-
- phonehub::FakeTetherController* fake_tether_controller =
- fake_phone_hub_manager_->fake_tether_controller();
- if (tether_controller_observer_.IsObserving(fake_tether_controller)) {
- tether_controller_observer_.Remove(fake_tether_controller);
- }
-
- phonehub::OnboardingUiTracker* fake_onboarding_ui_tracker =
- fake_phone_hub_manager_->fake_onboarding_ui_tracker();
- if (onboarding_ui_tracker_observer_.IsObserving(fake_onboarding_ui_tracker)) {
- onboarding_ui_tracker_observer_.Remove(fake_onboarding_ui_tracker);
- }
+ notification_manager_observation_.Reset();
+ do_not_disturb_controller_observation_.Reset();
+ find_my_device_controller_observation_.Reset();
+ tether_controller_observation_.Reset();
+ onboarding_ui_tracker_observation_.Reset();
}
void MultidevicePhoneHubHandler::OnNotificationsRemoved(
diff --git a/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.h b/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.h
index e0ec4f0..07a1242a 100644
--- a/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.h
+++ b/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.h
@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_MULTIDEVICE_INTERNALS_MULTIDEVICE_INTERNALS_PHONE_HUB_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_MULTIDEVICE_INTERNALS_MULTIDEVICE_INTERNALS_PHONE_HUB_HANDLER_H_
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chromeos/components/phonehub/do_not_disturb_controller.h"
#include "chromeos/components/phonehub/find_my_device_controller.h"
#include "chromeos/components/phonehub/notification_manager.h"
@@ -79,21 +79,21 @@
void RemoveObservers();
std::unique_ptr<phonehub::FakePhoneHubManager> fake_phone_hub_manager_;
- ScopedObserver<phonehub::NotificationManager,
- phonehub::NotificationManager::Observer>
- notification_manager_observer_{this};
- ScopedObserver<phonehub::DoNotDisturbController,
- phonehub::DoNotDisturbController::Observer>
- do_not_disturb_controller_observer_{this};
- ScopedObserver<phonehub::FindMyDeviceController,
- phonehub::FindMyDeviceController::Observer>
- find_my_device_controller_oberserver_{this};
- ScopedObserver<phonehub::TetherController,
- phonehub::TetherController::Observer>
- tether_controller_observer_{this};
- ScopedObserver<phonehub::OnboardingUiTracker,
- phonehub::OnboardingUiTracker::Observer>
- onboarding_ui_tracker_observer_{this};
+ base::ScopedObservation<phonehub::NotificationManager,
+ phonehub::NotificationManager::Observer>
+ notification_manager_observation_{this};
+ base::ScopedObservation<phonehub::DoNotDisturbController,
+ phonehub::DoNotDisturbController::Observer>
+ do_not_disturb_controller_observation_{this};
+ base::ScopedObservation<phonehub::FindMyDeviceController,
+ phonehub::FindMyDeviceController::Observer>
+ find_my_device_controller_observation_{this};
+ base::ScopedObservation<phonehub::TetherController,
+ phonehub::TetherController::Observer>
+ tether_controller_observation_{this};
+ base::ScopedObservation<phonehub::OnboardingUiTracker,
+ phonehub::OnboardingUiTracker::Observer>
+ onboarding_ui_tracker_observation_{this};
};
} // namespace multidevice
diff --git a/chrome/browser/ui/webui/chromeos/set_time_ui.cc b/chrome/browser/ui/webui/chromeos/set_time_ui.cc
index 3fffeae..2c2e1fd 100644
--- a/chrome/browser/ui/webui/chromeos/set_time_ui.cc
+++ b/chrome/browser/ui/webui/chromeos/set_time_ui.cc
@@ -14,7 +14,7 @@
#include "base/build_time.h"
#include "base/callback_helpers.h"
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/values.h"
#include "chrome/browser/chromeos/child_accounts/parent_access_code/parent_access_service.h"
#include "chrome/browser/chromeos/set_time_dialog.h"
@@ -69,13 +69,13 @@
}
void OnJavascriptAllowed() override {
- clock_observer_.Add(SystemClockClient::Get());
- timezone_observer_.Add(system::TimezoneSettings::GetInstance());
+ clock_observation_.Observe(SystemClockClient::Get());
+ timezone_observation_.Observe(system::TimezoneSettings::GetInstance());
}
void OnJavascriptDisallowed() override {
- clock_observer_.RemoveAll();
- timezone_observer_.RemoveAll();
+ clock_observation_.Reset();
+ timezone_observation_.Reset();
}
private:
@@ -157,10 +157,11 @@
FireWebUIListener("validation-complete");
}
- ScopedObserver<SystemClockClient, SystemClockClient::Observer>
- clock_observer_{this};
- ScopedObserver<system::TimezoneSettings, system::TimezoneSettings::Observer>
- timezone_observer_{this};
+ base::ScopedObservation<SystemClockClient, SystemClockClient::Observer>
+ clock_observation_{this};
+ base::ScopedObservation<system::TimezoneSettings,
+ system::TimezoneSettings::Observer>
+ timezone_observation_{this};
base::WeakPtrFactory<SetTimeMessageHandler> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(SetTimeMessageHandler);
diff --git a/chrome/browser/ui/webui/components/components_handler.cc b/chrome/browser/ui/webui/components/components_handler.cc
index 12e81dd..1f9014b 100644
--- a/chrome/browser/ui/webui/components/components_handler.cc
+++ b/chrome/browser/ui/webui/components/components_handler.cc
@@ -34,11 +34,11 @@
}
void ComponentsHandler::OnJavascriptAllowed() {
- observer_.Add(component_updater_);
+ observation_.Observe(component_updater_);
}
void ComponentsHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
+ observation_.Reset();
}
void ComponentsHandler::HandleRequestComponentsData(
diff --git a/chrome/browser/ui/webui/components/components_handler.h b/chrome/browser/ui/webui/components/components_handler.h
index 5ed5d43..4f2f38f 100644
--- a/chrome/browser/ui/webui/components/components_handler.h
+++ b/chrome/browser/ui/webui/components/components_handler.h
@@ -8,7 +8,7 @@
#include <memory>
#include <string>
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/strings/string16.h"
#include "components/component_updater/component_updater_service.h"
#include "components/update_client/update_client.h"
@@ -53,9 +53,9 @@
// Weak pointer; injected for testing.
component_updater::ComponentUpdateService* const component_updater_;
- ScopedObserver<component_updater::ComponentUpdateService,
- component_updater::ComponentUpdateService::Observer>
- observer_{this};
+ base::ScopedObservation<component_updater::ComponentUpdateService,
+ component_updater::ComponentUpdateService::Observer>
+ observation_{this};
};
#endif // CHROME_BROWSER_UI_WEBUI_COMPONENTS_COMPONENTS_HANDLER_H_
diff --git a/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.cc b/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.cc
index 96355ed8..056ed9c 100644
--- a/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.cc
+++ b/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.cc
@@ -105,9 +105,9 @@
}
void QueryTilesInternalsUIMessageHandler::OnJavascriptAllowed() {
- logger_observer_.Add(tile_service_->GetLogger());
+ logger_observation_.Observe(tile_service_->GetLogger());
}
void QueryTilesInternalsUIMessageHandler::OnJavascriptDisallowed() {
- logger_observer_.RemoveAll();
+ logger_observation_.Reset();
}
diff --git a/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.h b/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.h
index f896b56..dc1cb45 100644
--- a/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.h
+++ b/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.h
@@ -7,7 +7,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "components/query_tiles/logger.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -46,8 +46,8 @@
query_tiles::TileService* tile_service_;
- ScopedObserver<query_tiles::Logger, query_tiles::Logger::Observer>
- logger_observer_{this};
+ base::ScopedObservation<query_tiles::Logger, query_tiles::Logger::Observer>
+ logger_observation_{this};
base::WeakPtrFactory<QueryTilesInternalsUIMessageHandler> weak_ptr_factory_{
this};
diff --git a/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.cc b/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.cc
index 1264b4b..4e0f1fd1 100644
--- a/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.cc
+++ b/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.cc
@@ -104,14 +104,14 @@
NearbySharingService* service_ =
NearbySharingServiceFactory::GetForBrowserContext(context_);
if (service_) {
- observer_.Add(service_->GetContactManager());
+ observation_.Observe(service_->GetContactManager());
} else {
NS_LOG(ERROR) << "No NearbyShareService instance to call.";
}
}
void NearbyInternalsContactHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
+ observation_.Reset();
}
void NearbyInternalsContactHandler::InitializeContents(
diff --git a/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.h b/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.h
index 02a568f..a5bd632 100644
--- a/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.h
+++ b/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.h
@@ -11,7 +11,7 @@
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/nearby_sharing/contacts/nearby_share_contact_manager.h"
#include "chrome/browser/nearby_sharing/proto/rpc_resources.pb.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -57,8 +57,9 @@
void HandleDownloadContacts(const base::ListValue* args);
content::BrowserContext* context_;
- ScopedObserver<NearbyShareContactManager, NearbyShareContactManager::Observer>
- observer_{this};
+ base::ScopedObservation<NearbyShareContactManager,
+ NearbyShareContactManager::Observer>
+ observation_{this};
base::WeakPtrFactory<NearbyInternalsContactHandler> weak_ptr_factory_{this};
};
diff --git a/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.cc b/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.cc
index 6d0f2427..83260ce 100644
--- a/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.cc
+++ b/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.cc
@@ -96,14 +96,14 @@
NearbySharingService* service_ =
NearbySharingServiceFactory::GetForBrowserContext(context_);
if (service_) {
- observer_.Add(service_->GetHttpNotifier());
+ observation_.Observe(service_->GetHttpNotifier());
} else {
NS_LOG(ERROR) << "No NearbyShareService instance to call.";
}
}
void NearbyInternalsHttpHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
+ observation_.Reset();
}
void NearbyInternalsHttpHandler::InitializeContents(
diff --git a/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.h b/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.h
index da37e13..62bfaaa 100644
--- a/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.h
+++ b/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_NEARBY_INTERNALS_NEARBY_INTERNALS_HTTP_HANDLER_H_
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/nearby_sharing/client/nearby_share_http_notifier.h"
#include "chrome/browser/nearby_sharing/proto/certificate_rpc.pb.h"
#include "chrome/browser/nearby_sharing/proto/contact_rpc.pb.h"
@@ -67,8 +67,9 @@
void ListContactPeople(const base::ListValue* args);
content::BrowserContext* const context_;
- ScopedObserver<NearbyShareHttpNotifier, NearbyShareHttpNotifier::Observer>
- observer_{this};
+ base::ScopedObservation<NearbyShareHttpNotifier,
+ NearbyShareHttpNotifier::Observer>
+ observation_{this};
base::WeakPtrFactory<NearbyInternalsHttpHandler> weak_ptr_factory_{this};
};
diff --git a/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.cc b/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.cc
index ba44fc2..e72da2f 100644
--- a/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.cc
+++ b/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.cc
@@ -31,7 +31,7 @@
}
} // namespace
-NearbyInternalsLogsHandler::NearbyInternalsLogsHandler() : observer_(this) {}
+NearbyInternalsLogsHandler::NearbyInternalsLogsHandler() {}
NearbyInternalsLogsHandler::~NearbyInternalsLogsHandler() = default;
@@ -43,11 +43,11 @@
}
void NearbyInternalsLogsHandler::OnJavascriptAllowed() {
- observer_.Add(LogBuffer::GetInstance());
+ observation_.Observe(LogBuffer::GetInstance());
}
void NearbyInternalsLogsHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
+ observation_.Reset();
}
void NearbyInternalsLogsHandler::HandleGetLogMessages(
diff --git a/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.h b/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.h
index 3ba482bd..48b6927 100644
--- a/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.h
+++ b/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.h
@@ -5,7 +5,7 @@
#define CHROME_BROWSER_UI_WEBUI_NEARBY_INTERNALS_NEARBY_INTERNALS_LOGS_HANDLER_H_
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/values.h"
#include "chrome/browser/nearby_sharing/logging/log_buffer.h"
#include "chrome/browser/nearby_sharing/logging/logging.h"
@@ -42,7 +42,7 @@
// Message handler callback that clears the Log Buffer.
void ClearLogBuffer(const base::ListValue* args);
- ScopedObserver<LogBuffer, LogBuffer::Observer> observer_{this};
+ base::ScopedObservation<LogBuffer, LogBuffer::Observer> observation_{this};
base::WeakPtrFactory<NearbyInternalsLogsHandler> weak_ptr_factory_{this};
};
diff --git a/chrome/browser/ui/webui/net_export_ui.cc b/chrome/browser/ui/webui/net_export_ui.cc
index f27414c..a233236 100644
--- a/chrome/browser/ui/webui/net_export_ui.cc
+++ b/chrome/browser/ui/webui/net_export_ui.cc
@@ -16,7 +16,7 @@
#include "base/lazy_instance.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -139,9 +139,9 @@
// Cached pointer to SystemNetworkContextManager's NetExportFileWriter.
net_log::NetExportFileWriter* file_writer_;
- ScopedObserver<net_log::NetExportFileWriter,
- net_log::NetExportFileWriter::StateObserver>
- state_observer_manager_;
+ base::ScopedObservation<net_log::NetExportFileWriter,
+ net_log::NetExportFileWriter::StateObserver>
+ state_observation_manager_{this};
// The capture mode and file size bound that the user chose in the UI when
// logging started is cached here and is read after a file path is chosen in
@@ -159,8 +159,7 @@
NetExportMessageHandler::NetExportMessageHandler()
: file_writer_(g_browser_process->system_network_context_manager()
- ->GetNetExportFileWriter()),
- state_observer_manager_(this) {
+ ->GetNetExportFileWriter()) {
file_writer_->Initialize();
}
@@ -204,8 +203,8 @@
void NetExportMessageHandler::OnEnableNotifyUIWithState(
const base::ListValue* list) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- if (!state_observer_manager_.IsObservingSources()) {
- state_observer_manager_.Add(file_writer_);
+ if (!state_observation_manager_.IsObserving()) {
+ state_observation_manager_.Observe(file_writer_);
}
NotifyUIWithState(file_writer_->GetState());
}
diff --git a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc
index 82fc446..833e8ec 100644
--- a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc
+++ b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc
@@ -390,8 +390,8 @@
instant_service_->UpdateNtpTheme();
OmniboxTabHelper::CreateForWebContents(web_contents);
OmniboxTabHelper::FromWebContents(web_contents_)->AddObserver(this);
- promo_service_observer_.Add(promo_service_);
- one_google_bar_service_observer_.Add(one_google_bar_service_);
+ promo_service_observation_.Observe(promo_service_);
+ one_google_bar_service_observation_.Observe(one_google_bar_service_);
logger_.SetModulesVisible(
profile_->GetPrefs()->GetBoolean(prefs::kNtpModulesVisible));
}
@@ -721,7 +721,7 @@
}
void NewTabPageHandler::OnPromoServiceShuttingDown() {
- promo_service_observer_.RemoveAll();
+ promo_service_observation_.Reset();
promo_service_ = nullptr;
}
@@ -1368,7 +1368,7 @@
}
void NewTabPageHandler::OnOneGoogleBarServiceShuttingDown() {
- one_google_bar_service_observer_.RemoveAll();
+ one_google_bar_service_observation_.Reset();
one_google_bar_service_ = nullptr;
}
diff --git a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h
index b0c3960..28f5a26 100644
--- a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h
+++ b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h
@@ -11,7 +11,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/time/time.h"
#include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h"
#include "chrome/browser/search/background/ntp_background_service_observer.h"
@@ -229,8 +229,8 @@
base::TimeTicks background_images_request_start_time_;
std::vector<GetOneGoogleBarPartsCallback> one_google_bar_parts_callbacks_;
OneGoogleBarService* one_google_bar_service_;
- ScopedObserver<OneGoogleBarService, OneGoogleBarServiceObserver>
- one_google_bar_service_observer_{this};
+ base::ScopedObservation<OneGoogleBarService, OneGoogleBarServiceObserver>
+ one_google_bar_service_observation_{this};
base::Optional<base::TimeTicks> one_google_bar_load_start_time_;
Profile* profile_;
scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
@@ -247,8 +247,8 @@
loader_map_;
std::vector<GetPromoCallback> promo_callbacks_;
PromoService* promo_service_;
- ScopedObserver<PromoService, PromoServiceObserver> promo_service_observer_{
- this};
+ base::ScopedObservation<PromoService, PromoServiceObserver>
+ promo_service_observation_{this};
base::Optional<base::TimeTicks> promo_load_start_time_;
// These are located at the end of the list of member variables to ensure the
diff --git a/chrome/browser/ui/webui/new_tab_page/untrusted_source.cc b/chrome/browser/ui/webui/new_tab_page/untrusted_source.cc
index 41d892c2..315fd9c0 100644
--- a/chrome/browser/ui/webui/new_tab_page/untrusted_source.cc
+++ b/chrome/browser/ui/webui/new_tab_page/untrusted_source.cc
@@ -71,7 +71,7 @@
// |one_google_bar_service_| is null in incognito, or when the feature is
// disabled.
if (one_google_bar_service_) {
- one_google_bar_service_observer_.Add(one_google_bar_service_);
+ one_google_bar_service_observation_.Observe(one_google_bar_service_);
}
}
@@ -269,7 +269,7 @@
}
void UntrustedSource::OnOneGoogleBarServiceShuttingDown() {
- one_google_bar_service_observer_.RemoveAll();
+ one_google_bar_service_observation_.Reset();
one_google_bar_service_ = nullptr;
}
diff --git a/chrome/browser/ui/webui/new_tab_page/untrusted_source.h b/chrome/browser/ui/webui/new_tab_page/untrusted_source.h
index 420a55c..03fd3bd 100644
--- a/chrome/browser/ui/webui/new_tab_page/untrusted_source.h
+++ b/chrome/browser/ui/webui/new_tab_page/untrusted_source.h
@@ -8,7 +8,7 @@
#include <string>
#include <vector>
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/search/one_google_bar/one_google_bar_service.h"
#include "chrome/browser/search/one_google_bar/one_google_bar_service_observer.h"
#include "content/public/browser/url_data_source.h"
@@ -79,8 +79,8 @@
std::vector<content::URLDataSource::GotDataCallback>
one_google_bar_callbacks_;
OneGoogleBarService* one_google_bar_service_;
- ScopedObserver<OneGoogleBarService, OneGoogleBarServiceObserver>
- one_google_bar_service_observer_{this};
+ base::ScopedObservation<OneGoogleBarService, OneGoogleBarServiceObserver>
+ one_google_bar_service_observation_{this};
base::Optional<base::TimeTicks> one_google_bar_load_start_time_;
Profile* profile_;
};
diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
index 38aa9336..24f5201 100644
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -582,7 +582,7 @@
}
void AppLauncherHandler::OnAppRegistrarDestroyed() {
- web_apps_observer_.RemoveAll();
+ web_apps_observation_.Reset();
}
void AppLauncherHandler::FillAppDictionary(base::DictionaryValue* dictionary) {
@@ -711,7 +711,7 @@
registrar_.Add(this, chrome::NOTIFICATION_APP_LAUNCHER_REORDERED,
content::Source<AppSorting>(
ExtensionSystem::Get(profile)->app_sorting()));
- web_apps_observer_.Add(&web_app_provider_->registrar());
+ web_apps_observation_.Observe(&web_app_provider_->registrar());
}
has_loaded_apps_ = true;
diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.h b/chrome/browser/ui/webui/ntp/app_launcher_handler.h
index f7fb6a7..385649119 100644
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.h
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.h
@@ -11,7 +11,7 @@
#include "base/macros.h"
#include "base/optional.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/task/cancelable_task_tracker.h"
#include "chrome/browser/extensions/extension_uninstall_dialog.h"
#include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h"
@@ -224,8 +224,8 @@
// features::kDesktopPWAsWithoutExtensions is enabled.
web_app::WebAppProvider* const web_app_provider_;
- ScopedObserver<web_app::AppRegistrar, web_app::AppRegistrarObserver>
- web_apps_observer_{this};
+ base::ScopedObservation<web_app::AppRegistrar, web_app::AppRegistrarObserver>
+ web_apps_observation_{this};
// We monitor changes to the extension system so that we can reload the apps
// when necessary.
diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
index 2cd7018..0c1fd1d8 100644
--- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
@@ -178,7 +178,7 @@
profile_pref_change_registrar_.Add(prefs::kHideWebStoreIcon, callback);
profile_pref_change_registrar_.Add(prefs::kCookieControlsMode, callback);
- theme_observer_.Add(ui::NativeTheme::GetInstanceForNativeUi());
+ theme_observation_.Observe(ui::NativeTheme::GetInstanceForNativeUi());
policy_change_registrar_ = std::make_unique<policy::PolicyChangeRegistrar>(
profile->GetProfilePolicyConnector()->policy_service(),
diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache.h b/chrome/browser/ui/webui/ntp/ntp_resource_cache.h
index 6e6fb43..353a3ec 100644
--- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.h
+++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.h
@@ -11,7 +11,7 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/ref_counted_memory.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/prefs/pref_change_registrar.h"
#include "content/public/browser/notification_observer.h"
@@ -134,8 +134,8 @@
// Set based on platform_util::IsSwipeTrackingFromScrollEventsEnabled.
bool is_swipe_tracking_from_scroll_events_enabled_;
- ScopedObserver<ui::NativeTheme, ui::NativeThemeObserver> theme_observer_{
- this};
+ base::ScopedObservation<ui::NativeTheme, ui::NativeThemeObserver>
+ theme_observation_{this};
std::unique_ptr<policy::PolicyChangeRegistrar> policy_change_registrar_;
diff --git a/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc b/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc
index a226e412..0b83168 100644
--- a/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc
+++ b/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc
@@ -200,10 +200,9 @@
OmniboxPageHandler::OmniboxPageHandler(
Profile* profile,
mojo::PendingReceiver<mojom::OmniboxPageHandler> receiver)
- : profile_(profile),
- receiver_(this, std::move(receiver)),
- observer_(this) {
- observer_.Add(OmniboxControllerEmitter::GetForBrowserContext(profile_));
+ : profile_(profile), receiver_(this, std::move(receiver)) {
+ observation_.Observe(
+ OmniboxControllerEmitter::GetForBrowserContext(profile_));
ResetController();
}
diff --git a/chrome/browser/ui/webui/omnibox/omnibox_page_handler.h b/chrome/browser/ui/webui/omnibox/omnibox_page_handler.h
index eee3cc2..3b529a26a 100644
--- a/chrome/browser/ui/webui/omnibox/omnibox_page_handler.h
+++ b/chrome/browser/ui/webui/omnibox/omnibox_page_handler.h
@@ -12,7 +12,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/time/time.h"
#include "chrome/browser/ui/webui/omnibox/omnibox.mojom.h"
#include "components/omnibox/browser/autocomplete_controller.h"
@@ -90,8 +90,9 @@
mojo::Receiver<mojom::OmniboxPageHandler> receiver_;
- ScopedObserver<OmniboxControllerEmitter, AutocompleteController::Observer>
- observer_;
+ base::ScopedObservation<OmniboxControllerEmitter,
+ AutocompleteController::Observer>
+ observation_{this};
base::WeakPtrFactory<OmniboxPageHandler> weak_factory_{this};
diff --git a/chrome/browser/ui/webui/settings/chromeos/accessibility_section.h b/chrome/browser/ui/webui/settings/chromeos/accessibility_section.h
index e87764dd..fab8783 100644
--- a/chrome/browser/ui/webui/settings/chromeos/accessibility_section.h
+++ b/chrome/browser/ui/webui/settings/chromeos/accessibility_section.h
@@ -5,7 +5,6 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_ACCESSIBILITY_SECTION_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_ACCESSIBILITY_SECTION_H_
-#include "base/scoped_observer.h"
#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
#include "components/prefs/pref_change_registrar.h"
diff --git a/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc b/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc
index 8ecced2..4eaf6b31 100644
--- a/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc
@@ -175,10 +175,7 @@
AccountManagerUIHandler::AccountManagerUIHandler(
AccountManager* account_manager,
signin::IdentityManager* identity_manager)
- : account_manager_(account_manager),
- identity_manager_(identity_manager),
- account_manager_observer_(this),
- identity_manager_observer_(this) {
+ : account_manager_(account_manager), identity_manager_(identity_manager) {
DCHECK(account_manager_);
DCHECK(identity_manager_);
}
@@ -407,13 +404,13 @@
}
void AccountManagerUIHandler::OnJavascriptAllowed() {
- account_manager_observer_.Add(account_manager_);
- identity_manager_observer_.Add(identity_manager_);
+ account_manager_observation_.Observe(account_manager_);
+ identity_manager_observation_.Observe(identity_manager_);
}
void AccountManagerUIHandler::OnJavascriptDisallowed() {
- account_manager_observer_.RemoveAll();
- identity_manager_observer_.RemoveAll();
+ account_manager_observation_.Reset();
+ identity_manager_observation_.Reset();
}
// |AccountManager::Observer| overrides. Note: We need to listen on
diff --git a/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h b/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h
index f3d2bfc..4482af6 100644
--- a/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h
+++ b/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h
@@ -10,7 +10,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chromeos/components/account_manager/account_manager.h"
#include "components/account_id/account_id.h"
@@ -104,13 +104,14 @@
// An observer for |AccountManager|. Automatically deregisters when |this| is
// destructed.
- ScopedObserver<AccountManager, AccountManager::Observer>
- account_manager_observer_;
+ base::ScopedObservation<AccountManager, AccountManager::Observer>
+ account_manager_observation_{this};
// An observer for |signin::IdentityManager|. Automatically deregisters when
// |this| is destructed.
- ScopedObserver<signin::IdentityManager, signin::IdentityManager::Observer>
- identity_manager_observer_;
+ base::ScopedObservation<signin::IdentityManager,
+ signin::IdentityManager::Observer>
+ identity_manager_observation_{this};
base::WeakPtrFactory<AccountManagerUIHandler> weak_factory_{this};
diff --git a/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc b/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc
index df482d3..9356083f 100644
--- a/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc
@@ -17,10 +17,7 @@
namespace chromeos {
namespace settings {
-AndroidAppsHandler::AndroidAppsHandler(Profile* profile)
- : arc_prefs_observer_(this),
- arc_session_manager_observer_(this),
- profile_(profile) {}
+AndroidAppsHandler::AndroidAppsHandler(Profile* profile) : profile_(profile) {}
AndroidAppsHandler::~AndroidAppsHandler() {}
@@ -43,15 +40,15 @@
void AndroidAppsHandler::OnJavascriptAllowed() {
ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile_);
if (arc_prefs) {
- arc_prefs_observer_.Add(arc_prefs);
+ arc_prefs_observation_.Observe(arc_prefs);
// arc::ArcSessionManager is associated with primary profile.
- arc_session_manager_observer_.Add(arc::ArcSessionManager::Get());
+ arc_session_manager_observation_.Observe(arc::ArcSessionManager::Get());
}
}
void AndroidAppsHandler::OnJavascriptDisallowed() {
- arc_prefs_observer_.RemoveAll();
- arc_session_manager_observer_.RemoveAll();
+ arc_prefs_observation_.Reset();
+ arc_session_manager_observation_.Reset();
}
void AndroidAppsHandler::OnAppRegistered(
diff --git a/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h b/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h
index f6b0242..373e2a12 100644
--- a/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h
+++ b/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h
@@ -10,7 +10,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/chromeos/arc/session/arc_session_manager.h"
#include "chrome/browser/chromeos/arc/session/arc_session_manager_observer.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
@@ -56,10 +56,11 @@
void ShowAndroidManageAppLinks(const base::ListValue* args);
int64_t GetDisplayIdForCurrentProfile();
- ScopedObserver<ArcAppListPrefs, ArcAppListPrefs::Observer>
- arc_prefs_observer_;
- ScopedObserver<arc::ArcSessionManager, arc::ArcSessionManagerObserver>
- arc_session_manager_observer_;
+ base::ScopedObservation<ArcAppListPrefs, ArcAppListPrefs::Observer>
+ arc_prefs_observation_{this};
+ base::ScopedObservation<arc::ArcSessionManager,
+ arc::ArcSessionManagerObserver>
+ arc_session_manager_observation_{this};
Profile* profile_; // unowned
base::WeakPtrFactory<AndroidAppsHandler> weak_ptr_factory_{this};
diff --git a/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc b/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc
index 6431584..2618d07 100644
--- a/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc
@@ -121,13 +121,18 @@
}
void ChangePictureHandler::OnJavascriptAllowed() {
- user_manager_observer_.Add(user_manager::UserManager::Get());
- camera_observer_.Add(CameraPresenceNotifier::GetInstance());
+ user_manager_observation_.Observe(user_manager::UserManager::Get());
+ camera_observation_.Observe(CameraPresenceNotifier::GetInstance());
}
void ChangePictureHandler::OnJavascriptDisallowed() {
- user_manager_observer_.Remove(user_manager::UserManager::Get());
- camera_observer_.Remove(CameraPresenceNotifier::GetInstance());
+ DCHECK(user_manager_observation_.IsObservingSource(
+ user_manager::UserManager::Get()));
+ user_manager_observation_.Reset();
+
+ DCHECK(camera_observation_.IsObservingSource(
+ CameraPresenceNotifier::GetInstance()));
+ camera_observation_.Reset();
}
void ChangePictureHandler::SendDefaultImages() {
diff --git a/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h b/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h
index 1be240f6..e18ab47 100644
--- a/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h
+++ b/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h
@@ -7,7 +7,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/chromeos/camera_presence_notifier.h"
#include "chrome/browser/image_decoder/image_decoder.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
@@ -139,10 +139,12 @@
// Data for |user_photo_|.
scoped_refptr<base::RefCountedBytes> user_photo_data_;
- ScopedObserver<user_manager::UserManager, user_manager::UserManager::Observer>
- user_manager_observer_{this};
- ScopedObserver<CameraPresenceNotifier, CameraPresenceNotifier::Observer>
- camera_observer_{this};
+ base::ScopedObservation<user_manager::UserManager,
+ user_manager::UserManager::Observer>
+ user_manager_observation_{this};
+ base::ScopedObservation<CameraPresenceNotifier,
+ CameraPresenceNotifier::Observer>
+ camera_observation_{this};
base::WeakPtrFactory<ChangePictureHandler> weak_ptr_factory_{this};
diff --git a/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc b/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
index 9ac8f2d..88ac19b 100644
--- a/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
@@ -269,8 +269,8 @@
ppd_provider_(ppd_provider),
printer_configurer_(std::move(printer_configurer)),
printers_manager_(printers_manager),
- endpoint_resolver_(std::make_unique<local_discovery::EndpointResolver>()),
- printers_manager_observer_(this) {}
+ endpoint_resolver_(
+ std::make_unique<local_discovery::EndpointResolver>()) {}
// static
std::unique_ptr<CupsPrintersHandler> CupsPrintersHandler::CreateForTesting(
@@ -367,13 +367,12 @@
}
void CupsPrintersHandler::OnJavascriptAllowed() {
- if (!printers_manager_observer_.IsObservingSources()) {
- printers_manager_observer_.Add(printers_manager_);
- }
+ DCHECK(!printers_manager_observation_.IsObserving());
+ printers_manager_observation_.Observe(printers_manager_);
}
void CupsPrintersHandler::OnJavascriptDisallowed() {
- printers_manager_observer_.RemoveAll();
+ printers_manager_observation_.Reset();
}
void CupsPrintersHandler::SetWebUIForTest(content::WebUI* web_ui) {
diff --git a/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h b/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h
index 75fc8e7..1cc8e7f 100644
--- a/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h
+++ b/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h
@@ -11,7 +11,7 @@
#include <vector>
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/chromeos/printing/cups_printers_manager.h"
#include "chrome/browser/chromeos/printing/printer_configurer.h"
#include "chrome/browser/chromeos/printing/printer_event_tracker.h"
@@ -264,8 +264,8 @@
std::unique_ptr<ServerPrintersFetcher> server_printers_fetcher_;
- ScopedObserver<CupsPrintersManager, CupsPrintersManager::Observer>
- printers_manager_observer_;
+ base::ScopedObservation<CupsPrintersManager, CupsPrintersManager::Observer>
+ printers_manager_observation_{this};
base::WeakPtrFactory<CupsPrintersHandler> weak_factory_{this};
diff --git a/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc b/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc
index eef12177..d94ebf71e 100644
--- a/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc
@@ -65,7 +65,7 @@
} // namespace
-DateTimeHandler::DateTimeHandler() : scoped_observer_(this) {}
+DateTimeHandler::DateTimeHandler() {}
DateTimeHandler::~DateTimeHandler() = default;
@@ -89,7 +89,7 @@
void DateTimeHandler::OnJavascriptAllowed() {
SystemClockClient* system_clock_client = SystemClockClient::Get();
- scoped_observer_.Add(system_clock_client);
+ scoped_observation_.Observe(system_clock_client);
SystemClockCanSetTimeChanged(system_clock_client->CanSetTime());
// The system time zone policy disables auto-detection entirely. (However,
@@ -111,7 +111,7 @@
}
void DateTimeHandler::OnJavascriptDisallowed() {
- scoped_observer_.RemoveAll();
+ scoped_observation_.Reset();
system_timezone_policy_subscription_ = {};
local_state_pref_change_registrar_.RemoveAll();
}
diff --git a/chrome/browser/ui/webui/settings/chromeos/date_time_handler.h b/chrome/browser/ui/webui/settings/chromeos/date_time_handler.h
index e301d09..b9fa321 100644
--- a/chrome/browser/ui/webui/settings/chromeos/date_time_handler.h
+++ b/chrome/browser/ui/webui/settings/chromeos/date_time_handler.h
@@ -9,7 +9,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chromeos/dbus/system_clock/system_clock_client.h"
@@ -64,8 +64,8 @@
// Used to listen to changes to the system time zone detection policy.
PrefChangeRegistrar local_state_pref_change_registrar_;
- ScopedObserver<SystemClockClient, SystemClockClient::Observer>
- scoped_observer_;
+ base::ScopedObservation<SystemClockClient, SystemClockClient::Observer>
+ scoped_observation_{this};
base::WeakPtrFactory<DateTimeHandler> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(DateTimeHandler);
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc b/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc
index 21f56f9..73f3ecb 100644
--- a/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc
@@ -82,11 +82,11 @@
}
void KeyboardHandler::OnJavascriptAllowed() {
- observer_.Add(ui::DeviceDataManager::GetInstance());
+ observation_.Observe(ui::DeviceDataManager::GetInstance());
}
void KeyboardHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
+ observation_.Reset();
}
void KeyboardHandler::OnInputDeviceConfigurationChanged(
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h b/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h
index ee6c480..403303c8 100644
--- a/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h
+++ b/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_KEYBOARD_HANDLER_H_
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "ui/events/devices/device_data_manager.h"
#include "ui/events/devices/input_device_event_observer.h"
@@ -68,8 +68,8 @@
// Sends the UI a message about whether hardware keyboard are attached.
void UpdateKeyboards();
- ScopedObserver<ui::DeviceDataManager, ui::InputDeviceEventObserver> observer_{
- this};
+ base::ScopedObservation<ui::DeviceDataManager, ui::InputDeviceEventObserver>
+ observation_{this};
DISALLOW_COPY_AND_ASSIGN(KeyboardHandler);
};
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_name_handler.h b/chrome/browser/ui/webui/settings/chromeos/device_name_handler.h
index 62d32df4..79b4f67 100644
--- a/chrome/browser/ui/webui/settings/chromeos/device_name_handler.h
+++ b/chrome/browser/ui/webui/settings/chromeos/device_name_handler.h
@@ -6,7 +6,6 @@
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_NAME_HANDLER_H_
#include "base/macros.h"
-#include "base/scoped_observer.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
namespace base {
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc b/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc
index 00f86112..6bf1eca 100644
--- a/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc
@@ -162,7 +162,7 @@
void PowerHandler::OnJavascriptAllowed() {
PowerManagerClient* power_manager_client = PowerManagerClient::Get();
- power_manager_client_observer_.Add(power_manager_client);
+ power_manager_client_observation_.Observe(power_manager_client);
power_manager_client->GetSwitchStates(base::BindOnce(
&PowerHandler::OnGotSwitchStates, weak_ptr_factory_.GetWeakPtr()));
@@ -187,7 +187,7 @@
}
void PowerHandler::OnJavascriptDisallowed() {
- power_manager_client_observer_.RemoveAll();
+ power_manager_client_observation_.Reset();
pref_change_registrar_.reset();
}
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h b/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h
index 2f8b60f..699802af 100644
--- a/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h
+++ b/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h
@@ -11,7 +11,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/strings/string16.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chromeos/dbus/power/power_manager_client.h"
@@ -158,8 +158,8 @@
// Used to watch power management prefs for changes so the UI can be notified.
std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
- ScopedObserver<PowerManagerClient, PowerManagerClient::Observer>
- power_manager_client_observer_{this};
+ base::ScopedObservation<PowerManagerClient, PowerManagerClient::Observer>
+ power_manager_client_observation_{this};
// Last lid state received from powerd.
PowerManagerClient::LidState lid_state_ = PowerManagerClient::LidState::OPEN;
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc b/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc
index c299a2b..ad8de48 100644
--- a/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc
@@ -65,7 +65,6 @@
other_users_size_calculator_(),
profile_(profile),
source_name_(html_source->GetSource()),
- arc_observer_(this),
special_volume_path_pattern_("[a-z]+://.*") {
// TODO(khorimoto): Set kAndroidEnabled within DeviceSection, and
// updates this value accordingly (see OnArcPlayStoreEnabledChanged()).
@@ -103,7 +102,7 @@
void StorageHandler::OnJavascriptAllowed() {
if (base::FeatureList::IsEnabled(arc::kUsbStorageUIFeature))
- arc_observer_.Add(arc::ArcSessionManager::Get());
+ arc_observation_.Observe(arc::ArcSessionManager::Get());
// Start observing mount/unmount events to update the connected device list.
DiskMountManager::GetInstance()->AddObserver(this);
@@ -121,8 +120,10 @@
// Ensure that pending callbacks do not complete and cause JS to be evaluated.
weak_ptr_factory_.InvalidateWeakPtrs();
- if (base::FeatureList::IsEnabled(arc::kUsbStorageUIFeature))
- arc_observer_.Remove(arc::ArcSessionManager::Get());
+ if (base::FeatureList::IsEnabled(arc::kUsbStorageUIFeature)) {
+ DCHECK(arc_observation_.IsObservingSource(arc::ArcSessionManager::Get()));
+ arc_observation_.Reset();
+ }
StopObservingEvents();
}
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h b/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h
index 78e3db0..0819ea17 100644
--- a/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h
+++ b/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h
@@ -7,6 +7,7 @@
#include <string>
+#include "base/scoped_observation.h"
#include "chrome/browser/chromeos/arc/session/arc_session_manager.h"
#include "chrome/browser/chromeos/arc/session/arc_session_manager_observer.h"
#include "chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.h"
@@ -125,8 +126,9 @@
Profile* const profile_;
const std::string source_name_;
- ScopedObserver<arc::ArcSessionManager, arc::ArcSessionManagerObserver>
- arc_observer_;
+ base::ScopedObservation<arc::ArcSessionManager,
+ arc::ArcSessionManagerObserver>
+ arc_observation_{this};
const re2::RE2 special_volume_path_pattern_;
base::WeakPtrFactory<StorageHandler> weak_ptr_factory_{this};
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc b/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc
index ad7f2ee..678ea9c 100644
--- a/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc
@@ -60,13 +60,13 @@
}
void StylusHandler::OnJavascriptAllowed() {
- note_observer_.Add(NoteTakingHelper::Get());
- input_observer_.Add(ui::DeviceDataManager::GetInstance());
+ note_observation_.Observe(NoteTakingHelper::Get());
+ input_observation_.Observe(ui::DeviceDataManager::GetInstance());
}
void StylusHandler::OnJavascriptDisallowed() {
- note_observer_.RemoveAll();
- input_observer_.RemoveAll();
+ note_observation_.Reset();
+ input_observation_.Reset();
}
void StylusHandler::OnAvailableNoteTakingAppsUpdated() {
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h b/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h
index c0e2429..8e1ca21a 100644
--- a/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h
+++ b/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h
@@ -9,7 +9,7 @@
#include <string>
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/chromeos/note_taking_helper.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "ui/events/devices/device_data_manager.h"
@@ -60,10 +60,10 @@
std::set<std::string> note_taking_app_ids_;
// Observer registration.
- ScopedObserver<NoteTakingHelper, NoteTakingHelper::Observer> note_observer_{
- this};
- ScopedObserver<ui::DeviceDataManager, ui::InputDeviceEventObserver>
- input_observer_{this};
+ base::ScopedObservation<NoteTakingHelper, NoteTakingHelper::Observer>
+ note_observation_{this};
+ base::ScopedObservation<ui::DeviceDataManager, ui::InputDeviceEventObserver>
+ input_observation_{this};
DISALLOW_COPY_AND_ASSIGN(StylusHandler);
};
diff --git a/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc b/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
index a7ada16..1f9ae59 100644
--- a/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
@@ -105,13 +105,13 @@
void FingerprintHandler::OnJavascriptAllowed() {
// SessionManager may not exist in some tests.
if (SessionManager::Get())
- session_observer_.Add(SessionManager::Get());
+ session_observation_.Observe(SessionManager::Get());
fp_service_->AddFingerprintObserver(receiver_.BindNewPipeAndPassRemote());
}
void FingerprintHandler::OnJavascriptDisallowed() {
- session_observer_.RemoveAll();
+ session_observation_.Reset();
receiver_.reset();
}
diff --git a/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h b/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h
index 97c85fd..b18be765 100644
--- a/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h
+++ b/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_FINGERPRINT_HANDLER_H_
#include "base/containers/flat_map.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "components/session_manager/core/session_manager.h"
#include "components/session_manager/core/session_manager_observer.h"
@@ -79,9 +79,9 @@
mojo::Remote<device::mojom::Fingerprint> fp_service_;
mojo::Receiver<device::mojom::FingerprintObserver> receiver_{this};
- ScopedObserver<session_manager::SessionManager,
- session_manager::SessionManagerObserver>
- session_observer_{this};
+ base::ScopedObservation<session_manager::SessionManager,
+ session_manager::SessionManagerObserver>
+ session_observation_{this};
base::WeakPtrFactory<FingerprintHandler> weak_ptr_factory_{this};
diff --git a/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.cc b/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.cc
index b971238..e49ec10 100644
--- a/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.cc
@@ -394,11 +394,11 @@
}
void KerberosAccountsHandler::OnJavascriptAllowed() {
- credentials_manager_observer_.Add(kerberos_credentials_manager_);
+ credentials_manager_observation_.Observe(kerberos_credentials_manager_);
}
void KerberosAccountsHandler::OnJavascriptDisallowed() {
- credentials_manager_observer_.RemoveAll();
+ credentials_manager_observation_.Reset();
}
void KerberosAccountsHandler::OnAccountsChanged() {
diff --git a/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.h b/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.h
index 622f2a7..9c2d1e3a 100644
--- a/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.h
+++ b/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.h
@@ -11,7 +11,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/chromeos/kerberos/kerberos_credentials_manager.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chromeos/dbus/kerberos/kerberos_service.pb.h"
@@ -92,9 +92,9 @@
// This instance can be added as observer to KerberosCredentialsManager.
// This class keeps track of that and removes this instance on destruction.
- ScopedObserver<KerberosCredentialsManager,
- KerberosCredentialsManager::Observer>
- credentials_manager_observer_{this};
+ base::ScopedObservation<KerberosCredentialsManager,
+ KerberosCredentialsManager::Observer>
+ credentials_manager_observation_{this};
// Not owned.
KerberosCredentialsManager* kerberos_credentials_manager_;
diff --git a/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc b/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc
index 158e13f..07c0a5c 100644
--- a/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc
@@ -70,11 +70,7 @@
multidevice_setup_client_(multidevice_setup_client),
notification_access_manager_(notification_access_manager),
android_sms_pairing_state_tracker_(android_sms_pairing_state_tracker),
- android_sms_app_manager_(android_sms_app_manager),
- multidevice_setup_observer_(this),
- android_sms_pairing_state_tracker_observer_(this),
- android_sms_app_manager_observer_(this),
- notification_access_manager_observer_(this) {
+ android_sms_app_manager_(android_sms_app_manager) {
pref_change_registrar_.Init(prefs_);
}
@@ -133,18 +129,19 @@
void MultideviceHandler::OnJavascriptAllowed() {
if (multidevice_setup_client_)
- multidevice_setup_observer_.Add(multidevice_setup_client_);
+ multidevice_setup_observation_.Observe(multidevice_setup_client_);
if (notification_access_manager_)
- notification_access_manager_observer_.Add(notification_access_manager_);
+ notification_access_manager_observation_.Observe(
+ notification_access_manager_);
if (android_sms_pairing_state_tracker_) {
- android_sms_pairing_state_tracker_observer_.Add(
+ android_sms_pairing_state_tracker_observation_.Observe(
android_sms_pairing_state_tracker_);
}
if (android_sms_app_manager_)
- android_sms_app_manager_observer_.Add(android_sms_app_manager_);
+ android_sms_app_manager_observation_.Observe(android_sms_app_manager_);
pref_change_registrar_.Add(
proximity_auth::prefs::kProximityAuthIsChromeOSLoginEnabled,
@@ -161,21 +158,30 @@
void MultideviceHandler::OnJavascriptDisallowed() {
pref_change_registrar_.RemoveAll();
- if (multidevice_setup_client_)
- multidevice_setup_observer_.Remove(multidevice_setup_client_);
+ if (multidevice_setup_client_) {
+ DCHECK(multidevice_setup_observation_.IsObservingSource(
+ multidevice_setup_client_));
+ multidevice_setup_observation_.Reset();
+ }
if (notification_access_manager_) {
- notification_access_manager_observer_.Remove(notification_access_manager_);
+ DCHECK(notification_access_manager_observation_.IsObservingSource(
+ notification_access_manager_));
+ notification_access_manager_observation_.Reset();
notification_access_operation_.reset();
}
if (android_sms_pairing_state_tracker_) {
- android_sms_pairing_state_tracker_observer_.Remove(
- android_sms_pairing_state_tracker_);
+ DCHECK(android_sms_pairing_state_tracker_observation_.IsObservingSource(
+ android_sms_pairing_state_tracker_));
+ android_sms_pairing_state_tracker_observation_.Reset();
}
- if (android_sms_app_manager_)
- android_sms_app_manager_observer_.Remove(android_sms_app_manager_);
+ if (android_sms_app_manager_) {
+ DCHECK(android_sms_app_manager_observation_.IsObservingSource(
+ android_sms_app_manager_));
+ android_sms_app_manager_observation_.Reset();
+ }
// Ensure that pending callbacks do not complete and cause JS to be evaluated.
callback_weak_ptr_factory_.InvalidateWeakPtrs();
diff --git a/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h b/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h
index e4217ae..58e55754 100644
--- a/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h
+++ b/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h
@@ -7,7 +7,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/chromeos/android_sms/android_sms_app_manager.h"
#include "chrome/browser/chromeos/android_sms/android_sms_service_factory.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
@@ -137,18 +137,19 @@
android_sms_pairing_state_tracker_;
android_sms::AndroidSmsAppManager* android_sms_app_manager_;
- ScopedObserver<multidevice_setup::MultiDeviceSetupClient,
- multidevice_setup::MultiDeviceSetupClient::Observer>
- multidevice_setup_observer_;
- ScopedObserver<multidevice_setup::AndroidSmsPairingStateTracker,
- multidevice_setup::AndroidSmsPairingStateTracker::Observer>
- android_sms_pairing_state_tracker_observer_;
- ScopedObserver<android_sms::AndroidSmsAppManager,
- android_sms::AndroidSmsAppManager::Observer>
- android_sms_app_manager_observer_;
- ScopedObserver<phonehub::NotificationAccessManager,
- phonehub::NotificationAccessManager::Observer>
- notification_access_manager_observer_;
+ base::ScopedObservation<multidevice_setup::MultiDeviceSetupClient,
+ multidevice_setup::MultiDeviceSetupClient::Observer>
+ multidevice_setup_observation_{this};
+ base::ScopedObservation<
+ multidevice_setup::AndroidSmsPairingStateTracker,
+ multidevice_setup::AndroidSmsPairingStateTracker::Observer>
+ android_sms_pairing_state_tracker_observation_{this};
+ base::ScopedObservation<android_sms::AndroidSmsAppManager,
+ android_sms::AndroidSmsAppManager::Observer>
+ android_sms_app_manager_observation_{this};
+ base::ScopedObservation<phonehub::NotificationAccessManager,
+ phonehub::NotificationAccessManager::Observer>
+ notification_access_manager_observation_{this};
// Used to cancel callbacks when JavaScript becomes disallowed.
base::WeakPtrFactory<MultideviceHandler> callback_weak_ptr_factory_{this};
diff --git a/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.cc b/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.cc
index b53e6c3..b3594e94 100644
--- a/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.cc
@@ -76,12 +76,12 @@
void PluginVmHandler::OnJavascriptAllowed() {
if (auto* detector = chromeos::CrosUsbDetector::Get()) {
- cros_usb_device_observer_.Add(detector);
+ cros_usb_device_observation_.Observe(detector);
}
}
void PluginVmHandler::OnJavascriptDisallowed() {
- cros_usb_device_observer_.RemoveAll();
+ cros_usb_device_observation_.Reset();
}
void PluginVmHandler::HandleGetPluginVmSharedPathsDisplayText(
diff --git a/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.h b/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.h
index a9f3f7b..f75a347 100644
--- a/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.h
+++ b/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.h
@@ -8,7 +8,7 @@
#include <vector>
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager.h"
#include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager_factory.h"
#include "chrome/browser/chromeos/usb/cros_usb_detector.h"
@@ -57,11 +57,11 @@
const std::string& failure_reason);
Profile* profile_;
- ScopedObserver<CrosUsbDetector,
- CrosUsbDeviceObserver,
- &CrosUsbDetector::AddUsbDeviceObserver,
- &CrosUsbDetector::RemoveUsbDeviceObserver>
- cros_usb_device_observer_{this};
+ base::ScopedObservation<CrosUsbDetector,
+ CrosUsbDeviceObserver,
+ &CrosUsbDetector::AddUsbDeviceObserver,
+ &CrosUsbDetector::RemoveUsbDeviceObserver>
+ cros_usb_device_observation_{this};
// weak_ptr_factory_ should always be last member.
base::WeakPtrFactory<PluginVmHandler> weak_ptr_factory_{this};
diff --git a/chrome/browser/ui/webui/settings/font_handler.h b/chrome/browser/ui/webui/settings/font_handler.h
index 1889231..96669a5 100644
--- a/chrome/browser/ui/webui/settings/font_handler.h
+++ b/chrome/browser/ui/webui/settings/font_handler.h
@@ -10,7 +10,6 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
class Profile;
diff --git a/chrome/browser/ui/webui/settings/on_startup_handler.cc b/chrome/browser/ui/webui/settings/on_startup_handler.cc
index 3d1bbd91..5756ab2 100644
--- a/chrome/browser/ui/webui/settings/on_startup_handler.cc
+++ b/chrome/browser/ui/webui/settings/on_startup_handler.cc
@@ -24,19 +24,18 @@
const char OnStartupHandler::kOnStartupNtpExtensionEventName[] =
"update-ntp-extension";
-OnStartupHandler::OnStartupHandler(Profile* profile)
- : extension_registry_observer_(this), profile_(profile) {
+OnStartupHandler::OnStartupHandler(Profile* profile) : profile_(profile) {
DCHECK(profile);
}
OnStartupHandler::~OnStartupHandler() {}
void OnStartupHandler::OnJavascriptAllowed() {
- extension_registry_observer_.Add(
+ extension_registry_observation_.Observe(
extensions::ExtensionRegistry::Get(profile_));
}
void OnStartupHandler::OnJavascriptDisallowed() {
- extension_registry_observer_.RemoveAll();
+ extension_registry_observation_.Reset();
}
void OnStartupHandler::RegisterMessages() {
diff --git a/chrome/browser/ui/webui/settings/on_startup_handler.h b/chrome/browser/ui/webui/settings/on_startup_handler.h
index e5438a3..56edf61 100644
--- a/chrome/browser/ui/webui/settings/on_startup_handler.h
+++ b/chrome/browser/ui/webui/settings/on_startup_handler.h
@@ -8,7 +8,7 @@
#include <memory>
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_registry_observer.h"
@@ -59,9 +59,9 @@
const extensions::Extension* extension) override;
// Listen to extension unloaded notifications.
- ScopedObserver<extensions::ExtensionRegistry,
- extensions::ExtensionRegistryObserver>
- extension_registry_observer_;
+ base::ScopedObservation<extensions::ExtensionRegistry,
+ extensions::ExtensionRegistryObserver>
+ extension_registry_observation_{this};
Profile* profile_;
diff --git a/chrome/browser/ui/webui/settings/people_handler.cc b/chrome/browser/ui/webui/settings/people_handler.cc
index 4b8177ad..707c936 100644
--- a/chrome/browser/ui/webui/settings/people_handler.cc
+++ b/chrome/browser/ui/webui/settings/people_handler.cc
@@ -332,20 +332,20 @@
signin::IdentityManager* identity_manager(
IdentityManagerFactory::GetInstance()->GetForProfile(profile_));
if (identity_manager)
- identity_manager_observer_.Add(identity_manager);
+ identity_manager_observation_.Observe(identity_manager);
// This is intentionally not using GetSyncService(), to go around the
// Profile::IsSyncAllowed() check.
syncer::SyncService* sync_service =
ProfileSyncServiceFactory::GetForProfile(profile_);
if (sync_service)
- sync_service_observer_.Add(sync_service);
+ sync_service_observation_.Observe(sync_service);
}
void PeopleHandler::OnJavascriptDisallowed() {
profile_pref_registrar_.RemoveAll();
- identity_manager_observer_.RemoveAll();
- sync_service_observer_.RemoveAll();
+ identity_manager_observation_.Reset();
+ sync_service_observation_.Reset();
}
#if !BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chrome/browser/ui/webui/settings/people_handler.h b/chrome/browser/ui/webui/settings/people_handler.h
index c50237f..fdc26132 100644
--- a/chrome/browser/ui/webui/settings/people_handler.h
+++ b/chrome/browser/ui/webui/settings/people_handler.h
@@ -10,7 +10,7 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/timer/timer.h"
#include "build/build_config.h"
#include "build/buildflag.h"
@@ -228,10 +228,11 @@
PrefChangeRegistrar profile_pref_registrar_;
// Manages observer lifetimes.
- ScopedObserver<signin::IdentityManager, signin::IdentityManager::Observer>
- identity_manager_observer_{this};
- ScopedObserver<syncer::SyncService, syncer::SyncServiceObserver>
- sync_service_observer_{this};
+ base::ScopedObservation<signin::IdentityManager,
+ signin::IdentityManager::Observer>
+ identity_manager_observation_{this};
+ base::ScopedObservation<syncer::SyncService, syncer::SyncServiceObserver>
+ sync_service_observation_{this};
base::WeakPtrFactory<PeopleHandler> weak_factory_{this};
diff --git a/chrome/browser/ui/webui/settings/profile_info_handler.cc b/chrome/browser/ui/webui/settings/profile_info_handler.cc
index df6ca79..a0047996 100644
--- a/chrome/browser/ui/webui/settings/profile_info_handler.cc
+++ b/chrome/browser/ui/webui/settings/profile_info_handler.cc
@@ -58,22 +58,25 @@
}
void ProfileInfoHandler::OnJavascriptAllowed() {
- profile_observer_.Add(
+ profile_observation_.Observe(
&g_browser_process->profile_manager()->GetProfileAttributesStorage());
#if BUILDFLAG(IS_CHROMEOS_ASH)
- user_manager_observer_.Add(user_manager::UserManager::Get());
+ user_manager_observation_.Observe(user_manager::UserManager::Get());
#endif
}
void ProfileInfoHandler::OnJavascriptDisallowed() {
callback_weak_ptr_factory_.InvalidateWeakPtrs();
- profile_observer_.Remove(
- &g_browser_process->profile_manager()->GetProfileAttributesStorage());
+ DCHECK(profile_observation_.IsObservingSource(
+ &g_browser_process->profile_manager()->GetProfileAttributesStorage()));
+ profile_observation_.Reset();
#if BUILDFLAG(IS_CHROMEOS_ASH)
- user_manager_observer_.Remove(user_manager::UserManager::Get());
+ DCHECK(user_manager_observation_.IsObservingSource(
+ user_manager::UserManager::Get()));
+ user_manager_observation_.Reset();
#endif
}
diff --git a/chrome/browser/ui/webui/settings/profile_info_handler.h b/chrome/browser/ui/webui/settings/profile_info_handler.h
index bc6195c..cd5be0f1 100644
--- a/chrome/browser/ui/webui/settings/profile_info_handler.h
+++ b/chrome/browser/ui/webui/settings/profile_info_handler.h
@@ -9,7 +9,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
@@ -75,12 +75,14 @@
Profile* profile_;
#if BUILDFLAG(IS_CHROMEOS_ASH)
- ScopedObserver<user_manager::UserManager, user_manager::UserManager::Observer>
- user_manager_observer_{this};
+ base::ScopedObservation<user_manager::UserManager,
+ user_manager::UserManager::Observer>
+ user_manager_observation_{this};
#endif
- ScopedObserver<ProfileAttributesStorage, ProfileAttributesStorage::Observer>
- profile_observer_{this};
+ base::ScopedObservation<ProfileAttributesStorage,
+ ProfileAttributesStorage::Observer>
+ profile_observation_{this};
// Used to cancel callbacks when JavaScript becomes disallowed.
base::WeakPtrFactory<ProfileInfoHandler> callback_weak_ptr_factory_{this};
diff --git a/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc b/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc
index 5b183c7..b453a5eb 100644
--- a/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc
+++ b/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc
@@ -48,11 +48,11 @@
ProtocolHandlersHandler::~ProtocolHandlersHandler() = default;
void ProtocolHandlersHandler::OnJavascriptAllowed() {
- registry_observer_.Add(GetProtocolHandlerRegistry());
+ registry_observation_.Observe(GetProtocolHandlerRegistry());
}
void ProtocolHandlersHandler::OnJavascriptDisallowed() {
- registry_observer_.RemoveAll();
+ registry_observation_.Reset();
}
void ProtocolHandlersHandler::RegisterMessages() {
diff --git a/chrome/browser/ui/webui/settings/protocol_handlers_handler.h b/chrome/browser/ui/webui/settings/protocol_handlers_handler.h
index 0b5b576..4ab0c6d 100644
--- a/chrome/browser/ui/webui/settings/protocol_handlers_handler.h
+++ b/chrome/browser/ui/webui/settings/protocol_handlers_handler.h
@@ -8,7 +8,7 @@
#include <string>
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chrome/common/custom_handlers/protocol_handler.h"
@@ -81,8 +81,9 @@
ProtocolHandlerRegistry* GetProtocolHandlerRegistry();
- ScopedObserver<ProtocolHandlerRegistry, ProtocolHandlerRegistry::Observer>
- registry_observer_{this};
+ base::ScopedObservation<ProtocolHandlerRegistry,
+ ProtocolHandlerRegistry::Observer>
+ registry_observation_{this};
DISALLOW_COPY_AND_ASSIGN(ProtocolHandlersHandler);
};
diff --git a/chrome/browser/ui/webui/settings/safety_check_handler.cc b/chrome/browser/ui/webui/settings/safety_check_handler.cc
index 39e80de..7609236 100644
--- a/chrome/browser/ui/webui/settings/safety_check_handler.cc
+++ b/chrome/browser/ui/webui/settings/safety_check_handler.cc
@@ -400,11 +400,11 @@
// registered. This takes care of an edge case when safety check starts twice
// on the same page. Normally this should not happen, but if it does, the
// browser should not crash.
- observed_leak_check_.RemoveAll();
- observed_leak_check_.Add(leak_service_);
+ observed_leak_check_.Reset();
+ observed_leak_check_.Observe(leak_service_);
// Start observing the InsecureCredentialsManager.
- observed_insecure_credentials_manager_.RemoveAll();
- observed_insecure_credentials_manager_.Add(insecure_credentials_manager_);
+ observed_insecure_credentials_manager_.Reset();
+ observed_insecure_credentials_manager_.Observe(insecure_credentials_manager_);
passwords_delegate_->StartPasswordCheck(base::BindOnce(
&SafetyCheckHandler::OnStateChanged, weak_ptr_factory_.GetWeakPtr()));
}
@@ -888,7 +888,7 @@
// need to wait for InsecureCredentialsManager callbacks any longer, since
// there should be none for the current password check.
if (!compromised_passwords_exist_) {
- observed_insecure_credentials_manager_.RemoveAll();
+ observed_insecure_credentials_manager_.Reset();
}
passwords_delegate_->GetSavedPasswordsList(
base::BindOnce(&SafetyCheckHandler::DetermineIfNoPasswordsOrSafe,
@@ -942,7 +942,7 @@
case BulkLeakCheckService::State::kIdle:
case BulkLeakCheckService::State::kCanceled: {
UpdatePasswordsResultOnCheckIdle();
- observed_leak_check_.RemoveAll();
+ observed_leak_check_.Reset();
return;
}
case BulkLeakCheckService::State::kRunning:
@@ -975,8 +975,8 @@
// Stop observing the leak service and credentials manager in all non-idle
// states.
- observed_leak_check_.RemoveAll();
- observed_insecure_credentials_manager_.RemoveAll();
+ observed_leak_check_.Reset();
+ observed_insecure_credentials_manager_.Reset();
}
void SafetyCheckHandler::OnCredentialDone(
@@ -1011,7 +1011,7 @@
}
UpdatePasswordsResultOnCheckIdle();
// Stop observing the manager to avoid dynamically updating the result.
- observed_insecure_credentials_manager_.RemoveAll();
+ observed_insecure_credentials_manager_.Reset();
}
#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
@@ -1060,7 +1060,7 @@
// case when the page is reloaded while the password check is in progress and
// another safety check is started. Otherwise |observed_leak_check_|
// automatically calls RemoveAll() on destruction.
- observed_leak_check_.RemoveAll();
+ observed_leak_check_.Reset();
// Destroy the version updater to prevent getting a callback and firing a
// WebUI event, which would cause a crash.
version_updater_.reset();
diff --git a/chrome/browser/ui/webui/settings/safety_check_handler.h b/chrome/browser/ui/webui/settings/safety_check_handler.h
index 7018360..464fd01 100644
--- a/chrome/browser/ui/webui/settings/safety_check_handler.h
+++ b/chrome/browser/ui/webui/settings/safety_check_handler.h
@@ -13,7 +13,7 @@
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/time/time.h"
#include "base/types/strong_alias.h"
#include "build/branding_buildflags.h"
@@ -326,11 +326,13 @@
extensions::PasswordsPrivateDelegate* passwords_delegate_ = nullptr;
extensions::ExtensionPrefs* extension_prefs_ = nullptr;
extensions::ExtensionServiceInterface* extension_service_ = nullptr;
- ScopedObserver<password_manager::BulkLeakCheckServiceInterface,
- password_manager::BulkLeakCheckServiceInterface::Observer>
+ base::ScopedObservation<
+ password_manager::BulkLeakCheckServiceInterface,
+ password_manager::BulkLeakCheckServiceInterface::Observer>
observed_leak_check_{this};
- ScopedObserver<password_manager::InsecureCredentialsManager,
- password_manager::InsecureCredentialsManager::Observer>
+ base::ScopedObservation<
+ password_manager::InsecureCredentialsManager,
+ password_manager::InsecureCredentialsManager::Observer>
observed_insecure_credentials_manager_{this};
std::unique_ptr<TimestampDelegate> timestamp_delegate_;
base::WeakPtrFactory<SafetyCheckHandler> weak_ptr_factory_{this};
diff --git a/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc b/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc
index 01deb35..04bef37f 100644
--- a/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc
+++ b/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc
@@ -77,7 +77,6 @@
Profile* profile)
: profile_(profile),
sync_service_(ProfileSyncServiceFactory::GetForProfile(profile_)),
- sync_service_observer_(this),
show_history_deletion_dialog_(false) {}
ClearBrowsingDataHandler::~ClearBrowsingDataHandler() {
@@ -102,7 +101,7 @@
void ClearBrowsingDataHandler::OnJavascriptAllowed() {
if (sync_service_)
- sync_service_observer_.Add(sync_service_);
+ sync_service_observation_.Observe(sync_service_);
DCHECK(counters_.empty());
for (const std::string& pref : kCounterPrefsBasic) {
@@ -127,7 +126,7 @@
}
void ClearBrowsingDataHandler::OnJavascriptDisallowed() {
- sync_service_observer_.RemoveAll();
+ sync_service_observation_.Reset();
weak_ptr_factory_.InvalidateWeakPtrs();
counters_.clear();
period_.reset();
diff --git a/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h b/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h
index 5244d11..d0afce6 100644
--- a/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h
+++ b/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h
@@ -11,7 +11,7 @@
#include "base/containers/flat_set.h"
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/engagement/important_sites_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
@@ -115,8 +115,8 @@
// SyncService to observe sync state changes.
syncer::SyncService* sync_service_;
- ScopedObserver<syncer::SyncService, syncer::SyncServiceObserver>
- sync_service_observer_;
+ base::ScopedObservation<syncer::SyncService, syncer::SyncServiceObserver>
+ sync_service_observation_{this};
// Whether we should show a dialog informing the user about other forms of
// history stored in their account after the history deletion is finished.
diff --git a/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc b/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
index dbad124..1d35fbf 100644
--- a/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
+++ b/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
@@ -86,12 +86,12 @@
}
void ManageProfileHandler::OnJavascriptAllowed() {
- observer_.Add(
+ observation_.Observe(
&g_browser_process->profile_manager()->GetProfileAttributesStorage());
}
void ManageProfileHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
+ observation_.Reset();
}
void ManageProfileHandler::OnProfileHighResAvatarLoaded(
diff --git a/chrome/browser/ui/webui/settings/settings_manage_profile_handler.h b/chrome/browser/ui/webui/settings/settings_manage_profile_handler.h
index 3a597b1..b65bafa 100644
--- a/chrome/browser/ui/webui/settings/settings_manage_profile_handler.h
+++ b/chrome/browser/ui/webui/settings/settings_manage_profile_handler.h
@@ -9,7 +9,7 @@
#include <string>
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
@@ -91,8 +91,9 @@
Profile* profile_;
// Used to observe profile avatar updates.
- ScopedObserver<ProfileAttributesStorage, ProfileAttributesStorage::Observer>
- observer_{this};
+ base::ScopedObservation<ProfileAttributesStorage,
+ ProfileAttributesStorage::Observer>
+ observation_{this};
// For generating weak pointers to itself for callbacks.
base::WeakPtrFactory<ManageProfileHandler> weak_factory_{this};
diff --git a/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.cc b/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.cc
index 42d27c5..23e35a37 100644
--- a/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.cc
+++ b/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.cc
@@ -30,19 +30,18 @@
namespace settings {
MediaDevicesSelectionHandler::MediaDevicesSelectionHandler(Profile* profile)
- : profile_(profile), observer_(this) {
-}
+ : profile_(profile) {}
MediaDevicesSelectionHandler::~MediaDevicesSelectionHandler() {
}
void MediaDevicesSelectionHandler::OnJavascriptAllowed() {
// Register to the device observer list to get up-to-date device lists.
- observer_.Add(MediaCaptureDevicesDispatcher::GetInstance());
+ observation_.Observe(MediaCaptureDevicesDispatcher::GetInstance());
}
void MediaDevicesSelectionHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
+ observation_.Reset();
}
void MediaDevicesSelectionHandler::RegisterMessages() {
diff --git a/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.h b/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.h
index bbf93138..fa36422 100644
--- a/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.h
+++ b/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_MEDIA_DEVICES_SELECTION_HANDLER_H_
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "content/public/browser/web_contents.h"
@@ -55,8 +55,9 @@
Profile* profile_; // Weak pointer.
- ScopedObserver<MediaCaptureDevicesDispatcher,
- MediaCaptureDevicesDispatcher::Observer> observer_;
+ base::ScopedObservation<MediaCaptureDevicesDispatcher,
+ MediaCaptureDevicesDispatcher::Observer>
+ observation_{this};
DISALLOW_COPY_AND_ASSIGN(MediaDevicesSelectionHandler);
};
diff --git a/chrome/browser/ui/webui/settings/site_settings_handler.cc b/chrome/browser/ui/webui/settings/site_settings_handler.cc
index d1fdf8c..f692ca8 100644
--- a/chrome/browser/ui/webui/settings/site_settings_handler.cc
+++ b/chrome/browser/ui/webui/settings/site_settings_handler.cc
@@ -539,15 +539,15 @@
}
void SiteSettingsHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
- chooser_observer_.RemoveAll();
+ observations_.RemoveAllObservations();
+ chooser_observations_.RemoveAllObservations();
host_zoom_map_subscription_ = {};
pref_change_registrar_->Remove(prefs::kBlockAutoplayEnabled);
pref_change_registrar_->Remove(prefs::kCookieControlsMode);
#if BUILDFLAG(IS_CHROMEOS_ASH)
pref_change_registrar_->Remove(prefs::kEnableDRM);
#endif
- observed_profiles_.RemoveAll();
+ observed_profiles_.RemoveAllObservations();
}
void SiteSettingsHandler::OnGetUsageInfo() {
@@ -1436,58 +1436,58 @@
void SiteSettingsHandler::ObserveSourcesForProfile(Profile* profile) {
auto* map = HostContentSettingsMapFactory::GetForProfile(profile);
- if (!observer_.IsObserving(map))
- observer_.Add(map);
+ if (!observations_.IsObservingSource(map))
+ observations_.AddObservation(map);
auto* usb_context = UsbChooserContextFactory::GetForProfile(profile);
- if (!chooser_observer_.IsObserving(usb_context))
- chooser_observer_.Add(usb_context);
+ if (!chooser_observations_.IsObservingSource(usb_context))
+ chooser_observations_.AddObservation(usb_context);
auto* serial_context = SerialChooserContextFactory::GetForProfile(profile);
- if (!chooser_observer_.IsObserving(serial_context))
- chooser_observer_.Add(serial_context);
+ if (!chooser_observations_.IsObservingSource(serial_context))
+ chooser_observations_.AddObservation(serial_context);
auto* hid_context = HidChooserContextFactory::GetForProfile(profile);
- if (!chooser_observer_.IsObserving(hid_context))
- chooser_observer_.Add(hid_context);
+ if (!chooser_observations_.IsObservingSource(hid_context))
+ chooser_observations_.AddObservation(hid_context);
if (base::FeatureList::IsEnabled(
features::kWebBluetoothNewPermissionsBackend)) {
auto* bluetooth_context =
BluetoothChooserContextFactory::GetForProfile(profile);
- if (!chooser_observer_.IsObserving(bluetooth_context))
- chooser_observer_.Add(bluetooth_context);
+ if (!chooser_observations_.IsObservingSource(bluetooth_context))
+ chooser_observations_.AddObservation(bluetooth_context);
}
- observed_profiles_.Add(profile);
+ observed_profiles_.AddObservation(profile);
}
void SiteSettingsHandler::StopObservingSourcesForProfile(Profile* profile) {
auto* map = HostContentSettingsMapFactory::GetForProfile(profile);
- if (observer_.IsObserving(map))
- observer_.Remove(map);
+ if (observations_.IsObservingSource(map))
+ observations_.RemoveObservation(map);
auto* usb_context = UsbChooserContextFactory::GetForProfile(profile);
- if (chooser_observer_.IsObserving(usb_context))
- chooser_observer_.Remove(usb_context);
+ if (chooser_observations_.IsObservingSource(usb_context))
+ chooser_observations_.RemoveObservation(usb_context);
auto* serial_context = SerialChooserContextFactory::GetForProfile(profile);
- if (chooser_observer_.IsObserving(serial_context))
- chooser_observer_.Remove(serial_context);
+ if (chooser_observations_.IsObservingSource(serial_context))
+ chooser_observations_.RemoveObservation(serial_context);
auto* hid_context = HidChooserContextFactory::GetForProfile(profile);
- if (chooser_observer_.IsObserving(hid_context))
- chooser_observer_.Remove(hid_context);
+ if (chooser_observations_.IsObservingSource(hid_context))
+ chooser_observations_.RemoveObservation(hid_context);
if (base::FeatureList::IsEnabled(
features::kWebBluetoothNewPermissionsBackend)) {
auto* bluetooth_context =
BluetoothChooserContextFactory::GetForProfile(profile);
- if (chooser_observer_.IsObserving(bluetooth_context))
- chooser_observer_.Remove(bluetooth_context);
+ if (chooser_observations_.IsObservingSource(bluetooth_context))
+ chooser_observations_.RemoveObservation(bluetooth_context);
}
- observed_profiles_.Remove(profile);
+ observed_profiles_.RemoveObservation(profile);
}
void SiteSettingsHandler::TreeNodesAdded(ui::TreeModel* model,
diff --git a/chrome/browser/ui/webui/settings/site_settings_handler.h b/chrome/browser/ui/webui/settings/site_settings_handler.h
index ed126ec..70758bf 100644
--- a/chrome/browser/ui/webui/settings/site_settings_handler.h
+++ b/chrome/browser/ui/webui/settings/site_settings_handler.h
@@ -11,7 +11,7 @@
#include <string>
#include "base/containers/flat_set.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_multi_source_observation.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browsing_data/cookies_tree_model.h"
#include "chrome/browser/profiles/profile.h"
@@ -262,7 +262,8 @@
Profile* profile_;
web_app::AppRegistrar& app_registrar_;
- ScopedObserver<Profile, ProfileObserver> observed_profiles_{this};
+ base::ScopedMultiSourceObservation<Profile, ProfileObserver>
+ observed_profiles_{this};
// Keeps track of events related to zooming.
base::CallbackListSubscription host_zoom_map_subscription_;
@@ -274,13 +275,15 @@
std::string clearing_origin_;
// Change observer for content settings.
- ScopedObserver<HostContentSettingsMap, content_settings::Observer> observer_{
- this};
+ base::ScopedMultiSourceObservation<HostContentSettingsMap,
+ content_settings::Observer>
+ observations_{this};
// Change observer for chooser permissions.
- ScopedObserver<permissions::ChooserContextBase,
- permissions::ChooserContextBase::PermissionObserver>
- chooser_observer_{this};
+ base::ScopedMultiSourceObservation<
+ permissions::ChooserContextBase,
+ permissions::ChooserContextBase::PermissionObserver>
+ chooser_observations_{this};
// Change observer for prefs.
std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
diff --git a/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.cc b/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.cc
index 519c896..5db3fd4 100644
--- a/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.cc
+++ b/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.cc
@@ -94,7 +94,7 @@
callback) {
DCHECK(callback);
sync_confirmation_callback_ = std::move(callback);
- scoped_login_ui_service_observer_.Add(
+ scoped_login_ui_service_observation_.Observe(
LoginUIServiceFactory::GetForProfile(profile_));
browser_ = EnsureBrowser(browser_, profile_);
browser_->signin_view_controller()->ShowModalSyncConfirmationDialog();
diff --git a/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.h b/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.h
index e77f706..10d1088 100644
--- a/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.h
+++ b/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.h
@@ -7,7 +7,7 @@
#include "base/callback_forward.h"
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/ui/browser_list_observer.h"
#include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h"
#include "chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.h"
@@ -55,8 +55,8 @@
Profile* profile_;
base::OnceCallback<void(LoginUIService::SyncConfirmationUIClosedResult)>
sync_confirmation_callback_;
- ScopedObserver<LoginUIService, LoginUIService::Observer>
- scoped_login_ui_service_observer_{this};
+ base::ScopedObservation<LoginUIService, LoginUIService::Observer>
+ scoped_login_ui_service_observation_{this};
DISALLOW_COPY_AND_ASSIGN(DiceTurnSyncOnHelperDelegateImpl);
};
diff --git a/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.cc b/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.cc
index c09e8d0..18421be 100644
--- a/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.cc
+++ b/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.cc
@@ -63,11 +63,11 @@
void DiceWebSigninInterceptHandler::OnJavascriptAllowed() {
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()));
- identity_observer_.Add(identity_manager);
+ identity_observation_.Observe(identity_manager);
}
void DiceWebSigninInterceptHandler::OnJavascriptDisallowed() {
- identity_observer_.RemoveAll();
+ identity_observation_.Reset();
}
void DiceWebSigninInterceptHandler::OnExtendedAccountInfoUpdated(
diff --git a/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.h b/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.h
index 14faaa0e..5ad700a 100644
--- a/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.h
+++ b/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.h
@@ -10,7 +10,7 @@
#include <string>
#include "base/callback.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/values.h"
#include "chrome/browser/signin/dice_web_signin_interceptor.h"
#include "components/signin/public/identity_manager/account_info.h"
@@ -59,8 +59,9 @@
std::string GetBodyTitle();
std::string GetBodyText();
- ScopedObserver<signin::IdentityManager, signin::IdentityManager::Observer>
- identity_observer_{this};
+ base::ScopedObservation<signin::IdentityManager,
+ signin::IdentityManager::Observer>
+ identity_observation_{this};
DiceWebSigninInterceptor::Delegate::BubbleParameters bubble_parameters_;
base::OnceCallback<void(SigninInterceptionUserChoice)> callback_;
diff --git a/chrome/browser/ui/webui/signin/login_ui_test_utils.cc b/chrome/browser/ui/webui/signin/login_ui_test_utils.cc
index f8df63f8..c0099ea 100644
--- a/chrome/browser/ui/webui/signin/login_ui_test_utils.cc
+++ b/chrome/browser/ui/webui/signin/login_ui_test_utils.cc
@@ -7,7 +7,7 @@
#include "base/bind.h"
#include "base/notreached.h"
#include "base/run_loop.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -442,9 +442,10 @@
return false;
#else
SignInObserver signin_observer;
- ScopedObserver<signin::IdentityManager, signin::IdentityManager::Observer>
- scoped_signin_observer(&signin_observer);
- scoped_signin_observer.Add(
+ base::ScopedObservation<signin::IdentityManager,
+ signin::IdentityManager::Observer>
+ scoped_signin_observation(&signin_observer);
+ scoped_signin_observation.Observe(
IdentityManagerFactory::GetForProfile(browser->profile()));
signin_metrics::AccessPoint access_point =
@@ -467,9 +468,9 @@
base::TimeDelta timeout,
SyncConfirmationDialogAction action) {
SyncConfirmationClosedObserver confirmation_closed_observer;
- ScopedObserver<LoginUIService, LoginUIService::Observer>
- scoped_confirmation_closed_observer(&confirmation_closed_observer);
- scoped_confirmation_closed_observer.Add(
+ base::ScopedObservation<LoginUIService, LoginUIService::Observer>
+ scoped_confirmation_closed_observation(&confirmation_closed_observer);
+ scoped_confirmation_closed_observation.Observe(
LoginUIServiceFactory::GetForProfile(browser->profile()));
const base::Time expire_time = base::Time::Now() + timeout;
diff --git a/chrome/browser/ui/webui/signin/signin_reauth_handler.cc b/chrome/browser/ui/webui/signin/signin_reauth_handler.cc
index 3b127dc..0d4d887 100644
--- a/chrome/browser/ui/webui/signin/signin_reauth_handler.cc
+++ b/chrome/browser/ui/webui/signin/signin_reauth_handler.cc
@@ -19,7 +19,7 @@
: controller_(controller),
string_to_grd_id_map_(std::move(string_to_grd_id_map)) {
DCHECK(controller_);
- controller_observer_.Add(controller_);
+ controller_observation_.Observe(controller_);
}
SigninReauthHandler::~SigninReauthHandler() = default;
@@ -49,7 +49,7 @@
}
void SigninReauthHandler::OnReauthControllerDestroyed() {
- controller_observer_.RemoveAll();
+ controller_observation_.Reset();
controller_ = nullptr;
}
diff --git a/chrome/browser/ui/webui/signin/signin_reauth_handler.h b/chrome/browser/ui/webui/signin/signin_reauth_handler.h
index 0e4912de..8fafcf5c 100644
--- a/chrome/browser/ui/webui/signin/signin_reauth_handler.h
+++ b/chrome/browser/ui/webui/signin/signin_reauth_handler.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_REAUTH_HANDLER_H_
#include "base/containers/flat_map.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/ui/signin_reauth_view_controller.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -54,9 +55,9 @@
// May be null if |controller_| gets destroyed earlier than |this|.
SigninReauthViewController* controller_;
- ScopedObserver<SigninReauthViewController,
- SigninReauthViewController::Observer>
- controller_observer_{this};
+ base::ScopedObservation<SigninReauthViewController,
+ SigninReauthViewController::Observer>
+ controller_observation_{this};
// Mapping between strings displayed in the UI corresponding to this handler
// and their respective GRD IDs.
diff --git a/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc b/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc
index e3dd3bc..2c334c7 100644
--- a/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc
+++ b/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc
@@ -10,7 +10,7 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/metrics/user_action_tester.h"
#include "base/values.h"
@@ -75,8 +75,7 @@
: did_user_explicitly_interact_(false),
on_sync_confirmation_ui_closed_called_(false),
sync_confirmation_ui_closed_result_(LoginUIService::ABORT_SYNC),
- web_ui_(new content::TestWebUI),
- login_ui_service_observer_(this) {}
+ web_ui_(new content::TestWebUI) {}
void SetUp() override {
BrowserWithTestWindowTest::SetUp();
@@ -94,12 +93,12 @@
std::make_unique<IdentityTestEnvironmentProfileAdaptor>(profile());
account_info_ =
identity_test_env()->MakePrimaryAccountAvailable("[email protected]");
- login_ui_service_observer_.Add(
+ login_ui_service_observation_.Observe(
LoginUIServiceFactory::GetForProfile(profile()));
}
void TearDown() override {
- login_ui_service_observer_.RemoveAll();
+ login_ui_service_observation_.Reset();
sync_confirmation_ui_.reset();
web_ui_.reset();
identity_test_env_adaptor_.reset();
@@ -200,8 +199,8 @@
TestingSyncConfirmationHandler* handler_; // Not owned.
base::UserActionTester user_action_tester_;
std::unordered_map<std::string, int> string_to_grd_id_map_;
- ScopedObserver<LoginUIService, LoginUIService::Observer>
- login_ui_service_observer_;
+ base::ScopedObservation<LoginUIService, LoginUIService::Observer>
+ login_ui_service_observation_{this};
base::HistogramTester histogram_tester_;
std::unique_ptr<IdentityTestEnvironmentProfileAdaptor>
identity_test_env_adaptor_;
diff --git a/chrome/browser/ui/webui/supervised_user_internals_message_handler.cc b/chrome/browser/ui/webui/supervised_user_internals_message_handler.cc
index ce32cb2..3235dec 100644
--- a/chrome/browser/ui/webui/supervised_user_internals_message_handler.cc
+++ b/chrome/browser/ui/webui/supervised_user_internals_message_handler.cc
@@ -159,10 +159,10 @@
void SupervisedUserInternalsMessageHandler::HandleRegisterForEvents(
const base::ListValue* args) {
DCHECK(args->empty());
- if (scoped_observer_.IsObservingSources())
+ if (scoped_observation_.IsObserving())
return;
- scoped_observer_.Add(GetSupervisedUserService()->GetURLFilter());
+ scoped_observation_.Observe(GetSupervisedUserService()->GetURLFilter());
}
void SupervisedUserInternalsMessageHandler::HandleGetBasicInfo(
diff --git a/chrome/browser/ui/webui/supervised_user_internals_message_handler.h b/chrome/browser/ui/webui/supervised_user_internals_message_handler.h
index 68b2af8..40a96712 100644
--- a/chrome/browser/ui/webui/supervised_user_internals_message_handler.h
+++ b/chrome/browser/ui/webui/supervised_user_internals_message_handler.h
@@ -8,7 +8,7 @@
#include "base/callback_list.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/supervised_user/supervised_user_error_page/supervised_user_error_page.h"
#include "chrome/browser/supervised_user/supervised_user_service.h"
#include "chrome/browser/supervised_user/supervised_user_service_observer.h"
@@ -59,8 +59,9 @@
base::CallbackListSubscription user_settings_subscription_;
- ScopedObserver<SupervisedUserURLFilter, SupervisedUserURLFilter::Observer>
- scoped_observer_{this};
+ base::ScopedObservation<SupervisedUserURLFilter,
+ SupervisedUserURLFilter::Observer>
+ scoped_observation_{this};
base::WeakPtrFactory<SupervisedUserInternalsMessageHandler> weak_factory_{
this};
diff --git a/chrome/browser/ui/webui/tab_strip/thumbnail_tracker.cc b/chrome/browser/ui/webui/tab_strip/thumbnail_tracker.cc
index 9959e3f7..c33dfe94 100644
--- a/chrome/browser/ui/webui/tab_strip/thumbnail_tracker.cc
+++ b/chrome/browser/ui/webui/tab_strip/thumbnail_tracker.cc
@@ -8,7 +8,7 @@
#include <utility>
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/thumbnails/thumbnail_tab_helper.h"
#include "content/public/browser/web_contents_observer.h"
@@ -22,7 +22,7 @@
: content::WebContentsObserver(contents), parent_(parent) {
thumbnail_ = parent_->thumbnail_getter_.Run(contents);
if (thumbnail_)
- observer_.Add(thumbnail_.get());
+ observation_.Observe(thumbnail_.get());
}
void RequestThumbnail() {
@@ -35,7 +35,8 @@
// We must un-observe each ThumbnailImage when the WebContents it came from
// closes.
if (thumbnail_) {
- observer_.Remove(thumbnail_.get());
+ DCHECK(observation_.IsObservingSource(thumbnail_.get()));
+ observation_.Reset();
thumbnail_.reset();
}
@@ -52,7 +53,8 @@
private:
ThumbnailTracker* parent_;
scoped_refptr<ThumbnailImage> thumbnail_;
- ScopedObserver<ThumbnailImage, ThumbnailImage::Observer> observer_{this};
+ base::ScopedObservation<ThumbnailImage, ThumbnailImage::Observer>
+ observation_{this};
DISALLOW_COPY_AND_ASSIGN(ContentsData);
};
diff --git a/chrome/browser/ui/webui/theme_handler.cc b/chrome/browser/ui/webui/theme_handler.cc
index a1d7401a8..2198f534 100644
--- a/chrome/browser/ui/webui/theme_handler.cc
+++ b/chrome/browser/ui/webui/theme_handler.cc
@@ -40,12 +40,12 @@
content::Source<ThemeService>(
ThemeServiceFactory::GetForProfile(GetProfile())));
// Or native theme change.
- theme_observer_.Add(ui::NativeTheme::GetInstanceForNativeUi());
+ theme_observation_.Observe(ui::NativeTheme::GetInstanceForNativeUi());
}
void ThemeHandler::OnJavascriptDisallowed() {
registrar_.RemoveAll();
- theme_observer_.RemoveAll();
+ theme_observation_.Reset();
}
void ThemeHandler::Observe(int type,
diff --git a/chrome/browser/ui/webui/theme_handler.h b/chrome/browser/ui/webui/theme_handler.h
index 5de9784..f7c0c35 100644
--- a/chrome/browser/ui/webui/theme_handler.h
+++ b/chrome/browser/ui/webui/theme_handler.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_THEME_HANDLER_H_
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -54,8 +54,8 @@
content::NotificationRegistrar registrar_;
- ScopedObserver<ui::NativeTheme, ui::NativeThemeObserver> theme_observer_{
- this};
+ base::ScopedObservation<ui::NativeTheme, ui::NativeThemeObserver>
+ theme_observation_{this};
DISALLOW_COPY_AND_ASSIGN(ThemeHandler);
};