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

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

Issue 2510203002: Implement auto-login for ARC kiosk. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kiosk_session
Patch Set: Stop timer if running in StartAutoLoginTimer() Created 4 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 <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
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
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
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();
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
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
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
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
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
1014 if (auto_login_timer_ && auto_login_timer_->IsRunning()) {
1015 StopAutoLoginTimer();
1016 }
1017
979 // Start the auto-login timer. 1018 // Start the auto-login timer.
980 if (!auto_login_timer_) 1019 if (!auto_login_timer_)
981 auto_login_timer_.reset(new base::OneShotTimer); 1020 auto_login_timer_.reset(new base::OneShotTimer);
982 1021
983 auto_login_timer_->Start( 1022 if (public_session_auto_login_account_id_.is_valid()) {
984 FROM_HERE, 1023 auto_login_timer_->Start(
985 base::TimeDelta::FromMilliseconds( 1024 FROM_HERE, base::TimeDelta::FromMilliseconds(auto_login_delay_),
986 public_session_auto_login_delay_), 1025 base::Bind(&ExistingUserController::OnPublicSessionAutoLoginTimerFire,
987 base::Bind( 1026 weak_factory_.GetWeakPtr()));
988 &ExistingUserController::OnPublicSessionAutoLoginTimerFire, 1027 } else {
989 weak_factory_.GetWeakPtr())); 1028 auto_login_timer_->Start(
1029 FROM_HERE, base::TimeDelta::FromMilliseconds(auto_login_delay_),
1030 base::Bind(&ExistingUserController::OnArcKioskAutoLoginTimerFire,
1031 weak_factory_.GetWeakPtr()));
1032 }
990 } 1033 }
991 1034
992 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { 1035 gfx::NativeWindow ExistingUserController::GetNativeWindow() const {
993 return host_->GetNativeWindow(); 1036 return host_->GetNativeWindow();
994 } 1037 }
995 1038
996 void ExistingUserController::ShowError(int error_id, 1039 void ExistingUserController::ShowError(int error_id,
997 const std::string& details) { 1040 const std::string& details) {
998 VLOG(1) << details; 1041 VLOG(1) << details;
999 HelpAppLauncher::HelpTopic help_topic_id; 1042 HelpAppLauncher::HelpTopic help_topic_id;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 // Disable clicking on other windows and status tray. 1110 // Disable clicking on other windows and status tray.
1068 login_display_->SetUIEnabled(false); 1111 login_display_->SetUIEnabled(false);
1069 1112
1070 if (last_login_attempt_account_id_ != user_context.GetAccountId()) { 1113 if (last_login_attempt_account_id_ != user_context.GetAccountId()) {
1071 last_login_attempt_account_id_ = user_context.GetAccountId(); 1114 last_login_attempt_account_id_ = user_context.GetAccountId();
1072 num_login_attempts_ = 0; 1115 num_login_attempts_ = 0;
1073 } 1116 }
1074 num_login_attempts_++; 1117 num_login_attempts_++;
1075 1118
1076 // Stop the auto-login timer when attempting login. 1119 // Stop the auto-login timer when attempting login.
1077 StopPublicSessionAutoLoginTimer(); 1120 StopAutoLoginTimer();
1078 } 1121 }
1079 1122
1080 void ExistingUserController::PerformLoginFinishedActions( 1123 void ExistingUserController::PerformLoginFinishedActions(
1081 bool start_public_session_timer) { 1124 bool start_auto_login_timer) {
1082 is_login_in_progress_ = false; 1125 is_login_in_progress_ = false;
1083 1126
1084 // Reenable clicking on other windows and status area. 1127 // Reenable clicking on other windows and status area.
1085 login_display_->SetUIEnabled(true); 1128 login_display_->SetUIEnabled(true);
1086 1129
1087 if (start_public_session_timer) 1130 if (start_auto_login_timer)
1088 StartPublicSessionAutoLoginTimer(); 1131 StartAutoLoginTimer();
1089 } 1132 }
1090 1133
1091 void ExistingUserController::ContinueLoginIfDeviceNotDisabled( 1134 void ExistingUserController::ContinueLoginIfDeviceNotDisabled(
1092 const base::Closure& continuation) { 1135 const base::Closure& continuation) {
1093 // Disable clicking on other windows and status tray. 1136 // Disable clicking on other windows and status tray.
1094 login_display_->SetUIEnabled(false); 1137 login_display_->SetUIEnabled(false);
1095 1138
1096 // Stop the auto-login timer. 1139 // Stop the auto-login timer.
1097 StopPublicSessionAutoLoginTimer(); 1140 StopAutoLoginTimer();
1098 1141
1099 // Wait for the |cros_settings_| to become either trusted or permanently 1142 // Wait for the |cros_settings_| to become either trusted or permanently
1100 // untrusted. 1143 // untrusted.
1101 const CrosSettingsProvider::TrustedStatus status = 1144 const CrosSettingsProvider::TrustedStatus status =
1102 cros_settings_->PrepareTrustedValues(base::Bind( 1145 cros_settings_->PrepareTrustedValues(base::Bind(
1103 &ExistingUserController::ContinueLoginIfDeviceNotDisabled, 1146 &ExistingUserController::ContinueLoginIfDeviceNotDisabled,
1104 weak_factory_.GetWeakPtr(), 1147 weak_factory_.GetWeakPtr(),
1105 continuation)); 1148 continuation));
1106 if (status == CrosSettingsProvider::TEMPORARILY_UNTRUSTED) 1149 if (status == CrosSettingsProvider::TEMPORARILY_UNTRUSTED)
1107 return; 1150 return;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 } 1262 }
1220 1263
1221 // Regular user or supervised user login. 1264 // Regular user or supervised user login.
1222 1265
1223 if (!user_context.HasCredentials()) { 1266 if (!user_context.HasCredentials()) {
1224 // If credentials are missing, refuse to log in. 1267 // If credentials are missing, refuse to log in.
1225 1268
1226 // Reenable clicking on other windows and status area. 1269 // Reenable clicking on other windows and status area.
1227 login_display_->SetUIEnabled(true); 1270 login_display_->SetUIEnabled(true);
1228 // Restart the auto-login timer. 1271 // Restart the auto-login timer.
1229 StartPublicSessionAutoLoginTimer(); 1272 StartAutoLoginTimer();
1230 } 1273 }
1231 1274
1232 PerformPreLoginActions(user_context); 1275 PerformPreLoginActions(user_context);
1233 PerformLogin(user_context, LoginPerformer::AUTH_MODE_INTERNAL); 1276 PerformLogin(user_context, LoginPerformer::AUTH_MODE_INTERNAL);
1234 } 1277 }
1235 1278
1236 void ExistingUserController::OnBootstrapUserContextInitialized( 1279 void ExistingUserController::OnBootstrapUserContextInitialized(
1237 bool success, 1280 bool success,
1238 const UserContext& user_context) { 1281 const UserContext& user_context) {
1239 if (!success) { 1282 if (!success) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 } 1320 }
1278 1321
1279 // Otherwise, show the unrecoverable cryptohome error UI and ask user's 1322 // Otherwise, show the unrecoverable cryptohome error UI and ask user's
1280 // permission to collect a feedback. 1323 // permission to collect a feedback.
1281 RecordPasswordChangeFlow(LOGIN_PASSWORD_CHANGE_FLOW_CRYPTOHOME_FAILURE); 1324 RecordPasswordChangeFlow(LOGIN_PASSWORD_CHANGE_FLOW_CRYPTOHOME_FAILURE);
1282 VLOG(1) << "Show unrecoverable cryptohome error dialog."; 1325 VLOG(1) << "Show unrecoverable cryptohome error dialog.";
1283 login_display_->ShowUnrecoverableCrypthomeErrorDialog(); 1326 login_display_->ShowUnrecoverableCrypthomeErrorDialog();
1284 } 1327 }
1285 1328
1286 } // namespace chromeos 1329 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698