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

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: split an assert Created 7 years, 9 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 "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 ExistingUserController::ExistingUserController(LoginDisplayHost* host) 136 ExistingUserController::ExistingUserController(LoginDisplayHost* host)
137 : login_status_consumer_(NULL), 137 : login_status_consumer_(NULL),
138 host_(host), 138 host_(host),
139 login_display_(host_->CreateLoginDisplay(this)), 139 login_display_(host_->CreateLoginDisplay(this)),
140 num_login_attempts_(0), 140 num_login_attempts_(0),
141 cros_settings_(CrosSettings::Get()), 141 cros_settings_(CrosSettings::Get()),
142 weak_factory_(this), 142 weak_factory_(this),
143 offline_failed_(false), 143 offline_failed_(false),
144 is_login_in_progress_(false), 144 is_login_in_progress_(false),
145 password_changed_(false), 145 password_changed_(false),
146 do_auto_enrollment_(false) { 146 do_auto_enrollment_(false),
147 signin_screen_ready_(false) {
147 DCHECK(current_controller_ == NULL); 148 DCHECK(current_controller_ == NULL);
148 current_controller_ = this; 149 current_controller_ = this;
149 150
150 registrar_.Add(this, 151 registrar_.Add(this,
151 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 152 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
152 content::NotificationService::AllSources()); 153 content::NotificationService::AllSources());
153 registrar_.Add(this, 154 registrar_.Add(this,
154 chrome::NOTIFICATION_USER_LIST_CHANGED, 155 chrome::NOTIFICATION_USER_LIST_CHANGED,
155 content::NotificationService::AllSources()); 156 content::NotificationService::AllSources());
156 registrar_.Add(this, 157 registrar_.Add(this,
157 chrome::NOTIFICATION_AUTH_SUPPLIED, 158 chrome::NOTIFICATION_AUTH_SUPPLIED,
158 content::NotificationService::AllSources()); 159 content::NotificationService::AllSources());
159 registrar_.Add(this, 160 registrar_.Add(this,
160 chrome::NOTIFICATION_SESSION_STARTED, 161 chrome::NOTIFICATION_SESSION_STARTED,
161 content::NotificationService::AllSources()); 162 content::NotificationService::AllSources());
162 cros_settings_->AddSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, this); 163 cros_settings_->AddSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, this);
163 cros_settings_->AddSettingsObserver(kAccountsPrefAllowNewUser, this); 164 cros_settings_->AddSettingsObserver(kAccountsPrefAllowNewUser, this);
164 cros_settings_->AddSettingsObserver(kAccountsPrefAllowGuest, this); 165 cros_settings_->AddSettingsObserver(kAccountsPrefAllowGuest, this);
165 cros_settings_->AddSettingsObserver(kAccountsPrefUsers, this); 166 cros_settings_->AddSettingsObserver(kAccountsPrefUsers, this);
167 cros_settings_->AddSettingsObserver(
168 kAccountsPrefDeviceLocalAccountAutoLoginId,
169 this);
170 cros_settings_->AddSettingsObserver(
171 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
172 this);
166 } 173 }
167 174
168 void ExistingUserController::Init(const UserList& users) { 175 void ExistingUserController::Init(const UserList& users) {
169 time_init_ = base::Time::Now(); 176 time_init_ = base::Time::Now();
170 UpdateLoginDisplay(users); 177 UpdateLoginDisplay(users);
178 ConfigurePublicSessionAutoLogin();
171 179
172 LoginUtils::Get()->PrewarmAuthentication(); 180 LoginUtils::Get()->PrewarmAuthentication();
173 DBusThreadManager::Get()->GetSessionManagerClient()->EmitLoginPromptReady(); 181 DBusThreadManager::Get()->GetSessionManagerClient()->EmitLoginPromptReady();
174 } 182 }
175 183
176 void ExistingUserController::UpdateLoginDisplay(const UserList& users) { 184 void ExistingUserController::UpdateLoginDisplay(const UserList& users) {
177 bool show_users_on_signin; 185 bool show_users_on_signin;
178 UserList filtered_users; 186 UserList filtered_users;
179 187
180 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, 188 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 const content::NotificationSource& source, 238 const content::NotificationSource& source,
231 const content::NotificationDetails& details) { 239 const content::NotificationDetails& details) {
232 if (type == chrome::NOTIFICATION_SESSION_STARTED) { 240 if (type == chrome::NOTIFICATION_SESSION_STARTED) {
233 // Stop listening to any notification once session has started. 241 // Stop listening to any notification once session has started.
234 // Sign in screen objects are marked for deletion with DeleteSoon so 242 // Sign in screen objects are marked for deletion with DeleteSoon so
235 // make sure no object would be used after session has started. 243 // make sure no object would be used after session has started.
236 // http://crbug.com/125276 244 // http://crbug.com/125276
237 registrar_.RemoveAll(); 245 registrar_.RemoveAll();
238 return; 246 return;
239 } 247 }
248 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) {
249 const std::string setting = *content::Details<const std::string>(
250 details).ptr();
251 if (setting == kAccountsPrefDeviceLocalAccountAutoLoginId ||
252 setting == kAccountsPrefDeviceLocalAccountAutoLoginDelay) {
253 ConfigurePublicSessionAutoLogin();
254 }
255 }
240 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED || 256 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED ||
241 type == chrome::NOTIFICATION_USER_LIST_CHANGED) { 257 type == chrome::NOTIFICATION_USER_LIST_CHANGED) {
242 if (host_ != NULL) { 258 if (host_ != NULL) {
243 // Signed settings or user list changed. Notify views and update them. 259 // Signed settings or user list changed. Notify views and update them.
244 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers()); 260 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers());
245 return; 261 return;
246 } 262 }
247 } 263 }
248 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) { 264 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) {
249 // Possibly the user has authenticated against a proxy server and we might 265 // Possibly the user has authenticated against a proxy server and we might
(...skipping 29 matching lines...) Expand all
279 // ExistingUserController, private: 295 // ExistingUserController, private:
280 296
281 ExistingUserController::~ExistingUserController() { 297 ExistingUserController::~ExistingUserController() {
282 LoginUtils::Get()->DelegateDeleted(this); 298 LoginUtils::Get()->DelegateDeleted(this);
283 299
284 cros_settings_->RemoveSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, 300 cros_settings_->RemoveSettingsObserver(kAccountsPrefShowUserNamesOnSignIn,
285 this); 301 this);
286 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this); 302 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this);
287 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowGuest, this); 303 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowGuest, this);
288 cros_settings_->RemoveSettingsObserver(kAccountsPrefUsers, this); 304 cros_settings_->RemoveSettingsObserver(kAccountsPrefUsers, this);
305 cros_settings_->RemoveSettingsObserver(
306 kAccountsPrefDeviceLocalAccountAutoLoginId,
307 this);
308 cros_settings_->RemoveSettingsObserver(
309 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
310 this);
289 311
290 if (current_controller_ == this) { 312 if (current_controller_ == this) {
291 current_controller_ = NULL; 313 current_controller_ = NULL;
292 } else { 314 } else {
293 NOTREACHED() << "More than one controller are alive."; 315 NOTREACHED() << "More than one controller are alive.";
294 } 316 }
295 DCHECK(login_display_.get()); 317 DCHECK(login_display_.get());
296 } 318 }
297 319
298 //////////////////////////////////////////////////////////////////////////////// 320 ////////////////////////////////////////////////////////////////////////////////
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // TODO(nkostylev): A11y message. 355 // TODO(nkostylev): A11y message.
334 } 356 }
335 357
336 void ExistingUserController::CompleteLogin(const std::string& username, 358 void ExistingUserController::CompleteLogin(const std::string& username,
337 const std::string& password) { 359 const std::string& password) {
338 if (!host_) { 360 if (!host_) {
339 // Complete login event was generated already from UI. Ignore notification. 361 // Complete login event was generated already from UI. Ignore notification.
340 return; 362 return;
341 } 363 }
342 364
365 // Stop the auto-login timer when attempting login.
366 StopPublicSessionAutoLoginTimer();
367
343 // Disable UI while loading user profile. 368 // Disable UI while loading user profile.
344 login_display_->SetUIEnabled(false); 369 login_display_->SetUIEnabled(false);
345 370
346 if (!time_init_.is_null()) { 371 if (!time_init_.is_null()) {
347 base::TimeDelta delta = base::Time::Now() - time_init_; 372 base::TimeDelta delta = base::Time::Now() - time_init_;
348 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta); 373 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta);
349 time_init_ = base::Time(); // Reset to null. 374 time_init_ = base::Time(); // Reset to null.
350 } 375 }
351 376
352 host_->OnCompleteLogin(); 377 host_->OnCompleteLogin();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 414 }
390 415
391 string16 ExistingUserController::GetConnectedNetworkName() { 416 string16 ExistingUserController::GetConnectedNetworkName() {
392 return GetCurrentNetworkName(); 417 return GetCurrentNetworkName();
393 } 418 }
394 419
395 void ExistingUserController::Login(const std::string& username, 420 void ExistingUserController::Login(const std::string& username,
396 const std::string& password) { 421 const std::string& password) {
397 if (username.empty() || password.empty()) 422 if (username.empty() || password.empty())
398 return; 423 return;
424
425 // Stop the auto-login timer when attempting login.
426 StopPublicSessionAutoLoginTimer();
427
399 // Disable clicking on other windows. 428 // Disable clicking on other windows.
400 login_display_->SetUIEnabled(false); 429 login_display_->SetUIEnabled(false);
401 430
402 BootTimesLoader::Get()->RecordLoginAttempted(); 431 BootTimesLoader::Get()->RecordLoginAttempted();
403 432
404 if (last_login_attempt_username_ != username) { 433 if (last_login_attempt_username_ != username) {
405 last_login_attempt_username_ = username; 434 last_login_attempt_username_ = username;
406 num_login_attempts_ = 0; 435 num_login_attempts_ = 0;
407 // Also reset state variables, which are used to determine password change. 436 // Also reset state variables, which are used to determine password change.
408 offline_failed_ = false; 437 offline_failed_ = false;
(...skipping 27 matching lines...) Expand all
436 UserManager::kLocallyManagedUserDomain) { 465 UserManager::kLocallyManagedUserDomain) {
437 login_performer_->LoginAsLocallyManagedUser(username, password); 466 login_performer_->LoginAsLocallyManagedUser(username, password);
438 } else { 467 } else {
439 login_performer_->PerformLogin(username, password, auth_mode); 468 login_performer_->PerformLogin(username, password, auth_mode);
440 } 469 }
441 accessibility::MaybeSpeak( 470 accessibility::MaybeSpeak(
442 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); 471 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN));
443 } 472 }
444 473
445 void ExistingUserController::LoginAsRetailModeUser() { 474 void ExistingUserController::LoginAsRetailModeUser() {
475 // Stop the auto-login timer when attempting login.
476 StopPublicSessionAutoLoginTimer();
477
446 // Disable clicking on other windows. 478 // Disable clicking on other windows.
447 login_display_->SetUIEnabled(false); 479 login_display_->SetUIEnabled(false);
448 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once 480 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once
449 // the enterprise policy wiring is done for retail mode. 481 // the enterprise policy wiring is done for retail mode.
450 482
451 // Only one instance of LoginPerformer should exist at a time. 483 // Only one instance of LoginPerformer should exist at a time.
452 login_performer_.reset(NULL); 484 login_performer_.reset(NULL);
453 login_performer_.reset(new LoginPerformer(this)); 485 login_performer_.reset(new LoginPerformer(this));
454 is_login_in_progress_ = true; 486 is_login_in_progress_ = true;
455 login_performer_->LoginRetailMode(); 487 login_performer_->LoginRetailMode();
456 accessibility::MaybeSpeak( 488 accessibility::MaybeSpeak(
457 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); 489 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER));
458 } 490 }
459 491
460 void ExistingUserController::LoginAsGuest() { 492 void ExistingUserController::LoginAsGuest() {
493 // Stop the auto-login timer when attempting login.
494 StopPublicSessionAutoLoginTimer();
495
461 // Disable clicking on other windows. 496 // Disable clicking on other windows.
462 login_display_->SetUIEnabled(false); 497 login_display_->SetUIEnabled(false);
463 498
464 CrosSettingsProvider::TrustedStatus status = 499 CrosSettingsProvider::TrustedStatus status =
465 cros_settings_->PrepareTrustedValues( 500 cros_settings_->PrepareTrustedValues(
466 base::Bind(&ExistingUserController::LoginAsGuest, 501 base::Bind(&ExistingUserController::LoginAsGuest,
467 weak_factory_.GetWeakPtr())); 502 weak_factory_.GetWeakPtr()));
468 // Must not proceed without signature verification. 503 // Must not proceed without signature verification.
469 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { 504 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) {
470 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, 505 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1,
471 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); 506 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
472 // Reenable clicking on other windows and status area. 507 // Reenable clicking on other windows and status area.
473 login_display_->SetUIEnabled(true); 508 login_display_->SetUIEnabled(true);
509 StartPublicSessionAutoLoginTimer();
474 display_email_.clear(); 510 display_email_.clear();
475 return; 511 return;
476 } else if (status != CrosSettingsProvider::TRUSTED) { 512 } else if (status != CrosSettingsProvider::TRUSTED) {
477 // Value of AllowNewUser setting is still not verified. 513 // Value of AllowNewUser setting is still not verified.
478 // Another attempt will be invoked after verification completion. 514 // Another attempt will be invoked after verification completion.
479 return; 515 return;
480 } 516 }
481 517
482 bool allow_guest; 518 bool allow_guest;
483 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); 519 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest);
484 if (!allow_guest) { 520 if (!allow_guest) {
485 // Disallowed. The UI should normally not show the guest pod but if for some 521 // Disallowed. The UI should normally not show the guest pod but if for some
486 // reason this has been made available to the user here is the time to tell 522 // reason this has been made available to the user here is the time to tell
487 // this nicely. 523 // this nicely.
488 login_display_->ShowError(IDS_LOGIN_ERROR_WHITELIST, 1, 524 login_display_->ShowError(IDS_LOGIN_ERROR_WHITELIST, 1,
489 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); 525 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
490 // Reenable clicking on other windows and status area. 526 // Reenable clicking on other windows and status area.
491 login_display_->SetUIEnabled(true); 527 login_display_->SetUIEnabled(true);
528 StartPublicSessionAutoLoginTimer();
492 display_email_.clear(); 529 display_email_.clear();
493 return; 530 return;
494 } 531 }
495 532
496 // Only one instance of LoginPerformer should exist at a time. 533 // Only one instance of LoginPerformer should exist at a time.
497 login_performer_.reset(NULL); 534 login_performer_.reset(NULL);
498 login_performer_.reset(new LoginPerformer(this)); 535 login_performer_.reset(new LoginPerformer(this));
499 is_login_in_progress_ = true; 536 is_login_in_progress_ = true;
500 login_performer_->LoginOffTheRecord(); 537 login_performer_->LoginOffTheRecord();
501 accessibility::MaybeSpeak( 538 accessibility::MaybeSpeak(
502 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); 539 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD));
503 } 540 }
504 541
505 void ExistingUserController::MigrateUserData(const std::string& old_password) { 542 void ExistingUserController::MigrateUserData(const std::string& old_password) {
506 // LoginPerformer instance has state of the user so it should exist. 543 // LoginPerformer instance has state of the user so it should exist.
507 if (login_performer_.get()) 544 if (login_performer_.get())
508 login_performer_->RecoverEncryptedData(old_password); 545 login_performer_->RecoverEncryptedData(old_password);
509 } 546 }
510 547
511 void ExistingUserController::LoginAsPublicAccount( 548 void ExistingUserController::LoginAsPublicAccount(
512 const std::string& username) { 549 const std::string& username) {
550 // Stop the auto-login timer when attempting login.
551 StopPublicSessionAutoLoginTimer();
552
513 // Disable clicking on other windows. 553 // Disable clicking on other windows.
514 login_display_->SetUIEnabled(false); 554 login_display_->SetUIEnabled(false);
515 555
516 CrosSettingsProvider::TrustedStatus status = 556 CrosSettingsProvider::TrustedStatus status =
517 cros_settings_->PrepareTrustedValues( 557 cros_settings_->PrepareTrustedValues(
518 base::Bind(&ExistingUserController::LoginAsPublicAccount, 558 base::Bind(&ExistingUserController::LoginAsPublicAccount,
519 weak_factory_.GetWeakPtr(), 559 weak_factory_.GetWeakPtr(),
520 username)); 560 username));
521 // If device policy is permanently unavailable, logging into public accounts 561 // If device policy is permanently unavailable, logging into public accounts
522 // is not possible. 562 // is not possible.
523 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { 563 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) {
524 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, 564 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1,
525 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); 565 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
526 // Re-enable clicking on other windows. 566 // Re-enable clicking on other windows.
527 login_display_->SetUIEnabled(true); 567 login_display_->SetUIEnabled(true);
528 return; 568 return;
529 } 569 }
530 570
531 // If device policy is not verified yet, this function will be called again 571 // If device policy is not verified yet, this function will be called again
532 // when verification finishes. 572 // when verification finishes.
533 if (status != CrosSettingsProvider::TRUSTED) 573 if (status != CrosSettingsProvider::TRUSTED)
534 return; 574 return;
535 575
536 // If there is no public account with the given |username|, logging in is not 576 // If there is no public account with the given |username|, logging in is not
537 // possible. 577 // possible.
538 const User* user = UserManager::Get()->FindUser(username); 578 const User* user = UserManager::Get()->FindUser(username);
539 if (!user || user->GetType() != User::USER_TYPE_PUBLIC_ACCOUNT) { 579 if (!user || user->GetType() != User::USER_TYPE_PUBLIC_ACCOUNT) {
540 // Re-enable clicking on other windows. 580 // Re-enable clicking on other windows.
541 login_display_->SetUIEnabled(true); 581 login_display_->SetUIEnabled(true);
582 StartPublicSessionAutoLoginTimer();
542 return; 583 return;
543 } 584 }
544 585
545 // Only one instance of LoginPerformer should exist at a time. 586 // Only one instance of LoginPerformer should exist at a time.
546 login_performer_.reset(NULL); 587 login_performer_.reset(NULL);
547 login_performer_.reset(new LoginPerformer(this)); 588 login_performer_.reset(new LoginPerformer(this));
548 is_login_in_progress_ = true; 589 is_login_in_progress_ = true;
549 login_performer_->LoginAsPublicAccount(username); 590 login_performer_->LoginAsPublicAccount(username);
550 accessibility::MaybeSpeak( 591 accessibility::MaybeSpeak(
551 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); 592 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT));
552 } 593 }
553 594
595 void ExistingUserController::OnSigninScreenReady() {
596 signin_screen_ready_ = true;
597 StartPublicSessionAutoLoginTimer();
598 }
599
554 void ExistingUserController::OnUserSelected(const std::string& username) { 600 void ExistingUserController::OnUserSelected(const std::string& username) {
555 login_performer_.reset(NULL); 601 login_performer_.reset(NULL);
556 num_login_attempts_ = 0; 602 num_login_attempts_ = 0;
557 } 603 }
558 604
559 void ExistingUserController::OnStartEnterpriseEnrollment() { 605 void ExistingUserController::OnStartEnterpriseEnrollment() {
560 DeviceSettingsService::Get()->GetOwnershipStatusAsync( 606 DeviceSettingsService::Get()->GetOwnershipStatusAsync(
561 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted, 607 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted,
562 weak_factory_.GetWeakPtr())); 608 weak_factory_.GetWeakPtr()));
563 } 609 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); 728 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error);
683 } else { 729 } else {
684 if (!is_known_user) 730 if (!is_known_user)
685 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); 731 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error);
686 else 732 else
687 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); 733 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error);
688 } 734 }
689 } 735 }
690 // Reenable clicking on other windows and status area. 736 // Reenable clicking on other windows and status area.
691 login_display_->SetUIEnabled(true); 737 login_display_->SetUIEnabled(true);
738 StartPublicSessionAutoLoginTimer();
692 } 739 }
693 740
694 // Reset user flow to default, so that special flow will not affect next 741 // Reset user flow to default, so that special flow will not affect next
695 // attempt. 742 // attempt.
696 UserManager::Get()->ResetUserFlow(last_login_attempt_username_); 743 UserManager::Get()->ResetUserFlow(last_login_attempt_username_);
697 744
698 if (login_status_consumer_) 745 if (login_status_consumer_)
699 login_status_consumer_->OnLoginFailure(failure); 746 login_status_consumer_->OnLoginFailure(failure);
700 747
701 // Clear the recorded displayed email so it won't affect any future attempts. 748 // Clear the recorded displayed email so it won't affect any future attempts.
702 display_email_.clear(); 749 display_email_.clear();
703 } 750 }
704 751
705 void ExistingUserController::OnLoginSuccess( 752 void ExistingUserController::OnLoginSuccess(
706 const std::string& username, 753 const std::string& username,
707 const std::string& password, 754 const std::string& password,
708 bool pending_requests, 755 bool pending_requests,
709 bool using_oauth) { 756 bool using_oauth) {
710 is_login_in_progress_ = false; 757 is_login_in_progress_ = false;
711 offline_failed_ = false; 758 offline_failed_ = false;
712 759
760 StopPublicSessionAutoLoginTimer();
761
713 bool has_cookies = 762 bool has_cookies =
714 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION; 763 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION;
715 764
716 // Login performer will be gone so cache this value to use 765 // Login performer will be gone so cache this value to use
717 // once profile is loaded. 766 // once profile is loaded.
718 password_changed_ = login_performer_->password_changed(); 767 password_changed_ = login_performer_->password_changed();
719 768
720 // LoginPerformer instance will delete itself once online auth result is OK. 769 // LoginPerformer instance will delete itself once online auth result is OK.
721 // In case of failure it'll bring up ScreenLock and ask for 770 // In case of failure it'll bring up ScreenLock and ask for
722 // correct password/display error message. 771 // correct password/display error message.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 // Reenable clicking on other windows and status area. 877 // Reenable clicking on other windows and status area.
829 login_display_->SetUIEnabled(true); 878 login_display_->SetUIEnabled(true);
830 login_display_->ShowSigninUI(email); 879 login_display_->ShowSigninUI(email);
831 880
832 if (login_status_consumer_) { 881 if (login_status_consumer_) {
833 login_status_consumer_->OnLoginFailure(LoginFailure( 882 login_status_consumer_->OnLoginFailure(LoginFailure(
834 LoginFailure::WHITELIST_CHECK_FAILED)); 883 LoginFailure::WHITELIST_CHECK_FAILED));
835 } 884 }
836 885
837 display_email_.clear(); 886 display_email_.clear();
887
888 StartPublicSessionAutoLoginTimer();
838 } 889 }
839 890
840 void ExistingUserController::PolicyLoadFailed() { 891 void ExistingUserController::PolicyLoadFailed() {
841 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, ""); 892 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, "");
842 893
843 // Reenable clicking on other windows and status area. 894 // Reenable clicking on other windows and status area.
844 login_display_->SetUIEnabled(true); 895 login_display_->SetUIEnabled(true);
845 896
846 display_email_.clear(); 897 display_email_.clear();
898
899 // Policy load failure stops login attempts -- restart the timer.
900 StartPublicSessionAutoLoginTimer();
847 } 901 }
848 902
849 void ExistingUserController::OnOnlineChecked(const std::string& username, 903 void ExistingUserController::OnOnlineChecked(const std::string& username,
850 bool success) { 904 bool success) {
851 if (success && last_login_attempt_username_ == username) { 905 if (success && last_login_attempt_username_ == username) {
852 online_succeeded_for_ = username; 906 online_succeeded_for_ = username;
853 // Wait for login attempt to end, if it hasn't yet. 907 // Wait for login attempt to end, if it hasn't yet.
854 if (offline_failed_ && !is_login_in_progress_) 908 if (offline_failed_ && !is_login_in_progress_)
855 ShowGaiaPasswordChanged(username); 909 ShowGaiaPasswordChanged(username);
856 } 910 }
857 } 911 }
858 912
859 //////////////////////////////////////////////////////////////////////////////// 913 ////////////////////////////////////////////////////////////////////////////////
860 // ExistingUserController, private: 914 // ExistingUserController, private:
861 915
862 void ExistingUserController::ActivateWizard(const std::string& screen_name) { 916 void ExistingUserController::ActivateWizard(const std::string& screen_name) {
863 DictionaryValue* params = NULL; 917 DictionaryValue* params = NULL;
864 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) { 918 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) {
865 params = new DictionaryValue; 919 params = new DictionaryValue;
866 params->SetString("start_url", guest_mode_url_.spec()); 920 params->SetString("start_url", guest_mode_url_.spec());
867 } 921 }
868 host_->StartWizard(screen_name, params); 922 host_->StartWizard(screen_name, params);
869 } 923 }
870 924
925 void ExistingUserController::ConfigurePublicSessionAutoLogin() {
926 if (!cros_settings_->GetString(
927 kAccountsPrefDeviceLocalAccountAutoLoginId,
928 &public_session_auto_login_username_)) {
929 public_session_auto_login_username_ = "";
930 }
931 if (!cros_settings_->GetInteger(
932 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
933 &public_session_auto_login_delay_)) {
934 public_session_auto_login_delay_ = 0;
935 }
936
937 if (!public_session_auto_login_username_.empty())
938 StartPublicSessionAutoLoginTimer();
939 else
940 StopPublicSessionAutoLoginTimer();
941 }
942
943 void ExistingUserController::ResetPublicSessionAutoLoginTimer() {
944 // Only restart the auto-login timer if it's already running.
945 if (auto_login_timer_ && auto_login_timer_->IsRunning()) {
946 StopPublicSessionAutoLoginTimer();
947 StartPublicSessionAutoLoginTimer();
948 }
949 }
950
951 void ExistingUserController::OnPublicSessionAutoLoginTimerFire() {
952 DCHECK(signin_screen_ready_ &&
Mattias Nissler (ping if slow) 2013/03/01 10:37:21 Make this a check maybe?
dconnelly 2013/03/06 10:02:59 Done.
953 !is_login_in_progress_ &&
954 !public_session_auto_login_username_.empty());
955 LoginAsPublicAccount(public_session_auto_login_username_);
956 }
957
958 void ExistingUserController::StopPublicSessionAutoLoginTimer() {
959 if (auto_login_timer_)
960 auto_login_timer_->Stop();
961 }
962
963 void ExistingUserController::StartPublicSessionAutoLoginTimer() {
964 if (!signin_screen_ready_ ||
965 is_login_in_progress_ ||
966 public_session_auto_login_username_.empty()) {
967 return;
968 }
969
970 // Start the auto-login timer.
971 if (!auto_login_timer_)
972 auto_login_timer_.reset(new base::OneShotTimer<ExistingUserController>);
Nikita (slow) 2013/03/04 15:52:08 nit: Insert one empty line after this one to impro
dconnelly 2013/03/06 10:02:59 Done.
973 auto_login_timer_->Start(
974 FROM_HERE,
975 base::TimeDelta::FromMilliseconds(
976 public_session_auto_login_delay_),
977 base::Bind(
978 &ExistingUserController::OnPublicSessionAutoLoginTimerFire,
979 weak_factory_.GetWeakPtr()));
980 }
981
871 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { 982 gfx::NativeWindow ExistingUserController::GetNativeWindow() const {
872 return host_->GetNativeWindow(); 983 return host_->GetNativeWindow();
873 } 984 }
874 985
875 void ExistingUserController::InitializeStartUrls() const { 986 void ExistingUserController::InitializeStartUrls() const {
876 std::vector<std::string> start_urls; 987 std::vector<std::string> start_urls;
877 988
878 PrefService* prefs = g_browser_process->local_state(); 989 PrefService* prefs = g_browser_process->local_state();
879 const base::ListValue *urls; 990 const base::ListValue *urls;
880 bool show_getstarted_guide = false; 991 bool show_getstarted_guide = false;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 // changed. 1119 // changed.
1009 UserManager::Get()->SaveUserOAuthStatus( 1120 UserManager::Get()->SaveUserOAuthStatus(
1010 username, 1121 username,
1011 User::OAUTH2_TOKEN_STATUS_INVALID); 1122 User::OAUTH2_TOKEN_STATUS_INVALID);
1012 1123
1013 login_display_->SetUIEnabled(true); 1124 login_display_->SetUIEnabled(true);
1014 login_display_->ShowGaiaPasswordChanged(username); 1125 login_display_->ShowGaiaPasswordChanged(username);
1015 } 1126 }
1016 1127
1017 } // namespace chromeos 1128 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698