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

Unified Diff: chrome/browser/chromeos/login/existing_user_controller.cc

Issue 12218078: Implement a policy to autologin a public account. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: last upload failed Created 7 years, 10 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 0cf370e5eaffb717f5cfdc32ff4e795bfeae8f30..648d568fa2dcd472c2e331b9732091ca4ecdbf3c 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(
+ kAccountsPrefDeviceLocalAccountAutoLoginId,
+ this);
+ cros_settings_->AddSettingsObserver(
+ kAccountsPrefDeviceLocalAccountAutoLoginDelay,
+ 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 == kAccountsPrefDeviceLocalAccountAutoLoginId ||
+ setting == kAccountsPrefDeviceLocalAccountAutoLoginDelay)
+ StartAutoLoginTimer();
Nikita (slow) 2013/02/11 09:56:58 nit: add {}
dconnelly 2013/02/11 16:17:56 Done.
+ }
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(
+ kAccountsPrefDeviceLocalAccountAutoLoginId,
+ this);
+ cros_settings_->RemoveSettingsObserver(
+ kAccountsPrefDeviceLocalAccountAutoLoginDelay,
+ 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.
bartfab (slow) 2013/02/11 09:46:01 Nit: You used the term "autologin" in this file an
dconnelly 2013/02/11 16:17:56 Done.
+ StopAutoLoginTimer();
Nikita (slow) 2013/02/11 09:56:58 I think that we want to stop this timer as soon as
dconnelly 2013/02/11 16:17:56 Done.
+
// 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();
bartfab (slow) 2013/02/11 09:46:01 Just an idea: Instead of having to stop the timer
+
// 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();
Nikita (slow) 2013/02/11 09:56:58 Why not place this call to the beginning of this m
dconnelly 2013/02/11 16:17:56 Done.
+
// 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();
Nikita (slow) 2013/02/11 09:56:58 Why not place this call to the beginning of this m
dconnelly 2013/02/11 16:17:56 Done.
+
// 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();
Nikita (slow) 2013/02/11 09:56:58 Are you sure this is what you want? This callback
dconnelly 2013/02/11 16:17:56 Yes, this is the intended behavior.
Nikita (slow) 2013/02/11 17:30:29 I think that has some potential issues when one us
}
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.
bartfab (slow) 2013/02/11 09:46:01 Nit: spaces around the dash. Also, -- for an em da
dconnelly 2013/02/11 16:17:56 My bad, ---. You don't need the spaces, though, a
+ StartAutoLoginTimer();
Nikita (slow) 2013/02/11 09:56:58 I thought that this error is kind of unrecoverable
dconnelly 2013/02/11 16:17:56 I ran into a problem during debugging where I scre
}
void ExistingUserController::OnOnlineChecked(const std::string& username,
@@ -881,6 +922,33 @@ 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(
+ kAccountsPrefDeviceLocalAccountAutoLoginId,
+ &username) && !username.empty()) {
+ int timer;
+ if (!cros_settings_->GetInteger(
+ kAccountsPrefDeviceLocalAccountAutoLoginDelay,
+ &timer)) {
+ timer = 0;
+ }
+ auto_login_timer_.Start(FROM_HERE,
+ base::TimeDelta::FromMilliseconds(timer),
+ base::Bind(
+ &ExistingUserController::LoginAsPublicAccount,
+ weak_factory_.GetWeakPtr(),
+ username));
bartfab (slow) 2013/02/11 09:46:01 Nit: Rather than indenting deeper and deeper, I th
dconnelly 2013/02/11 16:17:56 Done.
+ }
+}
+
gfx::NativeWindow ExistingUserController::GetNativeWindow() const {
return host_->GetNativeWindow();
}

Powered by Google App Engine
This is Rietveld 408576698