Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 5 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 content::NotificationService::AllSources()); | 144 content::NotificationService::AllSources()); |
| 145 registrar_.Add(this, | 145 registrar_.Add(this, |
| 146 chrome::NOTIFICATION_USER_LIST_CHANGED, | 146 chrome::NOTIFICATION_USER_LIST_CHANGED, |
| 147 content::NotificationService::AllSources()); | 147 content::NotificationService::AllSources()); |
| 148 registrar_.Add(this, | 148 registrar_.Add(this, |
| 149 chrome::NOTIFICATION_AUTH_SUPPLIED, | 149 chrome::NOTIFICATION_AUTH_SUPPLIED, |
| 150 content::NotificationService::AllSources()); | 150 content::NotificationService::AllSources()); |
| 151 registrar_.Add(this, | 151 registrar_.Add(this, |
| 152 chrome::NOTIFICATION_SESSION_STARTED, | 152 chrome::NOTIFICATION_SESSION_STARTED, |
| 153 content::NotificationService::AllSources()); | 153 content::NotificationService::AllSources()); |
| 154 cros_settings_->AddSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, this); | 154 show_user_names_subscription_ = cros_settings_->AddSettingsObserver( |
| 155 cros_settings_->AddSettingsObserver(kAccountsPrefAllowNewUser, this); | 155 kAccountsPrefShowUserNamesOnSignIn, |
| 156 cros_settings_->AddSettingsObserver(kAccountsPrefAllowGuest, this); | 156 base::Bind(&ExistingUserController::SettingsChanged, |
| 157 cros_settings_->AddSettingsObserver(kAccountsPrefUsers, this); | 157 base::Unretained(this))); |
| 158 cros_settings_->AddSettingsObserver( | 158 allow_new_user_subscription_ = cros_settings_->AddSettingsObserver( |
| 159 kAccountsPrefDeviceLocalAccountAutoLoginId, | 159 kAccountsPrefAllowNewUser, |
| 160 this); | 160 base::Bind(&ExistingUserController::SettingsChanged, |
| 161 cros_settings_->AddSettingsObserver( | 161 base::Unretained(this))); |
| 162 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | 162 allow_guest_subscription_ = cros_settings_->AddSettingsObserver( |
| 163 this); | 163 kAccountsPrefAllowGuest, |
| 164 base::Bind(&ExistingUserController::SettingsChanged, | |
| 165 base::Unretained(this))); | |
| 166 users_subscription_ = cros_settings_->AddSettingsObserver( | |
| 167 kAccountsPrefUsers, | |
| 168 base::Bind(&ExistingUserController::SettingsChanged, | |
| 169 base::Unretained(this))); | |
| 170 local_account_auto_login_id_subscription_ = | |
| 171 cros_settings_->AddSettingsObserver( | |
| 172 kAccountsPrefDeviceLocalAccountAutoLoginId, | |
| 173 base::Bind(&ExistingUserController::SettingsChanged, | |
| 174 base::Unretained(this))); | |
| 175 local_account_auto_login_delay_subscription_ = | |
| 176 cros_settings_->AddSettingsObserver( | |
| 177 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
| 178 base::Bind(&ExistingUserController::SettingsChanged, | |
| 179 base::Unretained(this))); | |
| 164 } | 180 } |
| 165 | 181 |
| 166 void ExistingUserController::Init(const UserList& users) { | 182 void ExistingUserController::Init(const UserList& users) { |
| 167 time_init_ = base::Time::Now(); | 183 time_init_ = base::Time::Now(); |
| 168 UpdateLoginDisplay(users); | 184 UpdateLoginDisplay(users); |
| 169 ConfigurePublicSessionAutoLogin(); | 185 ConfigurePublicSessionAutoLogin(); |
| 170 | 186 |
| 171 DBusThreadManager::Get()->GetSessionManagerClient()->EmitLoginPromptReady(); | 187 DBusThreadManager::Get()->GetSessionManagerClient()->EmitLoginPromptReady(); |
| 172 } | 188 } |
| 173 | 189 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 const content::NotificationSource& source, | 241 const content::NotificationSource& source, |
| 226 const content::NotificationDetails& details) { | 242 const content::NotificationDetails& details) { |
| 227 if (type == chrome::NOTIFICATION_SESSION_STARTED) { | 243 if (type == chrome::NOTIFICATION_SESSION_STARTED) { |
| 228 // Stop listening to any notification once session has started. | 244 // Stop listening to any notification once session has started. |
| 229 // Sign in screen objects are marked for deletion with DeleteSoon so | 245 // Sign in screen objects are marked for deletion with DeleteSoon so |
| 230 // make sure no object would be used after session has started. | 246 // make sure no object would be used after session has started. |
| 231 // http://crbug.com/125276 | 247 // http://crbug.com/125276 |
| 232 registrar_.RemoveAll(); | 248 registrar_.RemoveAll(); |
| 233 return; | 249 return; |
| 234 } | 250 } |
| 235 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) { | 251 if (type == chrome::NOTIFICATION_USER_LIST_CHANGED) { |
| 236 const std::string setting = *content::Details<const std::string>( | 252 SettingsChanged(); |
| 237 details).ptr(); | 253 return; |
| 238 if (setting == kAccountsPrefDeviceLocalAccountAutoLoginId || | |
| 239 setting == kAccountsPrefDeviceLocalAccountAutoLoginDelay) { | |
| 240 ConfigurePublicSessionAutoLogin(); | |
| 241 } | |
| 242 } | |
| 243 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED || | |
| 244 type == chrome::NOTIFICATION_USER_LIST_CHANGED) { | |
| 245 if (host_ != NULL) { | |
| 246 // Signed settings or user list changed. Notify views and update them. | |
| 247 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers()); | |
| 248 ConfigurePublicSessionAutoLogin(); | |
| 249 return; | |
| 250 } | |
| 251 } | 254 } |
| 252 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) { | 255 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) { |
| 253 // Possibly the user has authenticated against a proxy server and we might | 256 // Possibly the user has authenticated against a proxy server and we might |
| 254 // need the credentials for enrollment and other system requests from the | 257 // need the credentials for enrollment and other system requests from the |
| 255 // main |g_browser_process| request context (see bug | 258 // main |g_browser_process| request context (see bug |
| 256 // http://crosbug.com/24861). So we transfer any credentials to the global | 259 // http://crosbug.com/24861). So we transfer any credentials to the global |
| 257 // request context here. | 260 // request context here. |
| 258 // The issue we have here is that the NOTIFICATION_AUTH_SUPPLIED is sent | 261 // The issue we have here is that the NOTIFICATION_AUTH_SUPPLIED is sent |
| 259 // just after the UI is closed but before the new credentials were stored | 262 // just after the UI is closed but before the new credentials were stored |
| 260 // in the profile. Therefore we have to give it some time to make sure it | 263 // in the profile. Therefore we have to give it some time to make sure it |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 278 return; | 281 return; |
| 279 login_display_->OnUserImageChanged(*content::Details<User>(details).ptr()); | 282 login_display_->OnUserImageChanged(*content::Details<User>(details).ptr()); |
| 280 } | 283 } |
| 281 | 284 |
| 282 //////////////////////////////////////////////////////////////////////////////// | 285 //////////////////////////////////////////////////////////////////////////////// |
| 283 // ExistingUserController, private: | 286 // ExistingUserController, private: |
| 284 | 287 |
| 285 ExistingUserController::~ExistingUserController() { | 288 ExistingUserController::~ExistingUserController() { |
| 286 LoginUtils::Get()->DelegateDeleted(this); | 289 LoginUtils::Get()->DelegateDeleted(this); |
| 287 | 290 |
| 288 cros_settings_->RemoveSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, | |
| 289 this); | |
| 290 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this); | |
| 291 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowGuest, this); | |
| 292 cros_settings_->RemoveSettingsObserver(kAccountsPrefUsers, this); | |
| 293 cros_settings_->RemoveSettingsObserver( | |
| 294 kAccountsPrefDeviceLocalAccountAutoLoginId, | |
| 295 this); | |
| 296 cros_settings_->RemoveSettingsObserver( | |
| 297 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
| 298 this); | |
| 299 | |
| 300 if (current_controller_ == this) { | 291 if (current_controller_ == this) { |
| 301 current_controller_ = NULL; | 292 current_controller_ = NULL; |
| 302 } else { | 293 } else { |
| 303 NOTREACHED() << "More than one controller are alive."; | 294 NOTREACHED() << "More than one controller are alive."; |
| 304 } | 295 } |
| 305 DCHECK(login_display_.get()); | 296 DCHECK(login_display_.get()); |
| 306 } | 297 } |
| 307 | 298 |
| 308 //////////////////////////////////////////////////////////////////////////////// | 299 //////////////////////////////////////////////////////////////////////////////// |
| 309 // ExistingUserController, LoginDisplay::Delegate implementation: | 300 // ExistingUserController, LoginDisplay::Delegate implementation: |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 933 online_succeeded_for_ = username; | 924 online_succeeded_for_ = username; |
| 934 // Wait for login attempt to end, if it hasn't yet. | 925 // Wait for login attempt to end, if it hasn't yet. |
| 935 if (offline_failed_ && !is_login_in_progress_) | 926 if (offline_failed_ && !is_login_in_progress_) |
| 936 ShowGaiaPasswordChanged(username); | 927 ShowGaiaPasswordChanged(username); |
| 937 } | 928 } |
| 938 } | 929 } |
| 939 | 930 |
| 940 //////////////////////////////////////////////////////////////////////////////// | 931 //////////////////////////////////////////////////////////////////////////////// |
| 941 // ExistingUserController, private: | 932 // ExistingUserController, private: |
| 942 | 933 |
| 934 void ExistingUserController::SettingsChanged() { | |
|
Lei Zhang
2013/09/18 05:00:53
Not sure if this is this equivalent to the old cod
Mattias Nissler (ping if slow)
2013/09/18 09:09:48
The old code doesn't make much sense either ;)
I
Avi (use Gerrit)
2013/09/18 16:41:44
Tell me about it.
| |
| 935 if (host_ != NULL) { | |
| 936 // Signed settings or user list changed. Notify views and update them. | |
| 937 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers()); | |
| 938 ConfigurePublicSessionAutoLogin(); | |
| 939 return; | |
| 940 } | |
| 941 } | |
| 942 | |
| 943 void ExistingUserController::ActivateWizard(const std::string& screen_name) { | 943 void ExistingUserController::ActivateWizard(const std::string& screen_name) { |
| 944 scoped_ptr<DictionaryValue> params; | 944 scoped_ptr<DictionaryValue> params; |
| 945 host_->StartWizard(screen_name, params.Pass()); | 945 host_->StartWizard(screen_name, params.Pass()); |
| 946 } | 946 } |
| 947 | 947 |
| 948 void ExistingUserController::ConfigurePublicSessionAutoLogin() { | 948 void ExistingUserController::ConfigurePublicSessionAutoLogin() { |
| 949 std::string auto_login_account_id; | 949 std::string auto_login_account_id; |
| 950 cros_settings_->GetString(kAccountsPrefDeviceLocalAccountAutoLoginId, | 950 cros_settings_->GetString(kAccountsPrefDeviceLocalAccountAutoLoginId, |
| 951 &auto_login_account_id); | 951 &auto_login_account_id); |
| 952 const std::vector<policy::DeviceLocalAccount> device_local_accounts = | 952 const std::vector<policy::DeviceLocalAccount> device_local_accounts = |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1111 // changed. | 1111 // changed. |
| 1112 UserManager::Get()->SaveUserOAuthStatus( | 1112 UserManager::Get()->SaveUserOAuthStatus( |
| 1113 username, | 1113 username, |
| 1114 User::OAUTH2_TOKEN_STATUS_INVALID); | 1114 User::OAUTH2_TOKEN_STATUS_INVALID); |
| 1115 | 1115 |
| 1116 login_display_->SetUIEnabled(true); | 1116 login_display_->SetUIEnabled(true); |
| 1117 login_display_->ShowGaiaPasswordChanged(username); | 1117 login_display_->ShowGaiaPasswordChanged(username); |
| 1118 } | 1118 } |
| 1119 | 1119 |
| 1120 } // namespace chromeos | 1120 } // namespace chromeos |
| OLD | NEW |