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

Side by Side Diff: chrome/browser/chromeos/login/existing_user_controller.cc

Issue 1425093004: Revert of This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Created 5 years, 1 month 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
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 base::Bind(&RefreshPoliciesOnUIThread)); 118 base::Bind(&RefreshPoliciesOnUIThread));
119 } 119 }
120 120
121 // Record UMA for password login of regular user when Easy sign-in is enabled. 121 // Record UMA for password login of regular user when Easy sign-in is enabled.
122 void RecordPasswordLoginEvent(const UserContext& user_context) { 122 void RecordPasswordLoginEvent(const UserContext& user_context) {
123 EasyUnlockService* easy_unlock_service = 123 EasyUnlockService* easy_unlock_service =
124 EasyUnlockService::Get(ProfileHelper::GetSigninProfile()); 124 EasyUnlockService::Get(ProfileHelper::GetSigninProfile());
125 if (user_context.GetUserType() == user_manager::USER_TYPE_REGULAR && 125 if (user_context.GetUserType() == user_manager::USER_TYPE_REGULAR &&
126 user_context.GetAuthFlow() == UserContext::AUTH_FLOW_OFFLINE && 126 user_context.GetAuthFlow() == UserContext::AUTH_FLOW_OFFLINE &&
127 easy_unlock_service) { 127 easy_unlock_service) {
128 easy_unlock_service->RecordPasswordLoginEvent( 128 easy_unlock_service->RecordPasswordLoginEvent(user_context.GetUserID());
129 user_context.GetAccountId().GetUserEmail());
130 } 129 }
131 } 130 }
132 131
133 bool CanShowDebuggingFeatures() { 132 bool CanShowDebuggingFeatures() {
134 // We need to be on the login screen and in dev mode to show this menu item. 133 // We need to be on the login screen and in dev mode to show this menu item.
135 return base::CommandLine::ForCurrentProcess()->HasSwitch( 134 return base::CommandLine::ForCurrentProcess()->HasSwitch(
136 chromeos::switches::kSystemDevMode) && 135 chromeos::switches::kSystemDevMode) &&
137 base::CommandLine::ForCurrentProcess()->HasSwitch( 136 base::CommandLine::ForCurrentProcess()->HasSwitch(
138 chromeos::switches::kLoginManager) && 137 chromeos::switches::kLoginManager) &&
139 !user_manager::UserManager::Get()->IsSessionStarted(); 138 !user_manager::UserManager::Get()->IsSessionStarted();
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 weak_factory_.GetWeakPtr(), 348 weak_factory_.GetWeakPtr(),
350 user_context, 349 user_context,
351 specifics)); 350 specifics));
352 } 351 }
353 352
354 void ExistingUserController::PerformLogin( 353 void ExistingUserController::PerformLogin(
355 const UserContext& user_context, 354 const UserContext& user_context,
356 LoginPerformer::AuthorizationMode auth_mode) { 355 LoginPerformer::AuthorizationMode auth_mode) {
357 VLOG(1) << "Setting flow from PerformLogin"; 356 VLOG(1) << "Setting flow from PerformLogin";
358 ChromeUserManager::Get() 357 ChromeUserManager::Get()
359 ->GetUserFlow(user_context.GetAccountId()) 358 ->GetUserFlow(user_context.GetUserID())
360 ->SetHost(host_); 359 ->SetHost(host_);
361 360
362 BootTimesRecorder::Get()->RecordLoginAttempted(); 361 BootTimesRecorder::Get()->RecordLoginAttempted();
363 362
364 // Use the same LoginPerformer for subsequent login as it has state 363 // Use the same LoginPerformer for subsequent login as it has state
365 // such as Authenticator instance. 364 // such as Authenticator instance.
366 if (!login_performer_.get() || num_login_attempts_ <= 1) { 365 if (!login_performer_.get() || num_login_attempts_ <= 1) {
367 // Only one instance of LoginPerformer should exist at a time. 366 // Only one instance of LoginPerformer should exist at a time.
368 login_performer_.reset(NULL); 367 login_performer_.reset(NULL);
369 login_performer_.reset(new ChromeLoginPerformer(this)); 368 login_performer_.reset(new ChromeLoginPerformer(this));
370 } 369 }
371 370
372 if (gaia::ExtractDomainName(user_context.GetAccountId().GetUserEmail()) == 371 if (gaia::ExtractDomainName(user_context.GetUserID()) ==
373 chromeos::login::kSupervisedUserDomain) { 372 chromeos::login::kSupervisedUserDomain) {
374 login_performer_->LoginAsSupervisedUser(user_context); 373 login_performer_->LoginAsSupervisedUser(user_context);
375 } else { 374 } else {
376 login_performer_->PerformLogin(user_context, auth_mode); 375 login_performer_->PerformLogin(user_context, auth_mode);
377 RecordPasswordLoginEvent(user_context); 376 RecordPasswordLoginEvent(user_context);
378 } 377 }
379 SendAccessibilityAlert( 378 SendAccessibilityAlert(
380 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); 379 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN));
381 } 380 }
382 381
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 // ExistingUserController, LoginPerformer::Delegate implementation: 502 // ExistingUserController, LoginPerformer::Delegate implementation:
504 // 503 //
505 504
506 void ExistingUserController::OnAuthFailure(const AuthFailure& failure) { 505 void ExistingUserController::OnAuthFailure(const AuthFailure& failure) {
507 guest_mode_url_ = GURL::EmptyGURL(); 506 guest_mode_url_ = GURL::EmptyGURL();
508 std::string error = failure.GetErrorString(); 507 std::string error = failure.GetErrorString();
509 508
510 PerformLoginFinishedActions(false /* don't start public session timer */); 509 PerformLoginFinishedActions(false /* don't start public session timer */);
511 510
512 if (ChromeUserManager::Get() 511 if (ChromeUserManager::Get()
513 ->GetUserFlow(last_login_attempt_account_id_) 512 ->GetUserFlow(last_login_attempt_username_)
514 ->HandleLoginFailure(failure)) { 513 ->HandleLoginFailure(failure)) {
515 return; 514 return;
516 } 515 }
517 516
518 if (failure.reason() == AuthFailure::OWNER_REQUIRED) { 517 if (failure.reason() == AuthFailure::OWNER_REQUIRED) {
519 ShowError(IDS_LOGIN_ERROR_OWNER_REQUIRED, error); 518 ShowError(IDS_LOGIN_ERROR_OWNER_REQUIRED, error);
520 content::BrowserThread::PostDelayedTask( 519 content::BrowserThread::PostDelayedTask(
521 content::BrowserThread::UI, FROM_HERE, 520 content::BrowserThread::UI, FROM_HERE,
522 base::Bind(&SessionManagerClient::StopSession, 521 base::Bind(&SessionManagerClient::StopSession,
523 base::Unretained(DBusThreadManager::Get()-> 522 base::Unretained(DBusThreadManager::Get()->
524 GetSessionManagerClient())), 523 GetSessionManagerClient())),
525 base::TimeDelta::FromMilliseconds(kSafeModeRestartUiDelayMs)); 524 base::TimeDelta::FromMilliseconds(kSafeModeRestartUiDelayMs));
526 } else if (failure.reason() == AuthFailure::TPM_ERROR) { 525 } else if (failure.reason() == AuthFailure::TPM_ERROR) {
527 ShowTPMError(); 526 ShowTPMError();
528 } else if (last_login_attempt_account_id_ == login::GuestAccountId()) { 527 } else if (last_login_attempt_username_ == chromeos::login::kGuestUserName) {
529 // Show no errors, just re-enable input. 528 // Show no errors, just re-enable input.
530 login_display_->ClearAndEnablePassword(); 529 login_display_->ClearAndEnablePassword();
531 StartPublicSessionAutoLoginTimer(); 530 StartPublicSessionAutoLoginTimer();
532 } else { 531 } else {
533 // Check networking after trying to login in case user is 532 // Check networking after trying to login in case user is
534 // cached locally or the local admin account. 533 // cached locally or the local admin account.
535 const bool is_known_user = user_manager::UserManager::Get()->IsKnownUser( 534 bool is_known_user = user_manager::UserManager::Get()->IsKnownUser(
536 last_login_attempt_account_id_); 535 last_login_attempt_username_);
537 if (!network_state_helper_->IsConnected()) { 536 if (!network_state_helper_->IsConnected()) {
538 if (is_known_user) 537 if (is_known_user)
539 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); 538 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error);
540 else 539 else
541 ShowError(IDS_LOGIN_ERROR_OFFLINE_FAILED_NETWORK_NOT_CONNECTED, error); 540 ShowError(IDS_LOGIN_ERROR_OFFLINE_FAILED_NETWORK_NOT_CONNECTED, error);
542 } else { 541 } else {
543 // TODO(nkostylev): Cleanup rest of ClientLogin related code. 542 // TODO(nkostylev): Cleanup rest of ClientLogin related code.
544 if (failure.reason() == AuthFailure::NETWORK_AUTH_FAILED && 543 if (failure.reason() == AuthFailure::NETWORK_AUTH_FAILED &&
545 failure.error().state() == 544 failure.error().state() ==
546 GoogleServiceAuthError::HOSTED_NOT_ALLOWED) { 545 GoogleServiceAuthError::HOSTED_NOT_ALLOWED) {
547 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); 546 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error);
548 } else { 547 } else {
549 if (!is_known_user) 548 if (!is_known_user)
550 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); 549 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error);
551 else 550 else
552 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); 551 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error);
553 } 552 }
554 } 553 }
555 login_display_->ClearAndEnablePassword(); 554 login_display_->ClearAndEnablePassword();
556 StartPublicSessionAutoLoginTimer(); 555 StartPublicSessionAutoLoginTimer();
557 } 556 }
558 557
559 // Reset user flow to default, so that special flow will not affect next 558 // Reset user flow to default, so that special flow will not affect next
560 // attempt. 559 // attempt.
561 ChromeUserManager::Get()->ResetUserFlow(last_login_attempt_account_id_); 560 ChromeUserManager::Get()->ResetUserFlow(last_login_attempt_username_);
562 561
563 if (auth_status_consumer_) 562 if (auth_status_consumer_)
564 auth_status_consumer_->OnAuthFailure(failure); 563 auth_status_consumer_->OnAuthFailure(failure);
565 564
566 // Clear the recorded displayed email so it won't affect any future attempts. 565 // Clear the recorded displayed email so it won't affect any future attempts.
567 display_email_.clear(); 566 display_email_.clear();
568 567
569 // TODO(ginkage): Fix this case once crbug.com/469990 is ready. 568 // TODO(ginkage): Fix this case once crbug.com/469990 is ready.
570 /* 569 /*
571 if (failure.reason() == AuthFailure::COULD_NOT_MOUNT_CRYPTOHOME) { 570 if (failure.reason() == AuthFailure::COULD_NOT_MOUNT_CRYPTOHOME) {
572 RecordReauthReason(last_login_attempt_account_id_, 571 RecordReauthReason(last_login_attempt_username_,
573 ReauthReason::MISSING_CRYPTOHOME); 572 ReauthReason::MISSING_CRYPTOHOME);
574 } 573 }
575 */ 574 */
576 } 575 }
577 576
578 void ExistingUserController::OnAuthSuccess(const UserContext& user_context) { 577 void ExistingUserController::OnAuthSuccess(const UserContext& user_context) {
579 is_login_in_progress_ = false; 578 is_login_in_progress_ = false;
580 login_display_->set_signin_completed(true); 579 login_display_->set_signin_completed(true);
581 580
582 // Login performer will be gone so cache this value to use 581 // Login performer will be gone so cache this value to use
583 // once profile is loaded. 582 // once profile is loaded.
584 password_changed_ = login_performer_->password_changed(); 583 password_changed_ = login_performer_->password_changed();
585 auth_mode_ = login_performer_->auth_mode(); 584 auth_mode_ = login_performer_->auth_mode();
586 585
587 ChromeUserManager::Get() 586 ChromeUserManager::Get()
588 ->GetUserFlow(user_context.GetAccountId()) 587 ->GetUserFlow(user_context.GetUserID())
589 ->HandleLoginSuccess(user_context); 588 ->HandleLoginSuccess(user_context);
590 589
591 StopPublicSessionAutoLoginTimer(); 590 StopPublicSessionAutoLoginTimer();
592 591
593 // Truth table of |has_auth_cookies|: 592 // Truth table of |has_auth_cookies|:
594 // Regular SAML 593 // Regular SAML
595 // /ServiceLogin T T 594 // /ServiceLogin T T
596 // /ChromeOsEmbeddedSetup F T 595 // /ChromeOsEmbeddedSetup F T
597 // Bootstrap experiment F N/A 596 // Bootstrap experiment F N/A
598 const bool has_auth_cookies = 597 const bool has_auth_cookies =
(...skipping 11 matching lines...) Expand all
610 ? UserSessionManager::SECONDARY_USER_SESSION 609 ? UserSessionManager::SECONDARY_USER_SESSION
611 : UserSessionManager::PRIMARY_USER_SESSION; 610 : UserSessionManager::PRIMARY_USER_SESSION;
612 UserSessionManager::GetInstance()->StartSession( 611 UserSessionManager::GetInstance()->StartSession(
613 user_context, start_session_type, has_auth_cookies, 612 user_context, start_session_type, has_auth_cookies,
614 false, // Start session for user. 613 false, // Start session for user.
615 this); 614 this);
616 615
617 // Update user's displayed email. 616 // Update user's displayed email.
618 if (!display_email_.empty()) { 617 if (!display_email_.empty()) {
619 user_manager::UserManager::Get()->SaveUserDisplayEmail( 618 user_manager::UserManager::Get()->SaveUserDisplayEmail(
620 user_context.GetAccountId(), display_email_); 619 user_context.GetUserID(), display_email_);
621 display_email_.clear(); 620 display_email_.clear();
622 } 621 }
623 } 622 }
624 623
625 void ExistingUserController::OnProfilePrepared(Profile* profile, 624 void ExistingUserController::OnProfilePrepared(Profile* profile,
626 bool browser_launched) { 625 bool browser_launched) {
627 // Reenable clicking on other windows and status area. 626 // Reenable clicking on other windows and status area.
628 login_display_->SetUIEnabled(true); 627 login_display_->SetUIEnabled(true);
629 628
630 if (browser_launched) 629 if (browser_launched)
631 host_ = NULL; 630 host_ = NULL;
632 631
633 // Inform |auth_status_consumer_| about successful login. 632 // Inform |auth_status_consumer_| about successful login.
634 // TODO(nkostylev): Pass UserContext back crbug.com/424550 633 // TODO(nkostylev): Pass UserContext back crbug.com/424550
635 if (auth_status_consumer_) { 634 if (auth_status_consumer_) {
636 auth_status_consumer_->OnAuthSuccess( 635 auth_status_consumer_->
637 UserContext(last_login_attempt_account_id_)); 636 OnAuthSuccess(UserContext(last_login_attempt_username_));
638 } 637 }
639 } 638 }
640 639
641 void ExistingUserController::OnOffTheRecordAuthSuccess() { 640 void ExistingUserController::OnOffTheRecordAuthSuccess() {
642 is_login_in_progress_ = false; 641 is_login_in_progress_ = false;
643 642
644 // Mark the device as registered., i.e. the second part of OOBE as completed. 643 // Mark the device as registered., i.e. the second part of OOBE as completed.
645 if (!StartupUtils::IsDeviceRegistered()) 644 if (!StartupUtils::IsDeviceRegistered())
646 StartupUtils::MarkDeviceRegistered(base::Closure()); 645 StartupUtils::MarkDeviceRegistered(base::Closure());
647 646
648 UserSessionManager::GetInstance()->CompleteGuestSessionLogin(guest_mode_url_); 647 UserSessionManager::GetInstance()->CompleteGuestSessionLogin(guest_mode_url_);
649 648
650 if (auth_status_consumer_) 649 if (auth_status_consumer_)
651 auth_status_consumer_->OnOffTheRecordAuthSuccess(); 650 auth_status_consumer_->OnOffTheRecordAuthSuccess();
652 } 651 }
653 652
654 void ExistingUserController::OnPasswordChangeDetected() { 653 void ExistingUserController::OnPasswordChangeDetected() {
655 is_login_in_progress_ = false; 654 is_login_in_progress_ = false;
656 655
657 // Must not proceed without signature verification. 656 // Must not proceed without signature verification.
658 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues( 657 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues(
659 base::Bind(&ExistingUserController::OnPasswordChangeDetected, 658 base::Bind(&ExistingUserController::OnPasswordChangeDetected,
660 weak_factory_.GetWeakPtr()))) { 659 weak_factory_.GetWeakPtr()))) {
661 // Value of owner email is still not verified. 660 // Value of owner email is still not verified.
662 // Another attempt will be invoked after verification completion. 661 // Another attempt will be invoked after verification completion.
663 return; 662 return;
664 } 663 }
665 664
666 if (ChromeUserManager::Get() 665 if (ChromeUserManager::Get()
667 ->GetUserFlow(last_login_attempt_account_id_) 666 ->GetUserFlow(last_login_attempt_username_)
668 ->HandlePasswordChangeDetected()) { 667 ->HandlePasswordChangeDetected()) {
669 return; 668 return;
670 } 669 }
671 670
672 // True if user has already made an attempt to enter old password and failed. 671 // True if user has already made an attempt to enter old password and failed.
673 bool show_invalid_old_password_error = 672 bool show_invalid_old_password_error =
674 login_performer_->password_changed_callback_count() > 1; 673 login_performer_->password_changed_callback_count() > 1;
675 674
676 // Note: We allow owner using "full sync" mode which will recreate 675 // Note: We allow owner using "full sync" mode which will recreate
677 // cryptohome and deal with owner private key being lost. This also allows 676 // cryptohome and deal with owner private key being lost. This also allows
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); 753 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD));
755 } 754 }
756 755
757 void ExistingUserController::LoginAsPublicSession( 756 void ExistingUserController::LoginAsPublicSession(
758 const UserContext& user_context) { 757 const UserContext& user_context) {
759 PerformPreLoginActions(user_context); 758 PerformPreLoginActions(user_context);
760 759
761 // If there is no public account with the given user ID, logging in is not 760 // If there is no public account with the given user ID, logging in is not
762 // possible. 761 // possible.
763 const user_manager::User* user = 762 const user_manager::User* user =
764 user_manager::UserManager::Get()->FindUser(user_context.GetAccountId()); 763 user_manager::UserManager::Get()->FindUser(user_context.GetUserID());
765 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) { 764 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) {
766 PerformLoginFinishedActions(true /* start public session timer */); 765 PerformLoginFinishedActions(true /* start public session timer */);
767 return; 766 return;
768 } 767 }
769 768
770 UserContext new_user_context = user_context; 769 UserContext new_user_context = user_context;
771 std::string locale = user_context.GetPublicSessionLocale(); 770 std::string locale = user_context.GetPublicSessionLocale();
772 if (locale.empty()) { 771 if (locale.empty()) {
773 // When performing auto-login, no locale is chosen by the user. Check 772 // When performing auto-login, no locale is chosen by the user. Check
774 // whether a list of recommended locales was set by policy. If so, use its 773 // whether a list of recommended locales was set by policy. If so, use its
775 // first entry. Otherwise, |locale| will remain blank, indicating that the 774 // first entry. Otherwise, |locale| will remain blank, indicating that the
776 // public session should use the current UI locale. 775 // public session should use the current UI locale.
777 const policy::PolicyMap::Entry* entry = 776 const policy::PolicyMap::Entry* entry = g_browser_process->platform_part()->
778 g_browser_process->platform_part() 777 browser_policy_connector_chromeos()->
779 ->browser_policy_connector_chromeos() 778 GetDeviceLocalAccountPolicyService()->
780 ->GetDeviceLocalAccountPolicyService() 779 GetBrokerForUser(user_context.GetUserID())->core()->store()->
781 ->GetBrokerForUser(user_context.GetAccountId().GetUserEmail()) 780 policy_map().Get(policy::key::kSessionLocales);
782 ->core()
783 ->store()
784 ->policy_map()
785 .Get(policy::key::kSessionLocales);
786 base::ListValue const* list = NULL; 781 base::ListValue const* list = NULL;
787 if (entry && 782 if (entry &&
788 entry->level == policy::POLICY_LEVEL_RECOMMENDED && 783 entry->level == policy::POLICY_LEVEL_RECOMMENDED &&
789 entry->value && 784 entry->value &&
790 entry->value->GetAsList(&list)) { 785 entry->value->GetAsList(&list)) {
791 if (list->GetString(0, &locale)) 786 if (list->GetString(0, &locale))
792 new_user_context.SetPublicSessionLocale(locale); 787 new_user_context.SetPublicSessionLocale(locale);
793 } 788 }
794 } 789 }
795 790
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 for (std::vector<policy::DeviceLocalAccount>::const_iterator 836 for (std::vector<policy::DeviceLocalAccount>::const_iterator
842 it = device_local_accounts.begin(); 837 it = device_local_accounts.begin();
843 it != device_local_accounts.end(); ++it) { 838 it != device_local_accounts.end(); ++it) {
844 if (it->account_id == auto_login_account_id) { 839 if (it->account_id == auto_login_account_id) {
845 public_session_auto_login_username_ = it->user_id; 840 public_session_auto_login_username_ = it->user_id;
846 break; 841 break;
847 } 842 }
848 } 843 }
849 844
850 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( 845 const user_manager::User* user = user_manager::UserManager::Get()->FindUser(
851 AccountId::FromUserEmail(public_session_auto_login_username_)); 846 public_session_auto_login_username_);
852 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) 847 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT)
853 public_session_auto_login_username_.clear(); 848 public_session_auto_login_username_.clear();
854 849
855 if (!cros_settings_->GetInteger( 850 if (!cros_settings_->GetInteger(
856 kAccountsPrefDeviceLocalAccountAutoLoginDelay, 851 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
857 &public_session_auto_login_delay_)) { 852 &public_session_auto_login_delay_)) {
858 public_session_auto_login_delay_ = 0; 853 public_session_auto_login_delay_ = 0;
859 } 854 }
860 855
861 if (!public_session_auto_login_username_.empty()) 856 if (!public_session_auto_login_username_.empty())
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 } else { 922 } else {
928 // login_performer_ will be null if an error occurred during OAuth2 token 923 // login_performer_ will be null if an error occurred during OAuth2 token
929 // fetch. In this case, show a generic error. 924 // fetch. In this case, show a generic error.
930 help_topic_id = HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT; 925 help_topic_id = HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT;
931 } 926 }
932 927
933 if (error_id == IDS_LOGIN_ERROR_AUTHENTICATING) { 928 if (error_id == IDS_LOGIN_ERROR_AUTHENTICATING) {
934 if (num_login_attempts_ > 1) { 929 if (num_login_attempts_ > 1) {
935 const user_manager::User* user = 930 const user_manager::User* user =
936 user_manager::UserManager::Get()->FindUser( 931 user_manager::UserManager::Get()->FindUser(
937 last_login_attempt_account_id_); 932 last_login_attempt_username_);
938 if (user && (user->GetType() == user_manager::USER_TYPE_SUPERVISED)) 933 if (user && (user->GetType() == user_manager::USER_TYPE_SUPERVISED))
939 error_id = IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME_SUPERVISED; 934 error_id = IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME_SUPERVISED;
940 } 935 }
941 } 936 }
942 937
943 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id); 938 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id);
944 } 939 }
945 940
946 void ExistingUserController::SendAccessibilityAlert( 941 void ExistingUserController::SendAccessibilityAlert(
947 const std::string& alert_text) { 942 const std::string& alert_text) {
(...skipping 30 matching lines...) Expand all
978 login_performer_->LoginAsPublicSession(user_context); 973 login_performer_->LoginAsPublicSession(user_context);
979 SendAccessibilityAlert( 974 SendAccessibilityAlert(
980 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); 975 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT));
981 } 976 }
982 977
983 void ExistingUserController::PerformPreLoginActions( 978 void ExistingUserController::PerformPreLoginActions(
984 const UserContext& user_context) { 979 const UserContext& user_context) {
985 // Disable clicking on other windows and status tray. 980 // Disable clicking on other windows and status tray.
986 login_display_->SetUIEnabled(false); 981 login_display_->SetUIEnabled(false);
987 982
988 if (last_login_attempt_account_id_ != user_context.GetAccountId()) { 983 if (last_login_attempt_username_ != user_context.GetUserID()) {
989 last_login_attempt_account_id_ = user_context.GetAccountId(); 984 last_login_attempt_username_ = user_context.GetUserID();
990 num_login_attempts_ = 0; 985 num_login_attempts_ = 0;
991 } 986 }
992 987
993 // Guard in cases when we're called twice but login process is still active. 988 // Guard in cases when we're called twice but login process is still active.
994 // This might happen when login process is paused till signed settings status 989 // This might happen when login process is paused till signed settings status
995 // is verified which results in Login* method called again as a callback. 990 // is verified which results in Login* method called again as a callback.
996 if (!is_login_in_progress_) 991 if (!is_login_in_progress_)
997 num_login_attempts_++; 992 num_login_attempts_++;
998 993
999 is_login_in_progress_ = true; 994 is_login_in_progress_ = true;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 } 1054 }
1060 1055
1061 continuation.Run(); 1056 continuation.Run();
1062 } 1057 }
1063 1058
1064 void ExistingUserController::DoCompleteLogin( 1059 void ExistingUserController::DoCompleteLogin(
1065 const UserContext& user_context_wo_device_id) { 1060 const UserContext& user_context_wo_device_id) {
1066 UserContext user_context = user_context_wo_device_id; 1061 UserContext user_context = user_context_wo_device_id;
1067 std::string device_id = 1062 std::string device_id =
1068 user_manager::UserManager::Get()->GetKnownUserDeviceId( 1063 user_manager::UserManager::Get()->GetKnownUserDeviceId(
1069 user_context.GetAccountId()); 1064 user_context.GetUserID());
1070 if (device_id.empty()) { 1065 if (device_id.empty()) {
1071 bool is_ephemeral = ChromeUserManager::Get()->AreEphemeralUsersEnabled() && 1066 bool is_ephemeral =
1072 user_context.GetAccountId() != 1067 ChromeUserManager::Get()->AreEphemeralUsersEnabled() &&
1073 ChromeUserManager::Get()->GetOwnerAccountId(); 1068 user_context.GetUserID() != ChromeUserManager::Get()->GetOwnerEmail();
1074 device_id = SigninClient::GenerateSigninScopedDeviceID(is_ephemeral); 1069 device_id = SigninClient::GenerateSigninScopedDeviceID(is_ephemeral);
1075 } 1070 }
1076 user_context.SetDeviceId(device_id); 1071 user_context.SetDeviceId(device_id);
1077 1072
1078 const std::string& gaps_cookie = user_context.GetGAPSCookie(); 1073 const std::string& gaps_cookie = user_context.GetGAPSCookie();
1079 if (!gaps_cookie.empty()) { 1074 if (!gaps_cookie.empty()) {
1080 user_manager::UserManager::Get()->SetKnownUserGAPSCookie( 1075 user_manager::UserManager::Get()->SetKnownUserGAPSCookie(
1081 user_context.GetAccountId(), gaps_cookie); 1076 user_context.GetUserID(), gaps_cookie);
1082 } 1077 }
1083 1078
1084 PerformPreLoginActions(user_context); 1079 PerformPreLoginActions(user_context);
1085 1080
1086 if (!time_init_.is_null()) { 1081 if (!time_init_.is_null()) {
1087 base::TimeDelta delta = base::Time::Now() - time_init_; 1082 base::TimeDelta delta = base::Time::Now() - time_init_;
1088 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta); 1083 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta);
1089 time_init_ = base::Time(); // Reset to null. 1084 time_init_ = base::Time(); // Reset to null.
1090 } 1085 }
1091 1086
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 LoginAsGuest(); 1138 LoginAsGuest();
1144 return; 1139 return;
1145 } 1140 }
1146 1141
1147 if (user_context.GetUserType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT) { 1142 if (user_context.GetUserType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT) {
1148 LoginAsPublicSession(user_context); 1143 LoginAsPublicSession(user_context);
1149 return; 1144 return;
1150 } 1145 }
1151 1146
1152 if (user_context.GetUserType() == user_manager::USER_TYPE_KIOSK_APP) { 1147 if (user_context.GetUserType() == user_manager::USER_TYPE_KIOSK_APP) {
1153 LoginAsKioskApp(user_context.GetAccountId().GetUserEmail(), 1148 LoginAsKioskApp(user_context.GetUserID(), specifics.kiosk_diagnostic_mode);
1154 specifics.kiosk_diagnostic_mode);
1155 return; 1149 return;
1156 } 1150 }
1157 1151
1158 // Regular user or supervised user login. 1152 // Regular user or supervised user login.
1159 1153
1160 if (!user_context.HasCredentials()) { 1154 if (!user_context.HasCredentials()) {
1161 // If credentials are missing, refuse to log in. 1155 // If credentials are missing, refuse to log in.
1162 1156
1163 // Reenable clicking on other windows and status area. 1157 // Reenable clicking on other windows and status area.
1164 login_display_->SetUIEnabled(true); 1158 login_display_->SetUIEnabled(true);
(...skipping 10 matching lines...) Expand all
1175 const UserContext& user_context) { 1169 const UserContext& user_context) {
1176 if (!success) { 1170 if (!success) {
1177 LOG(ERROR) << "Easy bootstrap failed."; 1171 LOG(ERROR) << "Easy bootstrap failed.";
1178 OnAuthFailure(AuthFailure(AuthFailure::NETWORK_AUTH_FAILED)); 1172 OnAuthFailure(AuthFailure(AuthFailure::NETWORK_AUTH_FAILED));
1179 return; 1173 return;
1180 } 1174 }
1181 1175
1182 // Setting a customized login user flow to perform additional initializations 1176 // Setting a customized login user flow to perform additional initializations
1183 // for bootstrap after the user session is started. 1177 // for bootstrap after the user session is started.
1184 ChromeUserManager::Get()->SetUserFlow( 1178 ChromeUserManager::Get()->SetUserFlow(
1185 user_context.GetAccountId(), 1179 user_context.GetUserID(),
1186 new BootstrapUserFlow( 1180 new BootstrapUserFlow(
1187 user_context, 1181 user_context,
1188 bootstrap_user_context_initializer_->random_key_used())); 1182 bootstrap_user_context_initializer_->random_key_used()));
1189 1183
1190 PerformLogin(user_context, LoginPerformer::AUTH_MODE_EXTENSION); 1184 PerformLogin(user_context, LoginPerformer::AUTH_MODE_EXTENSION);
1191 } 1185 }
1192 1186
1193 void ExistingUserController::OnOAuth2TokensFetched( 1187 void ExistingUserController::OnOAuth2TokensFetched(
1194 bool success, 1188 bool success,
1195 const UserContext& user_context) { 1189 const UserContext& user_context) {
1196 if (!success) { 1190 if (!success) {
1197 LOG(ERROR) << "OAuth2 token fetch failed."; 1191 LOG(ERROR) << "OAuth2 token fetch failed.";
1198 OnAuthFailure(AuthFailure(AuthFailure::FAILED_TO_INITIALIZE_TOKEN)); 1192 OnAuthFailure(AuthFailure(AuthFailure::FAILED_TO_INITIALIZE_TOKEN));
1199 return; 1193 return;
1200 } 1194 }
1201 UserSessionManager::GetInstance()->OnOAuth2TokensFetched(user_context); 1195 UserSessionManager::GetInstance()->OnOAuth2TokensFetched(user_context);
1202 PerformLogin(user_context, LoginPerformer::AUTH_MODE_EXTENSION); 1196 PerformLogin(user_context, LoginPerformer::AUTH_MODE_EXTENSION);
1203 } 1197 }
1204 1198
1205 } // namespace chromeos 1199 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698