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 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 } | 755 } |
756 | 756 |
757 bool ExistingUserController::password_changed() const { | 757 bool ExistingUserController::password_changed() const { |
758 if (login_performer_) | 758 if (login_performer_) |
759 return login_performer_->password_changed(); | 759 return login_performer_->password_changed(); |
760 | 760 |
761 return password_changed_; | 761 return password_changed_; |
762 } | 762 } |
763 | 763 |
764 void ExistingUserController::LoginAsGuest() { | 764 void ExistingUserController::LoginAsGuest() { |
765 PerformPreLoginActions(UserContext(user_manager::USER_TYPE_GUEST, | 765 PerformPreLoginActions( |
766 login::GuestAccountId().GetUserEmail())); | 766 UserContext(user_manager::USER_TYPE_GUEST, login::GuestAccountId())); |
767 | 767 |
768 bool allow_guest; | 768 bool allow_guest; |
769 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); | 769 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); |
770 if (!allow_guest) { | 770 if (!allow_guest) { |
771 // Disallowed. The UI should normally not show the guest session button. | 771 // Disallowed. The UI should normally not show the guest session button. |
772 LOG(ERROR) << "Guest login attempt when guest mode is disallowed."; | 772 LOG(ERROR) << "Guest login attempt when guest mode is disallowed."; |
773 PerformLoginFinishedActions(true /* start public session timer */); | 773 PerformLoginFinishedActions(true /* start public session timer */); |
774 display_email_.clear(); | 774 display_email_.clear(); |
775 return; | 775 return; |
776 } | 776 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 host_->StartAppLaunch(app_id, diagnostic_mode, auto_start); | 859 host_->StartAppLaunch(app_id, diagnostic_mode, auto_start); |
860 } | 860 } |
861 | 861 |
862 void ExistingUserController::ConfigurePublicSessionAutoLogin() { | 862 void ExistingUserController::ConfigurePublicSessionAutoLogin() { |
863 std::string auto_login_account_id; | 863 std::string auto_login_account_id; |
864 cros_settings_->GetString(kAccountsPrefDeviceLocalAccountAutoLoginId, | 864 cros_settings_->GetString(kAccountsPrefDeviceLocalAccountAutoLoginId, |
865 &auto_login_account_id); | 865 &auto_login_account_id); |
866 const std::vector<policy::DeviceLocalAccount> device_local_accounts = | 866 const std::vector<policy::DeviceLocalAccount> device_local_accounts = |
867 policy::GetDeviceLocalAccounts(cros_settings_); | 867 policy::GetDeviceLocalAccounts(cros_settings_); |
868 | 868 |
869 public_session_auto_login_username_.clear(); | 869 public_session_auto_login_account_id_ = EmptyAccountId(); |
870 for (std::vector<policy::DeviceLocalAccount>::const_iterator | 870 for (std::vector<policy::DeviceLocalAccount>::const_iterator |
871 it = device_local_accounts.begin(); | 871 it = device_local_accounts.begin(); |
872 it != device_local_accounts.end(); ++it) { | 872 it != device_local_accounts.end(); ++it) { |
873 if (it->account_id == auto_login_account_id) { | 873 if (it->account_id == auto_login_account_id) { |
874 public_session_auto_login_username_ = it->user_id; | 874 public_session_auto_login_account_id_ = |
| 875 AccountId::FromUserEmail(it->user_id); |
875 break; | 876 break; |
876 } | 877 } |
877 } | 878 } |
878 | 879 |
879 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( | 880 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( |
880 AccountId::FromUserEmail(public_session_auto_login_username_)); | 881 public_session_auto_login_account_id_); |
881 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) | 882 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) |
882 public_session_auto_login_username_.clear(); | 883 public_session_auto_login_account_id_ = EmptyAccountId(); |
883 | 884 |
884 if (!cros_settings_->GetInteger( | 885 if (!cros_settings_->GetInteger( |
885 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | 886 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
886 &public_session_auto_login_delay_)) { | 887 &public_session_auto_login_delay_)) { |
887 public_session_auto_login_delay_ = 0; | 888 public_session_auto_login_delay_ = 0; |
888 } | 889 } |
889 | 890 |
890 if (!public_session_auto_login_username_.empty()) | 891 if (public_session_auto_login_account_id_.is_valid()) |
891 StartPublicSessionAutoLoginTimer(); | 892 StartPublicSessionAutoLoginTimer(); |
892 else | 893 else |
893 StopPublicSessionAutoLoginTimer(); | 894 StopPublicSessionAutoLoginTimer(); |
894 } | 895 } |
895 | 896 |
896 void ExistingUserController::ResetPublicSessionAutoLoginTimer() { | 897 void ExistingUserController::ResetPublicSessionAutoLoginTimer() { |
897 // Only restart the auto-login timer if it's already running. | 898 // Only restart the auto-login timer if it's already running. |
898 if (auto_login_timer_ && auto_login_timer_->IsRunning()) { | 899 if (auto_login_timer_ && auto_login_timer_->IsRunning()) { |
899 StopPublicSessionAutoLoginTimer(); | 900 StopPublicSessionAutoLoginTimer(); |
900 StartPublicSessionAutoLoginTimer(); | 901 StartPublicSessionAutoLoginTimer(); |
901 } | 902 } |
902 } | 903 } |
903 | 904 |
904 void ExistingUserController::OnPublicSessionAutoLoginTimerFire() { | 905 void ExistingUserController::OnPublicSessionAutoLoginTimerFire() { |
905 CHECK(signin_screen_ready_ && !public_session_auto_login_username_.empty()); | 906 CHECK(signin_screen_ready_ && |
| 907 public_session_auto_login_account_id_.is_valid()); |
906 Login(UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 908 Login(UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
907 public_session_auto_login_username_), | 909 public_session_auto_login_account_id_), |
908 SigninSpecifics()); | 910 SigninSpecifics()); |
909 } | 911 } |
910 | 912 |
911 void ExistingUserController::StopPublicSessionAutoLoginTimer() { | 913 void ExistingUserController::StopPublicSessionAutoLoginTimer() { |
912 if (auto_login_timer_) | 914 if (auto_login_timer_) |
913 auto_login_timer_->Stop(); | 915 auto_login_timer_->Stop(); |
914 } | 916 } |
915 | 917 |
916 void ExistingUserController::StartPublicSessionAutoLoginTimer() { | 918 void ExistingUserController::StartPublicSessionAutoLoginTimer() { |
917 if (!signin_screen_ready_ || | 919 if (!signin_screen_ready_ || is_login_in_progress_ || |
918 is_login_in_progress_ || | 920 !public_session_auto_login_account_id_.is_valid()) { |
919 public_session_auto_login_username_.empty()) { | |
920 return; | 921 return; |
921 } | 922 } |
922 | 923 |
923 // Start the auto-login timer. | 924 // Start the auto-login timer. |
924 if (!auto_login_timer_) | 925 if (!auto_login_timer_) |
925 auto_login_timer_.reset(new base::OneShotTimer); | 926 auto_login_timer_.reset(new base::OneShotTimer); |
926 | 927 |
927 auto_login_timer_->Start( | 928 auto_login_timer_->Start( |
928 FROM_HERE, | 929 FROM_HERE, |
929 base::TimeDelta::FromMilliseconds( | 930 base::TimeDelta::FromMilliseconds( |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 return; | 1242 return; |
1242 } | 1243 } |
1243 | 1244 |
1244 // Otherwise, show the unrecoverable cryptohome error UI and ask user's | 1245 // Otherwise, show the unrecoverable cryptohome error UI and ask user's |
1245 // permission to collect a feedback. | 1246 // permission to collect a feedback. |
1246 VLOG(1) << "Show unrecoverable cryptohome error dialog."; | 1247 VLOG(1) << "Show unrecoverable cryptohome error dialog."; |
1247 login_display_->ShowUnrecoverableCrypthomeErrorDialog(); | 1248 login_display_->ShowUnrecoverableCrypthomeErrorDialog(); |
1248 } | 1249 } |
1249 | 1250 |
1250 } // namespace chromeos | 1251 } // namespace chromeos |
OLD | NEW |