| 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(
|
|
|