Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2270)

Unified Diff: chrome/browser/chromeos/policy/device_local_account_policy_service.cc

Issue 23494053: Remove NOTIFICATION_SYSTEM_SETTING_CHANGED, switch CrosSettings to base::CallbackRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/policy/device_local_account_policy_service.cc
diff --git a/chrome/browser/chromeos/policy/device_local_account_policy_service.cc b/chrome/browser/chromeos/policy/device_local_account_policy_service.cc
index 82f5294620dc0b5d7035c72b4de799eb9868d431..0d0724009edbdf7d0b22d8b269f70ac1510a6ea5 100644
--- a/chrome/browser/chromeos/policy/device_local_account_policy_service.cc
+++ b/chrome/browser/chromeos/policy/device_local_account_policy_service.cc
@@ -161,14 +161,15 @@ DeviceLocalAccountPolicyService::DeviceLocalAccountPolicyService(
cros_settings_(cros_settings),
device_management_service_(NULL),
cros_settings_callback_factory_(this) {
- cros_settings_->AddSettingsObserver(
- chromeos::kAccountsPrefDeviceLocalAccounts, this);
+ local_accounts_subscription_ = cros_settings_->AddSettingsObserver(
+ chromeos::kAccountsPrefDeviceLocalAccounts,
+ base::Bind(&DeviceLocalAccountPolicyService::
+ UpdateAccountListIfNonePending,
+ base::Unretained(this)));
UpdateAccountList();
}
DeviceLocalAccountPolicyService::~DeviceLocalAccountPolicyService() {
- cros_settings_->RemoveSettingsObserver(
- chromeos::kAccountsPrefDeviceLocalAccounts, this);
DeleteBrokers(&policy_brokers_);
}
@@ -219,24 +220,6 @@ void DeviceLocalAccountPolicyService::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
-void DeviceLocalAccountPolicyService::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- if (type != chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED ||
- *content::Details<const std::string>(details).ptr() !=
- chromeos::kAccountsPrefDeviceLocalAccounts) {
- NOTREACHED();
- return;
- }
-
- // Avoid unnecessary calls to UpdateAccountList(): If an earlier call is still
- // pending (because the |cros_settings_| are not trusted yet), the updated
- // account list will be processed by that call when it eventually runs.
- if (!cros_settings_callback_factory_.HasWeakPtrs())
- UpdateAccountList();
-}
-
void DeviceLocalAccountPolicyService::OnStoreLoaded(CloudPolicyStore* store) {
DeviceLocalAccountPolicyBroker* broker = GetBrokerForStore(store);
DCHECK(broker);
@@ -254,6 +237,14 @@ void DeviceLocalAccountPolicyService::OnStoreError(CloudPolicyStore* store) {
FOR_EACH_OBSERVER(Observer, observers_, OnPolicyUpdated(broker->user_id()));
}
+void DeviceLocalAccountPolicyService::UpdateAccountListIfNonePending() {
+ // Avoid unnecessary calls to UpdateAccountList(): If an earlier call is still
+ // pending (because the |cros_settings_| are not trusted yet), the updated
+ // account list will be processed by that call when it eventually runs.
+ if (!cros_settings_callback_factory_.HasWeakPtrs())
+ UpdateAccountList();
+}
+
void DeviceLocalAccountPolicyService::UpdateAccountList() {
if (chromeos::CrosSettingsProvider::TRUSTED !=
cros_settings_->PrepareTrustedValues(

Powered by Google App Engine
This is Rietveld 408576698