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