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 <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 kAccountsPrefSupervisedUsersEnabled, | 202 kAccountsPrefSupervisedUsersEnabled, |
| 203 base::Bind(&ExistingUserController::DeviceSettingsChanged, | 203 base::Bind(&ExistingUserController::DeviceSettingsChanged, |
| 204 base::Unretained(this))); | 204 base::Unretained(this))); |
| 205 users_subscription_ = cros_settings_->AddSettingsObserver( | 205 users_subscription_ = cros_settings_->AddSettingsObserver( |
| 206 kAccountsPrefUsers, | 206 kAccountsPrefUsers, |
| 207 base::Bind(&ExistingUserController::DeviceSettingsChanged, | 207 base::Bind(&ExistingUserController::DeviceSettingsChanged, |
| 208 base::Unretained(this))); | 208 base::Unretained(this))); |
| 209 local_account_auto_login_id_subscription_ = | 209 local_account_auto_login_id_subscription_ = |
| 210 cros_settings_->AddSettingsObserver( | 210 cros_settings_->AddSettingsObserver( |
| 211 kAccountsPrefDeviceLocalAccountAutoLoginId, | 211 kAccountsPrefDeviceLocalAccountAutoLoginId, |
| 212 base::Bind(&ExistingUserController::ConfigurePublicSessionAutoLogin, | 212 base::Bind(&ExistingUserController::ConfigureAutoLogin, |
| 213 base::Unretained(this))); | 213 base::Unretained(this))); |
| 214 local_account_auto_login_delay_subscription_ = | 214 local_account_auto_login_delay_subscription_ = |
| 215 cros_settings_->AddSettingsObserver( | 215 cros_settings_->AddSettingsObserver( |
| 216 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | 216 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
| 217 base::Bind(&ExistingUserController::ConfigurePublicSessionAutoLogin, | 217 base::Bind(&ExistingUserController::ConfigureAutoLogin, |
| 218 base::Unretained(this))); | 218 base::Unretained(this))); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void ExistingUserController::Init(const user_manager::UserList& users) { | 221 void ExistingUserController::Init(const user_manager::UserList& users) { |
| 222 time_init_ = base::Time::Now(); | 222 time_init_ = base::Time::Now(); |
| 223 UpdateLoginDisplay(users); | 223 UpdateLoginDisplay(users); |
| 224 ConfigurePublicSessionAutoLogin(); | 224 ConfigureAutoLogin(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void ExistingUserController::UpdateLoginDisplay( | 227 void ExistingUserController::UpdateLoginDisplay( |
| 228 const user_manager::UserList& users) { | 228 const user_manager::UserList& users) { |
| 229 bool show_users_on_signin; | 229 bool show_users_on_signin; |
| 230 user_manager::UserList filtered_users; | 230 user_manager::UserList filtered_users; |
| 231 | 231 |
| 232 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, | 232 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, |
| 233 &show_users_on_signin); | 233 &show_users_on_signin); |
| 234 for (auto* user : users) { | 234 for (auto* user : users) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 content::BrowserThread::PostDelayedTask( | 315 content::BrowserThread::PostDelayedTask( |
| 316 content::BrowserThread::IO, FROM_HERE, | 316 content::BrowserThread::IO, FROM_HERE, |
| 317 base::Bind(&TransferContextAuthenticationsOnIOThread, | 317 base::Bind(&TransferContextAuthenticationsOnIOThread, |
| 318 base::RetainedRef(signin_profile_context_getter), | 318 base::RetainedRef(signin_profile_context_getter), |
| 319 base::RetainedRef(browser_process_context_getter)), | 319 base::RetainedRef(browser_process_context_getter)), |
| 320 base::TimeDelta::FromMilliseconds(kAuthCacheTransferDelayMs)); | 320 base::TimeDelta::FromMilliseconds(kAuthCacheTransferDelayMs)); |
| 321 } | 321 } |
| 322 } | 322 } |
| 323 | 323 |
| 324 //////////////////////////////////////////////////////////////////////////////// | 324 //////////////////////////////////////////////////////////////////////////////// |
| 325 // ExistingUserController, ArcKioskAppManager::ArcKioskAppManagerObserver | |
| 326 // implementation: | |
| 327 // | |
| 328 | |
| 329 void ExistingUserController::OnArcKioskAppsChanged() { | |
| 330 ConfigureAutoLogin(); | |
| 331 } | |
| 332 //////////////////////////////////////////////////////////////////////////////// | |
| 325 // ExistingUserController, private: | 333 // ExistingUserController, private: |
| 326 | 334 |
| 327 ExistingUserController::~ExistingUserController() { | 335 ExistingUserController::~ExistingUserController() { |
| 328 UserSessionManager::GetInstance()->DelegateDeleted(this); | 336 UserSessionManager::GetInstance()->DelegateDeleted(this); |
| 329 | 337 |
| 330 if (current_controller_ == this) { | 338 if (current_controller_ == this) { |
| 331 current_controller_ = nullptr; | 339 current_controller_ = nullptr; |
| 332 } else { | 340 } else { |
| 333 NOTREACHED() << "More than one controller are alive."; | 341 NOTREACHED() << "More than one controller are alive."; |
| 334 } | 342 } |
| 335 DCHECK(login_display_.get()); | 343 DCHECK(login_display_.get()); |
| 336 } | 344 } |
| 337 | 345 |
| 338 //////////////////////////////////////////////////////////////////////////////// | 346 //////////////////////////////////////////////////////////////////////////////// |
| 339 // ExistingUserController, LoginDisplay::Delegate implementation: | 347 // ExistingUserController, LoginDisplay::Delegate implementation: |
| 340 // | 348 // |
| 341 | 349 |
| 342 void ExistingUserController::CancelPasswordChangedFlow() { | 350 void ExistingUserController::CancelPasswordChangedFlow() { |
| 343 login_performer_.reset(nullptr); | 351 login_performer_.reset(nullptr); |
| 344 PerformLoginFinishedActions(true /* start public session timer */); | 352 PerformLoginFinishedActions(true /* start auto login timer */); |
| 345 } | 353 } |
| 346 | 354 |
| 347 void ExistingUserController::CompleteLogin(const UserContext& user_context) { | 355 void ExistingUserController::CompleteLogin(const UserContext& user_context) { |
| 348 if (!host_) { | 356 if (!host_) { |
| 349 // Complete login event was generated already from UI. Ignore notification. | 357 // Complete login event was generated already from UI. Ignore notification. |
| 350 return; | 358 return; |
| 351 } | 359 } |
| 352 | 360 |
| 353 if (is_login_in_progress_) | 361 if (is_login_in_progress_) |
| 354 return; | 362 return; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 | 435 |
| 428 void ExistingUserController::MigrateUserData(const std::string& old_password) { | 436 void ExistingUserController::MigrateUserData(const std::string& old_password) { |
| 429 // LoginPerformer instance has state of the user so it should exist. | 437 // LoginPerformer instance has state of the user so it should exist. |
| 430 if (login_performer_.get()) { | 438 if (login_performer_.get()) { |
| 431 VLOG(1) << "Migrate the existing cryptohome to new password."; | 439 VLOG(1) << "Migrate the existing cryptohome to new password."; |
| 432 login_performer_->RecoverEncryptedData(old_password); | 440 login_performer_->RecoverEncryptedData(old_password); |
| 433 } | 441 } |
| 434 } | 442 } |
| 435 | 443 |
| 436 void ExistingUserController::OnSigninScreenReady() { | 444 void ExistingUserController::OnSigninScreenReady() { |
| 437 signin_screen_ready_ = true; | 445 auto_launch_ready_ = true; |
| 438 StartPublicSessionAutoLoginTimer(); | 446 StartAutoLoginTimer(); |
|
Nikita (slow)
2016/11/18 17:09:35
Both OnGaiaScreenReady and OnSigninScreenReady() m
Sergey Poromov
2016/11/18 18:56:11
Done.
| |
| 447 } | |
| 448 | |
| 449 void ExistingUserController::OnGaiaScreenReady() { | |
| 450 auto_launch_ready_ = true; | |
| 451 StartAutoLoginTimer(); | |
| 439 } | 452 } |
| 440 | 453 |
| 441 void ExistingUserController::OnStartEnterpriseEnrollment() { | 454 void ExistingUserController::OnStartEnterpriseEnrollment() { |
| 442 if (KioskAppManager::Get()->IsConsumerKioskDeviceWithAutoLaunch()) { | 455 if (KioskAppManager::Get()->IsConsumerKioskDeviceWithAutoLaunch()) { |
| 443 LOG(WARNING) << "Enterprise enrollment is not available after kiosk auto " | 456 LOG(WARNING) << "Enterprise enrollment is not available after kiosk auto " |
| 444 "launch is set."; | 457 "launch is set."; |
| 445 return; | 458 return; |
| 446 } | 459 } |
| 447 | 460 |
| 448 DeviceSettingsService::Get()->GetOwnershipStatusAsync( | 461 DeviceSettingsService::Get()->GetOwnershipStatusAsync( |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 568 } | 581 } |
| 569 | 582 |
| 570 //////////////////////////////////////////////////////////////////////////////// | 583 //////////////////////////////////////////////////////////////////////////////// |
| 571 // ExistingUserController, LoginPerformer::Delegate implementation: | 584 // ExistingUserController, LoginPerformer::Delegate implementation: |
| 572 // | 585 // |
| 573 | 586 |
| 574 void ExistingUserController::OnAuthFailure(const AuthFailure& failure) { | 587 void ExistingUserController::OnAuthFailure(const AuthFailure& failure) { |
| 575 guest_mode_url_ = GURL::EmptyGURL(); | 588 guest_mode_url_ = GURL::EmptyGURL(); |
| 576 std::string error = failure.GetErrorString(); | 589 std::string error = failure.GetErrorString(); |
| 577 | 590 |
| 578 PerformLoginFinishedActions(false /* don't start public session timer */); | 591 PerformLoginFinishedActions(false /* don't start auto login timer */); |
| 579 | 592 |
| 580 if (ChromeUserManager::Get() | 593 if (ChromeUserManager::Get() |
| 581 ->GetUserFlow(last_login_attempt_account_id_) | 594 ->GetUserFlow(last_login_attempt_account_id_) |
| 582 ->HandleLoginFailure(failure)) { | 595 ->HandleLoginFailure(failure)) { |
| 583 return; | 596 return; |
| 584 } | 597 } |
| 585 | 598 |
| 586 if (failure.reason() == AuthFailure::OWNER_REQUIRED) { | 599 if (failure.reason() == AuthFailure::OWNER_REQUIRED) { |
| 587 ShowError(IDS_LOGIN_ERROR_OWNER_REQUIRED, error); | 600 ShowError(IDS_LOGIN_ERROR_OWNER_REQUIRED, error); |
| 588 content::BrowserThread::PostDelayedTask( | 601 content::BrowserThread::PostDelayedTask( |
| 589 content::BrowserThread::UI, FROM_HERE, | 602 content::BrowserThread::UI, FROM_HERE, |
| 590 base::Bind(&SessionManagerClient::StopSession, | 603 base::Bind(&SessionManagerClient::StopSession, |
| 591 base::Unretained(DBusThreadManager::Get()-> | 604 base::Unretained(DBusThreadManager::Get()-> |
| 592 GetSessionManagerClient())), | 605 GetSessionManagerClient())), |
| 593 base::TimeDelta::FromMilliseconds(kSafeModeRestartUiDelayMs)); | 606 base::TimeDelta::FromMilliseconds(kSafeModeRestartUiDelayMs)); |
| 594 } else if (failure.reason() == AuthFailure::TPM_ERROR) { | 607 } else if (failure.reason() == AuthFailure::TPM_ERROR) { |
| 595 ShowTPMError(); | 608 ShowTPMError(); |
| 596 } else if (last_login_attempt_account_id_ == user_manager::GuestAccountId()) { | 609 } else if (last_login_attempt_account_id_ == user_manager::GuestAccountId()) { |
| 597 // Show no errors, just re-enable input. | 610 // Show no errors, just re-enable input. |
| 598 login_display_->ClearAndEnablePassword(); | 611 login_display_->ClearAndEnablePassword(); |
| 599 StartPublicSessionAutoLoginTimer(); | 612 StartAutoLoginTimer(); |
| 600 } else { | 613 } else { |
| 601 // Check networking after trying to login in case user is | 614 // Check networking after trying to login in case user is |
| 602 // cached locally or the local admin account. | 615 // cached locally or the local admin account. |
| 603 const bool is_known_user = user_manager::UserManager::Get()->IsKnownUser( | 616 const bool is_known_user = user_manager::UserManager::Get()->IsKnownUser( |
| 604 last_login_attempt_account_id_); | 617 last_login_attempt_account_id_); |
| 605 if (!network_state_helper_->IsConnected()) { | 618 if (!network_state_helper_->IsConnected()) { |
| 606 if (is_known_user) | 619 if (is_known_user) |
| 607 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); | 620 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); |
| 608 else | 621 else |
| 609 ShowError(IDS_LOGIN_ERROR_OFFLINE_FAILED_NETWORK_NOT_CONNECTED, error); | 622 ShowError(IDS_LOGIN_ERROR_OFFLINE_FAILED_NETWORK_NOT_CONNECTED, error); |
| 610 } else { | 623 } else { |
| 611 // TODO(nkostylev): Cleanup rest of ClientLogin related code. | 624 // TODO(nkostylev): Cleanup rest of ClientLogin related code. |
| 612 if (!is_known_user) | 625 if (!is_known_user) |
| 613 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); | 626 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); |
| 614 else | 627 else |
| 615 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); | 628 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); |
| 616 } | 629 } |
| 617 if (auth_flow_offline_) | 630 if (auth_flow_offline_) |
| 618 UMA_HISTOGRAM_BOOLEAN("Login.OfflineFailure.IsKnownUser", is_known_user); | 631 UMA_HISTOGRAM_BOOLEAN("Login.OfflineFailure.IsKnownUser", is_known_user); |
| 619 | 632 |
| 620 login_display_->ClearAndEnablePassword(); | 633 login_display_->ClearAndEnablePassword(); |
| 621 StartPublicSessionAutoLoginTimer(); | 634 StartAutoLoginTimer(); |
| 622 } | 635 } |
| 623 | 636 |
| 624 // Reset user flow to default, so that special flow will not affect next | 637 // Reset user flow to default, so that special flow will not affect next |
| 625 // attempt. | 638 // attempt. |
| 626 ChromeUserManager::Get()->ResetUserFlow(last_login_attempt_account_id_); | 639 ChromeUserManager::Get()->ResetUserFlow(last_login_attempt_account_id_); |
| 627 | 640 |
| 628 if (auth_status_consumer_) | 641 if (auth_status_consumer_) |
| 629 auth_status_consumer_->OnAuthFailure(failure); | 642 auth_status_consumer_->OnAuthFailure(failure); |
| 630 | 643 |
| 631 // Clear the recorded displayed email so it won't affect any future attempts. | 644 // Clear the recorded displayed email so it won't affect any future attempts. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 646 | 659 |
| 647 // Login performer will be gone so cache this value to use | 660 // Login performer will be gone so cache this value to use |
| 648 // once profile is loaded. | 661 // once profile is loaded. |
| 649 password_changed_ = login_performer_->password_changed(); | 662 password_changed_ = login_performer_->password_changed(); |
| 650 auth_mode_ = login_performer_->auth_mode(); | 663 auth_mode_ = login_performer_->auth_mode(); |
| 651 | 664 |
| 652 ChromeUserManager::Get() | 665 ChromeUserManager::Get() |
| 653 ->GetUserFlow(user_context.GetAccountId()) | 666 ->GetUserFlow(user_context.GetAccountId()) |
| 654 ->HandleLoginSuccess(user_context); | 667 ->HandleLoginSuccess(user_context); |
| 655 | 668 |
| 656 StopPublicSessionAutoLoginTimer(); | 669 StopAutoLoginTimer(); |
| 657 | 670 |
| 658 // Truth table of |has_auth_cookies|: | 671 // Truth table of |has_auth_cookies|: |
| 659 // Regular SAML | 672 // Regular SAML |
| 660 // /ServiceLogin T T | 673 // /ServiceLogin T T |
| 661 // /ChromeOsEmbeddedSetup F T | 674 // /ChromeOsEmbeddedSetup F T |
| 662 // Bootstrap experiment F N/A | 675 // Bootstrap experiment F N/A |
| 663 const bool has_auth_cookies = | 676 const bool has_auth_cookies = |
| 664 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION && | 677 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION && |
| 665 (user_context.GetAccessToken().empty() || | 678 (user_context.GetAccessToken().empty() || |
| 666 user_context.GetAuthFlow() == UserContext::AUTH_FLOW_GAIA_WITH_SAML) && | 679 user_context.GetAuthFlow() == UserContext::AUTH_FLOW_GAIA_WITH_SAML) && |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 753 base::Bind(&ExistingUserController::OnTokenHandleChecked, | 766 base::Bind(&ExistingUserController::OnTokenHandleChecked, |
| 754 weak_factory_.GetWeakPtr())); | 767 weak_factory_.GetWeakPtr())); |
| 755 return; | 768 return; |
| 756 } | 769 } |
| 757 } | 770 } |
| 758 | 771 |
| 759 ShowPasswordChangedDialog(); | 772 ShowPasswordChangedDialog(); |
| 760 } | 773 } |
| 761 | 774 |
| 762 void ExistingUserController::WhiteListCheckFailed(const std::string& email) { | 775 void ExistingUserController::WhiteListCheckFailed(const std::string& email) { |
| 763 PerformLoginFinishedActions(true /* start public session timer */); | 776 PerformLoginFinishedActions(true /* start auto login timer */); |
| 764 | 777 |
| 765 login_display_->ShowWhitelistCheckFailedError(); | 778 login_display_->ShowWhitelistCheckFailedError(); |
| 766 | 779 |
| 767 if (auth_status_consumer_) { | 780 if (auth_status_consumer_) { |
| 768 auth_status_consumer_->OnAuthFailure( | 781 auth_status_consumer_->OnAuthFailure( |
| 769 AuthFailure(AuthFailure::WHITELIST_CHECK_FAILED)); | 782 AuthFailure(AuthFailure::WHITELIST_CHECK_FAILED)); |
| 770 } | 783 } |
| 771 | 784 |
| 772 display_email_.clear(); | 785 display_email_.clear(); |
| 773 } | 786 } |
| 774 | 787 |
| 775 void ExistingUserController::PolicyLoadFailed() { | 788 void ExistingUserController::PolicyLoadFailed() { |
| 776 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, ""); | 789 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, ""); |
| 777 | 790 |
| 778 PerformLoginFinishedActions(false /* don't start public session timer */); | 791 PerformLoginFinishedActions(false /* don't start auto login timer */); |
| 779 display_email_.clear(); | 792 display_email_.clear(); |
| 780 } | 793 } |
| 781 | 794 |
| 782 void ExistingUserController::SetAuthFlowOffline(bool offline) { | 795 void ExistingUserController::SetAuthFlowOffline(bool offline) { |
| 783 auth_flow_offline_ = offline; | 796 auth_flow_offline_ = offline; |
| 784 } | 797 } |
| 785 | 798 |
| 786 //////////////////////////////////////////////////////////////////////////////// | 799 //////////////////////////////////////////////////////////////////////////////// |
| 787 // ExistingUserController, private: | 800 // ExistingUserController, private: |
| 788 | 801 |
| 789 void ExistingUserController::DeviceSettingsChanged() { | 802 void ExistingUserController::DeviceSettingsChanged() { |
| 790 // If login was already completed, we should avoid any signin screen | 803 // If login was already completed, we should avoid any signin screen |
| 791 // transitions, see http://crbug.com/461604 for example. | 804 // transitions, see http://crbug.com/461604 for example. |
| 792 if (host_ != nullptr && !login_display_->is_signin_completed()) { | 805 if (host_ != nullptr && !login_display_->is_signin_completed()) { |
| 793 // Signed settings or user list changed. Notify views and update them. | 806 // Signed settings or user list changed. Notify views and update them. |
| 794 UpdateLoginDisplay(user_manager::UserManager::Get()->GetUsers()); | 807 UpdateLoginDisplay(user_manager::UserManager::Get()->GetUsers()); |
| 795 ConfigurePublicSessionAutoLogin(); | 808 ConfigureAutoLogin(); |
| 796 } | 809 } |
| 797 } | 810 } |
| 798 | 811 |
| 799 LoginPerformer::AuthorizationMode ExistingUserController::auth_mode() const { | 812 LoginPerformer::AuthorizationMode ExistingUserController::auth_mode() const { |
| 800 if (login_performer_) | 813 if (login_performer_) |
| 801 return login_performer_->auth_mode(); | 814 return login_performer_->auth_mode(); |
| 802 | 815 |
| 803 return auth_mode_; | 816 return auth_mode_; |
| 804 } | 817 } |
| 805 | 818 |
| 806 bool ExistingUserController::password_changed() const { | 819 bool ExistingUserController::password_changed() const { |
| 807 if (login_performer_) | 820 if (login_performer_) |
| 808 return login_performer_->password_changed(); | 821 return login_performer_->password_changed(); |
| 809 | 822 |
| 810 return password_changed_; | 823 return password_changed_; |
| 811 } | 824 } |
| 812 | 825 |
| 813 void ExistingUserController::LoginAsGuest() { | 826 void ExistingUserController::LoginAsGuest() { |
| 814 PerformPreLoginActions(UserContext(user_manager::USER_TYPE_GUEST, | 827 PerformPreLoginActions(UserContext(user_manager::USER_TYPE_GUEST, |
| 815 user_manager::GuestAccountId())); | 828 user_manager::GuestAccountId())); |
| 816 | 829 |
| 817 bool allow_guest; | 830 bool allow_guest; |
| 818 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); | 831 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); |
| 819 if (!allow_guest) { | 832 if (!allow_guest) { |
| 820 // Disallowed. The UI should normally not show the guest session button. | 833 // Disallowed. The UI should normally not show the guest session button. |
| 821 LOG(ERROR) << "Guest login attempt when guest mode is disallowed."; | 834 LOG(ERROR) << "Guest login attempt when guest mode is disallowed."; |
| 822 PerformLoginFinishedActions(true /* start public session timer */); | 835 PerformLoginFinishedActions(true /* start auto login timer */); |
| 823 display_email_.clear(); | 836 display_email_.clear(); |
| 824 return; | 837 return; |
| 825 } | 838 } |
| 826 | 839 |
| 827 // Only one instance of LoginPerformer should exist at a time. | 840 // Only one instance of LoginPerformer should exist at a time. |
| 828 login_performer_.reset(nullptr); | 841 login_performer_.reset(nullptr); |
| 829 login_performer_.reset(new ChromeLoginPerformer(this)); | 842 login_performer_.reset(new ChromeLoginPerformer(this)); |
| 830 login_performer_->LoginOffTheRecord(); | 843 login_performer_->LoginOffTheRecord(); |
| 831 SendAccessibilityAlert( | 844 SendAccessibilityAlert( |
| 832 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); | 845 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); |
| 833 } | 846 } |
| 834 | 847 |
| 835 void ExistingUserController::LoginAsPublicSession( | 848 void ExistingUserController::LoginAsPublicSession( |
| 836 const UserContext& user_context) { | 849 const UserContext& user_context) { |
| 837 PerformPreLoginActions(user_context); | 850 PerformPreLoginActions(user_context); |
| 838 | 851 |
| 839 // If there is no public account with the given user ID, logging in is not | 852 // If there is no public account with the given user ID, logging in is not |
| 840 // possible. | 853 // possible. |
| 841 const user_manager::User* user = | 854 const user_manager::User* user = |
| 842 user_manager::UserManager::Get()->FindUser(user_context.GetAccountId()); | 855 user_manager::UserManager::Get()->FindUser(user_context.GetAccountId()); |
| 843 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) { | 856 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) { |
| 844 PerformLoginFinishedActions(true /* start public session timer */); | 857 PerformLoginFinishedActions(true /* start auto login timer */); |
| 845 return; | 858 return; |
| 846 } | 859 } |
| 847 | 860 |
| 848 UserContext new_user_context = user_context; | 861 UserContext new_user_context = user_context; |
| 849 std::string locale = user_context.GetPublicSessionLocale(); | 862 std::string locale = user_context.GetPublicSessionLocale(); |
| 850 if (locale.empty()) { | 863 if (locale.empty()) { |
| 851 // When performing auto-login, no locale is chosen by the user. Check | 864 // When performing auto-login, no locale is chosen by the user. Check |
| 852 // whether a list of recommended locales was set by policy. If so, use its | 865 // whether a list of recommended locales was set by policy. If so, use its |
| 853 // first entry. Otherwise, |locale| will remain blank, indicating that the | 866 // first entry. Otherwise, |locale| will remain blank, indicating that the |
| 854 // public session should use the current UI locale. | 867 // public session should use the current UI locale. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 907 const bool auto_start = false; | 920 const bool auto_start = false; |
| 908 host_->StartAppLaunch(app_id, diagnostic_mode, auto_start); | 921 host_->StartAppLaunch(app_id, diagnostic_mode, auto_start); |
| 909 } | 922 } |
| 910 | 923 |
| 911 void ExistingUserController::LoginAsArcKioskApp(const AccountId& account_id) { | 924 void ExistingUserController::LoginAsArcKioskApp(const AccountId& account_id) { |
| 912 login_performer_.reset(nullptr); | 925 login_performer_.reset(nullptr); |
| 913 login_performer_.reset(new ChromeLoginPerformer(this)); | 926 login_performer_.reset(new ChromeLoginPerformer(this)); |
| 914 login_performer_->LoginAsArcKioskAccount(account_id); | 927 login_performer_->LoginAsArcKioskAccount(account_id); |
| 915 } | 928 } |
| 916 | 929 |
| 917 void ExistingUserController::ConfigurePublicSessionAutoLogin() { | 930 void ExistingUserController::ConfigureAutoLogin() { |
| 918 std::string auto_login_account_id; | 931 std::string auto_login_account_id; |
| 919 cros_settings_->GetString(kAccountsPrefDeviceLocalAccountAutoLoginId, | 932 cros_settings_->GetString(kAccountsPrefDeviceLocalAccountAutoLoginId, |
| 920 &auto_login_account_id); | 933 &auto_login_account_id); |
| 921 const std::vector<policy::DeviceLocalAccount> device_local_accounts = | 934 const std::vector<policy::DeviceLocalAccount> device_local_accounts = |
| 922 policy::GetDeviceLocalAccounts(cros_settings_); | 935 policy::GetDeviceLocalAccounts(cros_settings_); |
| 923 | 936 |
| 924 public_session_auto_login_account_id_ = EmptyAccountId(); | 937 public_session_auto_login_account_id_ = EmptyAccountId(); |
| 925 for (std::vector<policy::DeviceLocalAccount>::const_iterator | 938 for (std::vector<policy::DeviceLocalAccount>::const_iterator |
| 926 it = device_local_accounts.begin(); | 939 it = device_local_accounts.begin(); |
| 927 it != device_local_accounts.end(); ++it) { | 940 it != device_local_accounts.end(); ++it) { |
| 928 if (it->account_id == auto_login_account_id) { | 941 if (it->account_id == auto_login_account_id) { |
| 929 public_session_auto_login_account_id_ = | 942 public_session_auto_login_account_id_ = |
| 930 AccountId::FromUserEmail(it->user_id); | 943 AccountId::FromUserEmail(it->user_id); |
| 931 break; | 944 break; |
| 932 } | 945 } |
| 933 } | 946 } |
| 934 | 947 |
| 935 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( | 948 const user_manager::User* public_session_user = |
| 936 public_session_auto_login_account_id_); | 949 user_manager::UserManager::Get()->FindUser( |
| 937 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) | 950 public_session_auto_login_account_id_); |
| 951 if (!public_session_user || | |
| 952 public_session_user->GetType() != | |
| 953 user_manager::USER_TYPE_PUBLIC_ACCOUNT) { | |
| 938 public_session_auto_login_account_id_ = EmptyAccountId(); | 954 public_session_auto_login_account_id_ = EmptyAccountId(); |
| 939 | |
| 940 if (!cros_settings_->GetInteger( | |
| 941 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
| 942 &public_session_auto_login_delay_)) { | |
| 943 public_session_auto_login_delay_ = 0; | |
| 944 } | 955 } |
| 945 | 956 |
| 946 if (public_session_auto_login_account_id_.is_valid()) | 957 arc_kiosk_auto_login_account_id_ = |
| 947 StartPublicSessionAutoLoginTimer(); | 958 ArcKioskAppManager::Get()->GetAutoLaunchAccountId(); |
| 948 else | 959 const user_manager::User* arc_kiosk_user = |
| 949 StopPublicSessionAutoLoginTimer(); | 960 user_manager::UserManager::Get()->FindUser( |
| 961 arc_kiosk_auto_login_account_id_); | |
| 962 if (!arc_kiosk_user || | |
| 963 arc_kiosk_user->GetType() != user_manager::USER_TYPE_ARC_KIOSK_APP) { | |
| 964 arc_kiosk_auto_login_account_id_ = EmptyAccountId(); | |
| 965 } | |
| 966 | |
| 967 if (!cros_settings_->GetInteger(kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
| 968 &auto_login_delay_)) { | |
| 969 auto_login_delay_ = 0; | |
| 970 } | |
| 971 | |
| 972 if (public_session_auto_login_account_id_.is_valid() || | |
| 973 arc_kiosk_auto_login_account_id_.is_valid()) { | |
| 974 StartAutoLoginTimer(); | |
| 975 } else { | |
| 976 StopAutoLoginTimer(); | |
| 977 } | |
| 950 } | 978 } |
| 951 | 979 |
| 952 void ExistingUserController::ResetPublicSessionAutoLoginTimer() { | 980 void ExistingUserController::ResetAutoLoginTimer() { |
| 953 // Only restart the auto-login timer if it's already running. | 981 // Only restart the auto-login timer if it's already running. |
| 954 if (auto_login_timer_ && auto_login_timer_->IsRunning()) { | 982 if (auto_login_timer_ && auto_login_timer_->IsRunning()) { |
| 955 StopPublicSessionAutoLoginTimer(); | 983 StopAutoLoginTimer(); |
| 956 StartPublicSessionAutoLoginTimer(); | 984 StartAutoLoginTimer(); |
| 957 } | 985 } |
| 958 } | 986 } |
| 959 | 987 |
| 960 void ExistingUserController::OnPublicSessionAutoLoginTimerFire() { | 988 void ExistingUserController::OnPublicSessionAutoLoginTimerFire() { |
| 961 CHECK(signin_screen_ready_ && | 989 CHECK(auto_launch_ready_ && public_session_auto_login_account_id_.is_valid()); |
| 962 public_session_auto_login_account_id_.is_valid()); | |
| 963 Login(UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 990 Login(UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
| 964 public_session_auto_login_account_id_), | 991 public_session_auto_login_account_id_), |
| 965 SigninSpecifics()); | 992 SigninSpecifics()); |
| 966 } | 993 } |
| 967 | 994 |
| 968 void ExistingUserController::StopPublicSessionAutoLoginTimer() { | 995 void ExistingUserController::OnArcKioskAutoLoginTimerFire() { |
| 996 CHECK(auto_launch_ready_ && (arc_kiosk_auto_login_account_id_.is_valid())); | |
| 997 Login(UserContext(user_manager::USER_TYPE_ARC_KIOSK_APP, | |
| 998 arc_kiosk_auto_login_account_id_), | |
| 999 SigninSpecifics()); | |
| 1000 } | |
| 1001 | |
| 1002 void ExistingUserController::StopAutoLoginTimer() { | |
| 969 if (auto_login_timer_) | 1003 if (auto_login_timer_) |
| 970 auto_login_timer_->Stop(); | 1004 auto_login_timer_->Stop(); |
| 971 } | 1005 } |
| 972 | 1006 |
| 973 void ExistingUserController::StartPublicSessionAutoLoginTimer() { | 1007 void ExistingUserController::StartAutoLoginTimer() { |
| 974 if (!signin_screen_ready_ || is_login_in_progress_ || | 1008 if (!auto_launch_ready_ || is_login_in_progress_ || |
| 975 !public_session_auto_login_account_id_.is_valid()) { | 1009 (!public_session_auto_login_account_id_.is_valid() && |
| 1010 !arc_kiosk_auto_login_account_id_.is_valid())) { | |
| 976 return; | 1011 return; |
| 977 } | 1012 } |
| 978 | 1013 |
| 979 // Start the auto-login timer. | 1014 // Start the auto-login timer. |
| 980 if (!auto_login_timer_) | 1015 if (!auto_login_timer_) |
| 981 auto_login_timer_.reset(new base::OneShotTimer); | 1016 auto_login_timer_.reset(new base::OneShotTimer); |
| 982 | 1017 |
| 983 auto_login_timer_->Start( | 1018 if (public_session_auto_login_account_id_.is_valid()) { |
| 984 FROM_HERE, | 1019 auto_login_timer_->Start( |
| 985 base::TimeDelta::FromMilliseconds( | 1020 FROM_HERE, base::TimeDelta::FromMilliseconds(auto_login_delay_), |
| 986 public_session_auto_login_delay_), | 1021 base::Bind(&ExistingUserController::OnPublicSessionAutoLoginTimerFire, |
| 987 base::Bind( | 1022 weak_factory_.GetWeakPtr())); |
| 988 &ExistingUserController::OnPublicSessionAutoLoginTimerFire, | 1023 } else { |
| 989 weak_factory_.GetWeakPtr())); | 1024 auto_login_timer_->Start( |
| 1025 FROM_HERE, base::TimeDelta::FromMilliseconds(auto_login_delay_), | |
| 1026 base::Bind(&ExistingUserController::OnArcKioskAutoLoginTimerFire, | |
| 1027 weak_factory_.GetWeakPtr())); | |
| 1028 } | |
| 990 } | 1029 } |
| 991 | 1030 |
| 992 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { | 1031 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { |
| 993 return host_->GetNativeWindow(); | 1032 return host_->GetNativeWindow(); |
| 994 } | 1033 } |
| 995 | 1034 |
| 996 void ExistingUserController::ShowError(int error_id, | 1035 void ExistingUserController::ShowError(int error_id, |
| 997 const std::string& details) { | 1036 const std::string& details) { |
| 998 VLOG(1) << details; | 1037 VLOG(1) << details; |
| 999 HelpAppLauncher::HelpTopic help_topic_id; | 1038 HelpAppLauncher::HelpTopic help_topic_id; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1067 // Disable clicking on other windows and status tray. | 1106 // Disable clicking on other windows and status tray. |
| 1068 login_display_->SetUIEnabled(false); | 1107 login_display_->SetUIEnabled(false); |
| 1069 | 1108 |
| 1070 if (last_login_attempt_account_id_ != user_context.GetAccountId()) { | 1109 if (last_login_attempt_account_id_ != user_context.GetAccountId()) { |
| 1071 last_login_attempt_account_id_ = user_context.GetAccountId(); | 1110 last_login_attempt_account_id_ = user_context.GetAccountId(); |
| 1072 num_login_attempts_ = 0; | 1111 num_login_attempts_ = 0; |
| 1073 } | 1112 } |
| 1074 num_login_attempts_++; | 1113 num_login_attempts_++; |
| 1075 | 1114 |
| 1076 // Stop the auto-login timer when attempting login. | 1115 // Stop the auto-login timer when attempting login. |
| 1077 StopPublicSessionAutoLoginTimer(); | 1116 StopAutoLoginTimer(); |
| 1078 } | 1117 } |
| 1079 | 1118 |
| 1080 void ExistingUserController::PerformLoginFinishedActions( | 1119 void ExistingUserController::PerformLoginFinishedActions( |
| 1081 bool start_public_session_timer) { | 1120 bool start_auto_login_timer) { |
| 1082 is_login_in_progress_ = false; | 1121 is_login_in_progress_ = false; |
| 1083 | 1122 |
| 1084 // Reenable clicking on other windows and status area. | 1123 // Reenable clicking on other windows and status area. |
| 1085 login_display_->SetUIEnabled(true); | 1124 login_display_->SetUIEnabled(true); |
| 1086 | 1125 |
| 1087 if (start_public_session_timer) | 1126 if (start_auto_login_timer) |
| 1088 StartPublicSessionAutoLoginTimer(); | 1127 StartAutoLoginTimer(); |
| 1089 } | 1128 } |
| 1090 | 1129 |
| 1091 void ExistingUserController::ContinueLoginIfDeviceNotDisabled( | 1130 void ExistingUserController::ContinueLoginIfDeviceNotDisabled( |
| 1092 const base::Closure& continuation) { | 1131 const base::Closure& continuation) { |
| 1093 // Disable clicking on other windows and status tray. | 1132 // Disable clicking on other windows and status tray. |
| 1094 login_display_->SetUIEnabled(false); | 1133 login_display_->SetUIEnabled(false); |
| 1095 | 1134 |
| 1096 // Stop the auto-login timer. | 1135 // Stop the auto-login timer. |
| 1097 StopPublicSessionAutoLoginTimer(); | 1136 StopAutoLoginTimer(); |
| 1098 | 1137 |
| 1099 // Wait for the |cros_settings_| to become either trusted or permanently | 1138 // Wait for the |cros_settings_| to become either trusted or permanently |
| 1100 // untrusted. | 1139 // untrusted. |
| 1101 const CrosSettingsProvider::TrustedStatus status = | 1140 const CrosSettingsProvider::TrustedStatus status = |
| 1102 cros_settings_->PrepareTrustedValues(base::Bind( | 1141 cros_settings_->PrepareTrustedValues(base::Bind( |
| 1103 &ExistingUserController::ContinueLoginIfDeviceNotDisabled, | 1142 &ExistingUserController::ContinueLoginIfDeviceNotDisabled, |
| 1104 weak_factory_.GetWeakPtr(), | 1143 weak_factory_.GetWeakPtr(), |
| 1105 continuation)); | 1144 continuation)); |
| 1106 if (status == CrosSettingsProvider::TEMPORARILY_UNTRUSTED) | 1145 if (status == CrosSettingsProvider::TEMPORARILY_UNTRUSTED) |
| 1107 return; | 1146 return; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1219 } | 1258 } |
| 1220 | 1259 |
| 1221 // Regular user or supervised user login. | 1260 // Regular user or supervised user login. |
| 1222 | 1261 |
| 1223 if (!user_context.HasCredentials()) { | 1262 if (!user_context.HasCredentials()) { |
| 1224 // If credentials are missing, refuse to log in. | 1263 // If credentials are missing, refuse to log in. |
| 1225 | 1264 |
| 1226 // Reenable clicking on other windows and status area. | 1265 // Reenable clicking on other windows and status area. |
| 1227 login_display_->SetUIEnabled(true); | 1266 login_display_->SetUIEnabled(true); |
| 1228 // Restart the auto-login timer. | 1267 // Restart the auto-login timer. |
| 1229 StartPublicSessionAutoLoginTimer(); | 1268 StartAutoLoginTimer(); |
| 1230 } | 1269 } |
| 1231 | 1270 |
| 1232 PerformPreLoginActions(user_context); | 1271 PerformPreLoginActions(user_context); |
| 1233 PerformLogin(user_context, LoginPerformer::AUTH_MODE_INTERNAL); | 1272 PerformLogin(user_context, LoginPerformer::AUTH_MODE_INTERNAL); |
| 1234 } | 1273 } |
| 1235 | 1274 |
| 1236 void ExistingUserController::OnBootstrapUserContextInitialized( | 1275 void ExistingUserController::OnBootstrapUserContextInitialized( |
| 1237 bool success, | 1276 bool success, |
| 1238 const UserContext& user_context) { | 1277 const UserContext& user_context) { |
| 1239 if (!success) { | 1278 if (!success) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1277 } | 1316 } |
| 1278 | 1317 |
| 1279 // Otherwise, show the unrecoverable cryptohome error UI and ask user's | 1318 // Otherwise, show the unrecoverable cryptohome error UI and ask user's |
| 1280 // permission to collect a feedback. | 1319 // permission to collect a feedback. |
| 1281 RecordPasswordChangeFlow(LOGIN_PASSWORD_CHANGE_FLOW_CRYPTOHOME_FAILURE); | 1320 RecordPasswordChangeFlow(LOGIN_PASSWORD_CHANGE_FLOW_CRYPTOHOME_FAILURE); |
| 1282 VLOG(1) << "Show unrecoverable cryptohome error dialog."; | 1321 VLOG(1) << "Show unrecoverable cryptohome error dialog."; |
| 1283 login_display_->ShowUnrecoverableCrypthomeErrorDialog(); | 1322 login_display_->ShowUnrecoverableCrypthomeErrorDialog(); |
| 1284 } | 1323 } |
| 1285 | 1324 |
| 1286 } // namespace chromeos | 1325 } // namespace chromeos |
| OLD | NEW |