Chromium Code Reviews| 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 0cf370e5eaffb717f5cfdc32ff4e795bfeae8f30..8e6cd6a4593fae32ac00b4d74251c642f1acba4d 100644 |
| --- a/chrome/browser/chromeos/login/existing_user_controller.cc |
| +++ b/chrome/browser/chromeos/login/existing_user_controller.cc |
| @@ -144,7 +144,8 @@ ExistingUserController::ExistingUserController(LoginDisplayHost* host) |
| offline_failed_(false), |
| is_login_in_progress_(false), |
| password_changed_(false), |
| - do_auto_enrollment_(false) { |
| + do_auto_enrollment_(false), |
| + signin_screen_ready_(false) { |
| DCHECK(current_controller_ == NULL); |
| current_controller_ = this; |
| @@ -164,6 +165,12 @@ ExistingUserController::ExistingUserController(LoginDisplayHost* host) |
| cros_settings_->AddSettingsObserver(kAccountsPrefAllowNewUser, this); |
| cros_settings_->AddSettingsObserver(kAccountsPrefAllowGuest, this); |
| cros_settings_->AddSettingsObserver(kAccountsPrefUsers, this); |
| + cros_settings_->AddSettingsObserver( |
| + kAccountsPrefDeviceLocalAccountAutoLoginUsername, |
| + this); |
| + cros_settings_->AddSettingsObserver( |
| + kAccountsPrefDeviceLocalAccountAutoLoginTimerMillis, |
|
bartfab (slow)
2013/02/08 18:38:42
We tend to abbreviate milliseconds as "Ms, not "Mi
dconnelly
2013/02/08 19:20:42
Done.
|
| + this); |
| } |
| void ExistingUserController::Init(const UserList& users) { |
| @@ -229,6 +236,12 @@ void ExistingUserController::Observe( |
| registrar_.RemoveAll(); |
| return; |
| } |
| + if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) { |
| + std::string setting = *content::Details<const std::string>(details).ptr(); |
| + if (setting == kAccountsPrefDeviceLocalAccountAutoLoginUsername || |
| + setting == kAccountsPrefDeviceLocalAccountAutoLoginTimerMillis) |
| + StartAutoLoginTimer(); |
| + } |
| if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED || |
| type == chrome::NOTIFICATION_POLICY_USER_LIST_CHANGED) { |
| if (host_ != NULL) { |
| @@ -278,6 +291,12 @@ ExistingUserController::~ExistingUserController() { |
| cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this); |
| cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowGuest, this); |
| cros_settings_->RemoveSettingsObserver(kAccountsPrefUsers, this); |
| + cros_settings_->RemoveSettingsObserver( |
| + kAccountsPrefDeviceLocalAccountAutoLoginUsername, |
| + this); |
| + cros_settings_->RemoveSettingsObserver( |
| + kAccountsPrefDeviceLocalAccountAutoLoginTimerMillis, |
| + this); |
| if (current_controller_ == this) { |
| current_controller_ = NULL; |
| @@ -412,6 +431,9 @@ void ExistingUserController::PerformLogin( |
| login_display_->SetUIEnabled(false); |
| resume_login_callback_.Reset(); |
| + // Stop the autologin timer when attempting login. |
| + StopAutoLoginTimer(); |
| + |
| // Use the same LoginPerformer for subsequent login as it has state |
| // such as Authenticator instance. |
| if (!login_performer_.get() || num_login_attempts_ <= 1) { |
| @@ -440,6 +462,9 @@ void ExistingUserController::LoginAsRetailModeUser() { |
| // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once |
| // the enterprise policy wiring is done for retail mode. |
| + // Stop the autologin timer when attempting login. |
| + StopAutoLoginTimer(); |
| + |
| // Only one instance of LoginPerformer should exist at a time. |
| login_performer_.reset(NULL); |
| login_performer_.reset(new LoginPerformer(this)); |
| @@ -485,6 +510,9 @@ void ExistingUserController::LoginAsGuest() { |
| return; |
| } |
| + // Stop the autologin timer when attempting login. |
| + StopAutoLoginTimer(); |
| + |
| // Only one instance of LoginPerformer should exist at a time. |
| login_performer_.reset(NULL); |
| login_performer_.reset(new LoginPerformer(this)); |
| @@ -532,6 +560,9 @@ void ExistingUserController::LoginAsPublicAccount( |
| return; |
| } |
| + // Stop the autologin timer when attempting login. |
| + StopAutoLoginTimer(); |
| + |
| // Only one instance of LoginPerformer should exist at a time. |
| login_performer_.reset(NULL); |
| login_performer_.reset(new LoginPerformer(this)); |
| @@ -541,6 +572,11 @@ void ExistingUserController::LoginAsPublicAccount( |
| l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); |
| } |
| +void ExistingUserController::OnSigninScreenReady() { |
| + signin_screen_ready_ = true; |
| + StartAutoLoginTimer(); |
| +} |
| + |
| void ExistingUserController::OnUserSelected(const std::string& username) { |
| login_performer_.reset(NULL); |
| num_login_attempts_ = 0; |
| @@ -681,6 +717,8 @@ void ExistingUserController::OnLoginFailure(const LoginFailure& failure) { |
| // Clear the recorded displayed email so it won't affect any future attempts. |
| display_email_.clear(); |
| + |
| + StartAutoLoginTimer(); |
| } |
| void ExistingUserController::OnLoginSuccess( |
| @@ -840,6 +878,9 @@ void ExistingUserController::PolicyLoadFailed() { |
| login_display_->SetUIEnabled(true); |
| display_email_.clear(); |
| + |
| + // Policy load failure stops login attempts--restart the timer. |
| + StartAutoLoginTimer(); |
| } |
| void ExistingUserController::OnOnlineChecked(const std::string& username, |
| @@ -881,6 +922,32 @@ void ExistingUserController::ActivateWizard(const std::string& screen_name) { |
| host_->StartWizard(screen_name, params); |
| } |
| +void ExistingUserController::StopAutoLoginTimer() { |
| + auto_login_timer_.Stop(); |
| +} |
| + |
| +void ExistingUserController::StartAutoLoginTimer() { |
| + if (!signin_screen_ready_) |
| + return; |
| + |
| + std::string username; |
| + if (cros_settings_->GetString( |
| + kAccountsPrefDeviceLocalAccountAutoLoginUsername, |
| + &username) && !username.empty()) { |
| + int timer; |
| + if (!cros_settings_->GetInteger( |
| + kAccountsPrefDeviceLocalAccountAutoLoginTimerMillis, |
| + &timer)) |
| + timer = 0; |
|
bartfab (slow)
2013/02/08 18:38:42
multi-line if => style guide requires curly braces
dconnelly
2013/02/08 19:20:42
Done.
|
| + auto_login_timer_.Start(FROM_HERE, |
| + base::TimeDelta::FromMilliseconds(timer), |
| + base::Bind( |
| + &ExistingUserController::LoginAsPublicAccount, |
| + weak_factory_.GetWeakPtr(), |
| + username)); |
| + } |
| +} |
| + |
| gfx::NativeWindow ExistingUserController::GetNativeWindow() const { |
| return host_->GetNativeWindow(); |
| } |