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

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: trailing space 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 ba4e32298f7ed75d0bbe9758ba37df4967f7653b..3399a296b8635cc912107c8eeadb3549a67db224 100644
--- a/chrome/browser/chromeos/policy/device_local_account_policy_service.cc
+++ b/chrome/browser/chromeos/policy/device_local_account_policy_service.cc
@@ -10,7 +10,6 @@
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_proxy.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/policy/device_local_account.h"
#include "chrome/browser/chromeos/policy/device_local_account_policy_store.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
@@ -23,7 +22,6 @@
#include "chrome/browser/policy/cloud/device_management_service.h"
#include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h"
#include "chromeos/dbus/session_manager_client.h"
-#include "content/public/browser/notification_details.h"
#include "policy/policy_constants.h"
namespace em = enterprise_management;
@@ -166,14 +164,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_);
}
@@ -224,24 +223,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);
@@ -259,6 +240,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