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

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

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

Powered by Google App Engine
This is Rietveld 408576698