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

Unified Diff: chrome/browser/chromeos/login/existing_user_controller.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/login/existing_user_controller.cc
diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc
index 5530fb773176d96e0ef61c62010ab4c7d202f2eb..64888985b408689f5a94e035d742eb1ab5b439fc 100644
--- a/chrome/browser/chromeos/login/existing_user_controller.cc
+++ b/chrome/browser/chromeos/login/existing_user_controller.cc
@@ -151,16 +151,32 @@ ExistingUserController::ExistingUserController(LoginDisplayHost* host)
registrar_.Add(this,
chrome::NOTIFICATION_SESSION_STARTED,
content::NotificationService::AllSources());
- cros_settings_->AddSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, this);
- cros_settings_->AddSettingsObserver(kAccountsPrefAllowNewUser, this);
- cros_settings_->AddSettingsObserver(kAccountsPrefAllowGuest, this);
- cros_settings_->AddSettingsObserver(kAccountsPrefUsers, this);
- cros_settings_->AddSettingsObserver(
- kAccountsPrefDeviceLocalAccountAutoLoginId,
- this);
- cros_settings_->AddSettingsObserver(
- kAccountsPrefDeviceLocalAccountAutoLoginDelay,
- this);
+ show_user_names_subscription_ = cros_settings_->AddSettingsObserver(
+ kAccountsPrefShowUserNamesOnSignIn,
+ base::Bind(&ExistingUserController::DeviceSettingsChanged,
+ base::Unretained(this)));
+ allow_new_user_subscription_ = cros_settings_->AddSettingsObserver(
+ kAccountsPrefAllowNewUser,
+ base::Bind(&ExistingUserController::DeviceSettingsChanged,
+ base::Unretained(this)));
+ allow_guest_subscription_ = cros_settings_->AddSettingsObserver(
+ kAccountsPrefAllowGuest,
+ base::Bind(&ExistingUserController::DeviceSettingsChanged,
+ base::Unretained(this)));
+ users_subscription_ = cros_settings_->AddSettingsObserver(
+ kAccountsPrefUsers,
+ base::Bind(&ExistingUserController::DeviceSettingsChanged,
+ base::Unretained(this)));
+ local_account_auto_login_id_subscription_ =
+ cros_settings_->AddSettingsObserver(
+ kAccountsPrefDeviceLocalAccountAutoLoginId,
+ base::Bind(&ExistingUserController::ConfigurePublicSessionAutoLogin,
+ base::Unretained(this)));
+ local_account_auto_login_delay_subscription_ =
+ cros_settings_->AddSettingsObserver(
+ kAccountsPrefDeviceLocalAccountAutoLoginDelay,
+ base::Bind(&ExistingUserController::ConfigurePublicSessionAutoLogin,
+ base::Unretained(this)));
}
void ExistingUserController::Init(const UserList& users) {
@@ -232,22 +248,9 @@ void ExistingUserController::Observe(
registrar_.RemoveAll();
return;
}
- if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) {
- const std::string setting = *content::Details<const std::string>(
- details).ptr();
- if (setting == kAccountsPrefDeviceLocalAccountAutoLoginId ||
- setting == kAccountsPrefDeviceLocalAccountAutoLoginDelay) {
- ConfigurePublicSessionAutoLogin();
- }
- }
- if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED ||
- type == chrome::NOTIFICATION_USER_LIST_CHANGED) {
- if (host_ != NULL) {
- // Signed settings or user list changed. Notify views and update them.
- UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers());
- ConfigurePublicSessionAutoLogin();
- return;
- }
+ if (type == chrome::NOTIFICATION_USER_LIST_CHANGED) {
+ DeviceSettingsChanged();
+ return;
}
if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) {
// Possibly the user has authenticated against a proxy server and we might
@@ -285,18 +288,6 @@ void ExistingUserController::Observe(
ExistingUserController::~ExistingUserController() {
LoginUtils::Get()->DelegateDeleted(this);
- cros_settings_->RemoveSettingsObserver(kAccountsPrefShowUserNamesOnSignIn,
- this);
- cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this);
- cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowGuest, this);
- cros_settings_->RemoveSettingsObserver(kAccountsPrefUsers, this);
- cros_settings_->RemoveSettingsObserver(
- kAccountsPrefDeviceLocalAccountAutoLoginId,
- this);
- cros_settings_->RemoveSettingsObserver(
- kAccountsPrefDeviceLocalAccountAutoLoginDelay,
- this);
-
if (current_controller_ == this) {
current_controller_ = NULL;
} else {
@@ -940,6 +931,15 @@ void ExistingUserController::OnOnlineChecked(const std::string& username,
////////////////////////////////////////////////////////////////////////////////
// ExistingUserController, private:
+void ExistingUserController::DeviceSettingsChanged() {
+ if (host_ != NULL) {
+ // Signed settings or user list changed. Notify views and update them.
+ UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers());
+ ConfigurePublicSessionAutoLogin();
+ return;
+ }
+}
+
void ExistingUserController::ActivateWizard(const std::string& screen_name) {
scoped_ptr<DictionaryValue> params;
host_->StartWizard(screen_name, params.Pass());

Powered by Google App Engine
This is Rietveld 408576698