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

Side by Side 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: reset timer on user activity, review comments 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ash/wm/user_activity_detector.h"
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
11 #include "base/callback.h" 12 #include "base/callback.h"
12 #include "base/command_line.h" 13 #include "base/command_line.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/message_loop.h" 15 #include "base/message_loop.h"
15 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
16 #include "base/string_util.h" 17 #include "base/string_util.h"
17 #include "base/stringprintf.h" 18 #include "base/stringprintf.h"
18 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 ExistingUserController::ExistingUserController(LoginDisplayHost* host) 138 ExistingUserController::ExistingUserController(LoginDisplayHost* host)
138 : login_status_consumer_(NULL), 139 : login_status_consumer_(NULL),
139 host_(host), 140 host_(host),
140 login_display_(host_->CreateLoginDisplay(this)), 141 login_display_(host_->CreateLoginDisplay(this)),
141 num_login_attempts_(0), 142 num_login_attempts_(0),
142 cros_settings_(CrosSettings::Get()), 143 cros_settings_(CrosSettings::Get()),
143 weak_factory_(this), 144 weak_factory_(this),
144 offline_failed_(false), 145 offline_failed_(false),
145 is_login_in_progress_(false), 146 is_login_in_progress_(false),
146 password_changed_(false), 147 password_changed_(false),
147 do_auto_enrollment_(false) { 148 do_auto_enrollment_(false),
149 signin_screen_ready_(false) {
148 DCHECK(current_controller_ == NULL); 150 DCHECK(current_controller_ == NULL);
149 current_controller_ = this; 151 current_controller_ = this;
150 152
151 registrar_.Add(this, 153 registrar_.Add(this,
152 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 154 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
153 content::NotificationService::AllSources()); 155 content::NotificationService::AllSources());
154 registrar_.Add(this, 156 registrar_.Add(this,
155 chrome::NOTIFICATION_POLICY_USER_LIST_CHANGED, 157 chrome::NOTIFICATION_POLICY_USER_LIST_CHANGED,
156 content::NotificationService::AllSources()); 158 content::NotificationService::AllSources());
157 registrar_.Add(this, 159 registrar_.Add(this,
158 chrome::NOTIFICATION_AUTH_SUPPLIED, 160 chrome::NOTIFICATION_AUTH_SUPPLIED,
159 content::NotificationService::AllSources()); 161 content::NotificationService::AllSources());
160 registrar_.Add(this, 162 registrar_.Add(this,
161 chrome::NOTIFICATION_SESSION_STARTED, 163 chrome::NOTIFICATION_SESSION_STARTED,
162 content::NotificationService::AllSources()); 164 content::NotificationService::AllSources());
163 cros_settings_->AddSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, this); 165 cros_settings_->AddSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, this);
164 cros_settings_->AddSettingsObserver(kAccountsPrefAllowNewUser, this); 166 cros_settings_->AddSettingsObserver(kAccountsPrefAllowNewUser, this);
165 cros_settings_->AddSettingsObserver(kAccountsPrefAllowGuest, this); 167 cros_settings_->AddSettingsObserver(kAccountsPrefAllowGuest, this);
166 cros_settings_->AddSettingsObserver(kAccountsPrefUsers, this); 168 cros_settings_->AddSettingsObserver(kAccountsPrefUsers, this);
169 cros_settings_->AddSettingsObserver(
170 kAccountsPrefDeviceLocalAccountAutoLoginId,
171 this);
172 cros_settings_->AddSettingsObserver(
173 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
174 this);
167 } 175 }
168 176
169 void ExistingUserController::Init(const UserList& users) { 177 void ExistingUserController::Init(const UserList& users) {
170 time_init_ = base::Time::Now(); 178 time_init_ = base::Time::Now();
171 UpdateLoginDisplay(users); 179 UpdateLoginDisplay(users);
180 ConfigurePublicSessionAutoLogin();
172 181
173 LoginUtils::Get()->PrewarmAuthentication(); 182 LoginUtils::Get()->PrewarmAuthentication();
174 DBusThreadManager::Get()->GetSessionManagerClient()->EmitLoginPromptReady(); 183 DBusThreadManager::Get()->GetSessionManagerClient()->EmitLoginPromptReady();
175 } 184 }
176 185
177 void ExistingUserController::UpdateLoginDisplay(const UserList& users) { 186 void ExistingUserController::UpdateLoginDisplay(const UserList& users) {
178 bool show_users_on_signin; 187 bool show_users_on_signin;
179 UserList filtered_users; 188 UserList filtered_users;
180 189
181 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, 190 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 const content::NotificationSource& source, 231 const content::NotificationSource& source,
223 const content::NotificationDetails& details) { 232 const content::NotificationDetails& details) {
224 if (type == chrome::NOTIFICATION_SESSION_STARTED) { 233 if (type == chrome::NOTIFICATION_SESSION_STARTED) {
225 // Stop listening to any notification once session has started. 234 // Stop listening to any notification once session has started.
226 // Sign in screen objects are marked for deletion with DeleteSoon so 235 // Sign in screen objects are marked for deletion with DeleteSoon so
227 // make sure no object would be used after session has started. 236 // make sure no object would be used after session has started.
228 // http://crbug.com/125276 237 // http://crbug.com/125276
229 registrar_.RemoveAll(); 238 registrar_.RemoveAll();
230 return; 239 return;
231 } 240 }
241 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) {
242 std::string setting = *content::Details<const std::string>(details).ptr();
243 if (setting == kAccountsPrefDeviceLocalAccountAutoLoginId ||
244 setting == kAccountsPrefDeviceLocalAccountAutoLoginDelay) {
245 ConfigurePublicSessionAutoLogin();
246 }
247 }
232 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED || 248 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED ||
233 type == chrome::NOTIFICATION_POLICY_USER_LIST_CHANGED) { 249 type == chrome::NOTIFICATION_POLICY_USER_LIST_CHANGED) {
234 if (host_ != NULL) { 250 if (host_ != NULL) {
235 // Signed settings or user list changed. Notify views and update them. 251 // Signed settings or user list changed. Notify views and update them.
236 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers()); 252 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers());
237 return; 253 return;
238 } 254 }
239 } 255 }
240 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) { 256 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) {
241 // Possibly the user has authenticated against a proxy server and we might 257 // Possibly the user has authenticated against a proxy server and we might
(...skipping 29 matching lines...) Expand all
271 // ExistingUserController, private: 287 // ExistingUserController, private:
272 288
273 ExistingUserController::~ExistingUserController() { 289 ExistingUserController::~ExistingUserController() {
274 LoginUtils::Get()->DelegateDeleted(this); 290 LoginUtils::Get()->DelegateDeleted(this);
275 291
276 cros_settings_->RemoveSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, 292 cros_settings_->RemoveSettingsObserver(kAccountsPrefShowUserNamesOnSignIn,
277 this); 293 this);
278 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this); 294 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this);
279 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowGuest, this); 295 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowGuest, this);
280 cros_settings_->RemoveSettingsObserver(kAccountsPrefUsers, this); 296 cros_settings_->RemoveSettingsObserver(kAccountsPrefUsers, this);
297 cros_settings_->RemoveSettingsObserver(
298 kAccountsPrefDeviceLocalAccountAutoLoginId,
299 this);
300 cros_settings_->RemoveSettingsObserver(
301 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
302 this);
281 303
282 if (current_controller_ == this) { 304 if (current_controller_ == this) {
283 current_controller_ = NULL; 305 current_controller_ = NULL;
284 } else { 306 } else {
285 NOTREACHED() << "More than one controller are alive."; 307 NOTREACHED() << "More than one controller are alive.";
286 } 308 }
287 DCHECK(login_display_.get()); 309 DCHECK(login_display_.get());
288 } 310 }
289 311
290 //////////////////////////////////////////////////////////////////////////////// 312 ////////////////////////////////////////////////////////////////////////////////
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 // TODO(nkostylev): A11y message. 347 // TODO(nkostylev): A11y message.
326 } 348 }
327 349
328 void ExistingUserController::CompleteLogin(const std::string& username, 350 void ExistingUserController::CompleteLogin(const std::string& username,
329 const std::string& password) { 351 const std::string& password) {
330 if (!host_) { 352 if (!host_) {
331 // Complete login event was generated already from UI. Ignore notification. 353 // Complete login event was generated already from UI. Ignore notification.
332 return; 354 return;
333 } 355 }
334 356
357 // Stop the auto-login timer when attempting login.
358 StopPublicSessionAutoLoginTimer();
359
335 // Disable UI while loading user profile. 360 // Disable UI while loading user profile.
336 login_display_->SetUIEnabled(false); 361 login_display_->SetUIEnabled(false);
337 362
338 if (!time_init_.is_null()) { 363 if (!time_init_.is_null()) {
339 base::TimeDelta delta = base::Time::Now() - time_init_; 364 base::TimeDelta delta = base::Time::Now() - time_init_;
340 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta); 365 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta);
341 time_init_ = base::Time(); // Reset to null. 366 time_init_ = base::Time(); // Reset to null.
342 } 367 }
343 368
344 host_->OnCompleteLogin(); 369 host_->OnCompleteLogin();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 406 }
382 407
383 string16 ExistingUserController::GetConnectedNetworkName() { 408 string16 ExistingUserController::GetConnectedNetworkName() {
384 return GetCurrentNetworkName(); 409 return GetCurrentNetworkName();
385 } 410 }
386 411
387 void ExistingUserController::Login(const std::string& username, 412 void ExistingUserController::Login(const std::string& username,
388 const std::string& password) { 413 const std::string& password) {
389 if (username.empty() || password.empty()) 414 if (username.empty() || password.empty())
390 return; 415 return;
416
417 // Stop the auto-login timer when attempting login.
418 StopPublicSessionAutoLoginTimer();
419
391 // Disable clicking on other windows. 420 // Disable clicking on other windows.
392 login_display_->SetUIEnabled(false); 421 login_display_->SetUIEnabled(false);
393 422
394 BootTimesLoader::Get()->RecordLoginAttempted(); 423 BootTimesLoader::Get()->RecordLoginAttempted();
395 424
396 if (last_login_attempt_username_ != username) { 425 if (last_login_attempt_username_ != username) {
397 last_login_attempt_username_ = username; 426 last_login_attempt_username_ = username;
398 num_login_attempts_ = 0; 427 num_login_attempts_ = 0;
399 // Also reset state variables, which are used to determine password change. 428 // Also reset state variables, which are used to determine password change.
400 offline_failed_ = false; 429 offline_failed_ = false;
(...skipping 27 matching lines...) Expand all
428 UserManager::kLocallyManagedUserDomain) { 457 UserManager::kLocallyManagedUserDomain) {
429 login_performer_->LoginAsLocallyManagedUser(username, password); 458 login_performer_->LoginAsLocallyManagedUser(username, password);
430 } else { 459 } else {
431 login_performer_->PerformLogin(username, password, auth_mode); 460 login_performer_->PerformLogin(username, password, auth_mode);
432 } 461 }
433 accessibility::MaybeSpeak( 462 accessibility::MaybeSpeak(
434 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); 463 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN));
435 } 464 }
436 465
437 void ExistingUserController::LoginAsRetailModeUser() { 466 void ExistingUserController::LoginAsRetailModeUser() {
467 // Stop the auto-login timer when attempting login.
468 StopPublicSessionAutoLoginTimer();
469
438 // Disable clicking on other windows. 470 // Disable clicking on other windows.
439 login_display_->SetUIEnabled(false); 471 login_display_->SetUIEnabled(false);
440 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once 472 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once
441 // the enterprise policy wiring is done for retail mode. 473 // the enterprise policy wiring is done for retail mode.
442 474
443 // Only one instance of LoginPerformer should exist at a time. 475 // Only one instance of LoginPerformer should exist at a time.
444 login_performer_.reset(NULL); 476 login_performer_.reset(NULL);
445 login_performer_.reset(new LoginPerformer(this)); 477 login_performer_.reset(new LoginPerformer(this));
446 is_login_in_progress_ = true; 478 is_login_in_progress_ = true;
447 login_performer_->LoginRetailMode(); 479 login_performer_->LoginRetailMode();
448 accessibility::MaybeSpeak( 480 accessibility::MaybeSpeak(
449 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); 481 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER));
450 } 482 }
451 483
452 void ExistingUserController::LoginAsGuest() { 484 void ExistingUserController::LoginAsGuest() {
485 // Stop the auto-login timer when attempting login.
486 StopPublicSessionAutoLoginTimer();
487
453 // Disable clicking on other windows. 488 // Disable clicking on other windows.
454 login_display_->SetUIEnabled(false); 489 login_display_->SetUIEnabled(false);
455 490
456 CrosSettingsProvider::TrustedStatus status = 491 CrosSettingsProvider::TrustedStatus status =
457 cros_settings_->PrepareTrustedValues( 492 cros_settings_->PrepareTrustedValues(
458 base::Bind(&ExistingUserController::LoginAsGuest, 493 base::Bind(&ExistingUserController::LoginAsGuest,
459 weak_factory_.GetWeakPtr())); 494 weak_factory_.GetWeakPtr()));
460 // Must not proceed without signature verification. 495 // Must not proceed without signature verification.
461 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { 496 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) {
462 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, 497 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1,
463 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); 498 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
464 // Reenable clicking on other windows and status area. 499 // Reenable clicking on other windows and status area.
465 login_display_->SetUIEnabled(true); 500 login_display_->SetUIEnabled(true);
501 StartPublicSessionAutoLoginTimer();
466 display_email_.clear(); 502 display_email_.clear();
467 return; 503 return;
468 } else if (status != CrosSettingsProvider::TRUSTED) { 504 } else if (status != CrosSettingsProvider::TRUSTED) {
469 // Value of AllowNewUser setting is still not verified. 505 // Value of AllowNewUser setting is still not verified.
470 // Another attempt will be invoked after verification completion. 506 // Another attempt will be invoked after verification completion.
507 StartPublicSessionAutoLoginTimer();
471 return; 508 return;
472 } 509 }
473 510
474 bool allow_guest; 511 bool allow_guest;
475 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); 512 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest);
476 if (!allow_guest) { 513 if (!allow_guest) {
477 // Disallowed. The UI should normally not show the guest pod but if for some 514 // Disallowed. The UI should normally not show the guest pod but if for some
478 // reason this has been made available to the user here is the time to tell 515 // reason this has been made available to the user here is the time to tell
479 // this nicely. 516 // this nicely.
480 login_display_->ShowError(IDS_LOGIN_ERROR_WHITELIST, 1, 517 login_display_->ShowError(IDS_LOGIN_ERROR_WHITELIST, 1,
481 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); 518 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
482 // Reenable clicking on other windows and status area. 519 // Reenable clicking on other windows and status area.
483 login_display_->SetUIEnabled(true); 520 login_display_->SetUIEnabled(true);
521 StartPublicSessionAutoLoginTimer();
484 display_email_.clear(); 522 display_email_.clear();
485 return; 523 return;
486 } 524 }
487 525
488 // Only one instance of LoginPerformer should exist at a time. 526 // Only one instance of LoginPerformer should exist at a time.
489 login_performer_.reset(NULL); 527 login_performer_.reset(NULL);
490 login_performer_.reset(new LoginPerformer(this)); 528 login_performer_.reset(new LoginPerformer(this));
491 is_login_in_progress_ = true; 529 is_login_in_progress_ = true;
492 login_performer_->LoginOffTheRecord(); 530 login_performer_->LoginOffTheRecord();
493 accessibility::MaybeSpeak( 531 accessibility::MaybeSpeak(
494 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); 532 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD));
495 } 533 }
496 534
497 void ExistingUserController::MigrateUserData(const std::string& old_password) { 535 void ExistingUserController::MigrateUserData(const std::string& old_password) {
498 RecoverEncryptedData(old_password); 536 RecoverEncryptedData(old_password);
499 } 537 }
500 538
501 void ExistingUserController::LoginAsPublicAccount( 539 void ExistingUserController::LoginAsPublicAccount(
502 const std::string& username) { 540 const std::string& username) {
541 // Stop the auto-login timer when attempting login.
542 StopPublicSessionAutoLoginTimer();
543
503 // Disable clicking on other windows. 544 // Disable clicking on other windows.
504 login_display_->SetUIEnabled(false); 545 login_display_->SetUIEnabled(false);
505 546
506 CrosSettingsProvider::TrustedStatus status = 547 CrosSettingsProvider::TrustedStatus status =
507 cros_settings_->PrepareTrustedValues( 548 cros_settings_->PrepareTrustedValues(
508 base::Bind(&ExistingUserController::LoginAsPublicAccount, 549 base::Bind(&ExistingUserController::LoginAsPublicAccount,
509 weak_factory_.GetWeakPtr(), 550 weak_factory_.GetWeakPtr(),
510 username)); 551 username));
511 // If device policy is permanently unavailable, logging into public accounts 552 // If device policy is permanently unavailable, logging into public accounts
512 // is not possible. 553 // is not possible.
513 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { 554 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) {
514 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, 555 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1,
515 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); 556 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
516 // Re-enable clicking on other windows. 557 // Re-enable clicking on other windows.
517 login_display_->SetUIEnabled(true); 558 login_display_->SetUIEnabled(true);
518 return; 559 return;
519 } 560 }
520 561
521 // If device policy is not verified yet, this function will be called again 562 // If device policy is not verified yet, this function will be called again
522 // when verification finishes. 563 // when verification finishes.
523 if (status != CrosSettingsProvider::TRUSTED) 564 if (status != CrosSettingsProvider::TRUSTED) {
565 StartPublicSessionAutoLoginTimer();
524 return; 566 return;
567 }
525 568
526 // If there is no public account with the given |username|, logging in is not 569 // If there is no public account with the given |username|, logging in is not
527 // possible. 570 // possible.
528 const User* user = UserManager::Get()->FindUser(username); 571 const User* user = UserManager::Get()->FindUser(username);
529 if (!user || user->GetType() != User::USER_TYPE_PUBLIC_ACCOUNT) { 572 if (!user || user->GetType() != User::USER_TYPE_PUBLIC_ACCOUNT) {
530 // Re-enable clicking on other windows. 573 // Re-enable clicking on other windows.
531 login_display_->SetUIEnabled(true); 574 login_display_->SetUIEnabled(true);
575 StartPublicSessionAutoLoginTimer();
532 return; 576 return;
533 } 577 }
534 578
535 // Only one instance of LoginPerformer should exist at a time. 579 // Only one instance of LoginPerformer should exist at a time.
536 login_performer_.reset(NULL); 580 login_performer_.reset(NULL);
537 login_performer_.reset(new LoginPerformer(this)); 581 login_performer_.reset(new LoginPerformer(this));
538 is_login_in_progress_ = true; 582 is_login_in_progress_ = true;
539 login_performer_->LoginAsPublicAccount(username); 583 login_performer_->LoginAsPublicAccount(username);
540 accessibility::MaybeSpeak( 584 accessibility::MaybeSpeak(
541 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); 585 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT));
542 } 586 }
543 587
588 void ExistingUserController::OnSigninScreenReady() {
589 signin_screen_ready_ = true;
590 StartPublicSessionAutoLoginTimer();
591 }
592
544 void ExistingUserController::OnUserSelected(const std::string& username) { 593 void ExistingUserController::OnUserSelected(const std::string& username) {
545 login_performer_.reset(NULL); 594 login_performer_.reset(NULL);
546 num_login_attempts_ = 0; 595 num_login_attempts_ = 0;
547 } 596 }
548 597
549 void ExistingUserController::OnStartEnterpriseEnrollment() { 598 void ExistingUserController::OnStartEnterpriseEnrollment() {
550 DeviceSettingsService::Get()->GetOwnershipStatusAsync( 599 DeviceSettingsService::Get()->GetOwnershipStatusAsync(
551 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted, 600 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted,
552 weak_factory_.GetWeakPtr())); 601 weak_factory_.GetWeakPtr()));
553 } 602 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 } 723 }
675 // Reenable clicking on other windows and status area. 724 // Reenable clicking on other windows and status area.
676 login_display_->SetUIEnabled(true); 725 login_display_->SetUIEnabled(true);
677 } 726 }
678 727
679 if (login_status_consumer_) 728 if (login_status_consumer_)
680 login_status_consumer_->OnLoginFailure(failure); 729 login_status_consumer_->OnLoginFailure(failure);
681 730
682 // Clear the recorded displayed email so it won't affect any future attempts. 731 // Clear the recorded displayed email so it won't affect any future attempts.
683 display_email_.clear(); 732 display_email_.clear();
733
734 StartPublicSessionAutoLoginTimer();
684 } 735 }
685 736
686 void ExistingUserController::OnLoginSuccess( 737 void ExistingUserController::OnLoginSuccess(
687 const std::string& username, 738 const std::string& username,
688 const std::string& password, 739 const std::string& password,
689 bool pending_requests, 740 bool pending_requests,
690 bool using_oauth) { 741 bool using_oauth) {
691 is_login_in_progress_ = false; 742 is_login_in_progress_ = false;
692 offline_failed_ = false; 743 offline_failed_ = false;
693 744
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 display_email_.clear(); 884 display_email_.clear();
834 } 885 }
835 886
836 void ExistingUserController::PolicyLoadFailed() { 887 void ExistingUserController::PolicyLoadFailed() {
837 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, ""); 888 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, "");
838 889
839 // Reenable clicking on other windows and status area. 890 // Reenable clicking on other windows and status area.
840 login_display_->SetUIEnabled(true); 891 login_display_->SetUIEnabled(true);
841 892
842 display_email_.clear(); 893 display_email_.clear();
894
895 // Policy load failure stops login attempts---restart the timer.
bartfab (slow) 2013/02/11 17:11:21 Hmm. The request to add space around the odd -- yi
896 StartPublicSessionAutoLoginTimer();
843 } 897 }
844 898
845 void ExistingUserController::OnOnlineChecked(const std::string& username, 899 void ExistingUserController::OnOnlineChecked(const std::string& username,
846 bool success) { 900 bool success) {
847 if (success && last_login_attempt_username_ == username) { 901 if (success && last_login_attempt_username_ == username) {
848 online_succeeded_for_ = username; 902 online_succeeded_for_ = username;
849 // Wait for login attempt to end, if it hasn't yet. 903 // Wait for login attempt to end, if it hasn't yet.
850 if (offline_failed_ && !is_login_in_progress_) 904 if (offline_failed_ && !is_login_in_progress_)
851 ShowGaiaPasswordChanged(username); 905 ShowGaiaPasswordChanged(username);
852 } 906 }
(...skipping 21 matching lines...) Expand all
874 928
875 void ExistingUserController::ActivateWizard(const std::string& screen_name) { 929 void ExistingUserController::ActivateWizard(const std::string& screen_name) {
876 DictionaryValue* params = NULL; 930 DictionaryValue* params = NULL;
877 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) { 931 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) {
878 params = new DictionaryValue; 932 params = new DictionaryValue;
879 params->SetString("start_url", guest_mode_url_.spec()); 933 params->SetString("start_url", guest_mode_url_.spec());
880 } 934 }
881 host_->StartWizard(screen_name, params); 935 host_->StartWizard(screen_name, params);
882 } 936 }
883 937
938 void ExistingUserController::ConfigurePublicSessionAutoLogin() {
939 if (!cros_settings_->GetString(
940 kAccountsPrefDeviceLocalAccountAutoLoginId,
941 &public_session_auto_login_username_) ||
942 public_session_auto_login_username_.empty()) {
943 public_session_auto_login_username_ = "";
944 }
945 if (!cros_settings_->GetInteger(
946 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
947 &public_session_auto_login_timer_)) {
948 public_session_auto_login_timer_ = 0;
949 }
950
951 if (!public_session_auto_login_username_.empty()) {
952 if (!ash::Shell::GetInstance()->user_activity_detector()->HasObserver(this))
953 ash::Shell::GetInstance()->user_activity_detector()->AddObserver(this);
954 StartPublicSessionAutoLoginTimer();
955 } else {
956 ash::Shell::GetInstance()->user_activity_detector()->RemoveObserver(this);
957 StopPublicSessionAutoLoginTimer();
958 }
959 }
960
961 void ExistingUserController::OnUserActivity() {
962 if (auto_login_timer_.IsRunning()) {
963 StopPublicSessionAutoLoginTimer();
964 StartPublicSessionAutoLoginTimer();
965 }
966 }
967
968 void ExistingUserController::StopPublicSessionAutoLoginTimer() {
969 auto_login_timer_.Stop();
970 }
971
972 void ExistingUserController::StartPublicSessionAutoLoginTimer() {
973 if (!signin_screen_ready_ || public_session_auto_login_username_.empty())
974 return;
975 auto_login_timer_.Start(FROM_HERE,
976 base::TimeDelta::FromMilliseconds(
977 public_session_auto_login_timer_),
978 base::Bind(
979 &ExistingUserController::LoginAsPublicAccount,
980 weak_factory_.GetWeakPtr(),
981 public_session_auto_login_username_));
982 }
983
884 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { 984 gfx::NativeWindow ExistingUserController::GetNativeWindow() const {
885 return host_->GetNativeWindow(); 985 return host_->GetNativeWindow();
886 } 986 }
887 987
888 void ExistingUserController::InitializeStartUrls() const { 988 void ExistingUserController::InitializeStartUrls() const {
889 std::vector<std::string> start_urls; 989 std::vector<std::string> start_urls;
890 990
891 PrefService* prefs = g_browser_process->local_state(); 991 PrefService* prefs = g_browser_process->local_state();
892 const base::ListValue *urls; 992 const base::ListValue *urls;
893 bool show_getstarted_guide = false; 993 bool show_getstarted_guide = false;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 username, 1120 username,
1021 CommandLine::ForCurrentProcess()->HasSwitch(switches::kForceOAuth1) ? 1121 CommandLine::ForCurrentProcess()->HasSwitch(switches::kForceOAuth1) ?
1022 User::OAUTH1_TOKEN_STATUS_INVALID : 1122 User::OAUTH1_TOKEN_STATUS_INVALID :
1023 User::OAUTH2_TOKEN_STATUS_INVALID); 1123 User::OAUTH2_TOKEN_STATUS_INVALID);
1024 1124
1025 login_display_->SetUIEnabled(true); 1125 login_display_->SetUIEnabled(true);
1026 login_display_->ShowGaiaPasswordChanged(username); 1126 login_display_->ShowGaiaPasswordChanged(username);
1027 } 1127 }
1028 1128
1029 } // namespace chromeos 1129 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698