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 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 } | 732 } |
733 | 733 |
734 bool ExistingUserController::password_changed() const { | 734 bool ExistingUserController::password_changed() const { |
735 if (login_performer_) | 735 if (login_performer_) |
736 return login_performer_->password_changed(); | 736 return login_performer_->password_changed(); |
737 | 737 |
738 return password_changed_; | 738 return password_changed_; |
739 } | 739 } |
740 | 740 |
741 void ExistingUserController::LoginAsGuest() { | 741 void ExistingUserController::LoginAsGuest() { |
742 PerformPreLoginActions(UserContext(user_manager::USER_TYPE_GUEST, | 742 PerformPreLoginActions( |
743 login::GuestAccountId().GetUserEmail())); | 743 UserContext(user_manager::USER_TYPE_GUEST, login::GuestAccountId())); |
744 | 744 |
745 bool allow_guest; | 745 bool allow_guest; |
746 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); | 746 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); |
747 if (!allow_guest) { | 747 if (!allow_guest) { |
748 // Disallowed. The UI should normally not show the guest session button. | 748 // Disallowed. The UI should normally not show the guest session button. |
749 LOG(ERROR) << "Guest login attempt when guest mode is disallowed."; | 749 LOG(ERROR) << "Guest login attempt when guest mode is disallowed."; |
750 PerformLoginFinishedActions(true /* start public session timer */); | 750 PerformLoginFinishedActions(true /* start public session timer */); |
751 display_email_.clear(); | 751 display_email_.clear(); |
752 return; | 752 return; |
753 } | 753 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 host_->StartAppLaunch(app_id, diagnostic_mode, auto_start); | 836 host_->StartAppLaunch(app_id, diagnostic_mode, auto_start); |
837 } | 837 } |
838 | 838 |
839 void ExistingUserController::ConfigurePublicSessionAutoLogin() { | 839 void ExistingUserController::ConfigurePublicSessionAutoLogin() { |
840 std::string auto_login_account_id; | 840 std::string auto_login_account_id; |
841 cros_settings_->GetString(kAccountsPrefDeviceLocalAccountAutoLoginId, | 841 cros_settings_->GetString(kAccountsPrefDeviceLocalAccountAutoLoginId, |
842 &auto_login_account_id); | 842 &auto_login_account_id); |
843 const std::vector<policy::DeviceLocalAccount> device_local_accounts = | 843 const std::vector<policy::DeviceLocalAccount> device_local_accounts = |
844 policy::GetDeviceLocalAccounts(cros_settings_); | 844 policy::GetDeviceLocalAccounts(cros_settings_); |
845 | 845 |
846 public_session_auto_login_username_.clear(); | 846 public_session_auto_login_account_id_ = EmptyAccountId(); |
847 for (std::vector<policy::DeviceLocalAccount>::const_iterator | 847 for (std::vector<policy::DeviceLocalAccount>::const_iterator |
848 it = device_local_accounts.begin(); | 848 it = device_local_accounts.begin(); |
849 it != device_local_accounts.end(); ++it) { | 849 it != device_local_accounts.end(); ++it) { |
850 if (it->account_id == auto_login_account_id) { | 850 if (it->account_id == auto_login_account_id) { |
851 public_session_auto_login_username_ = it->user_id; | 851 public_session_auto_login_account_id_ = |
| 852 AccountId::FromUserEmail(it->user_id); |
852 break; | 853 break; |
853 } | 854 } |
854 } | 855 } |
855 | 856 |
856 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( | 857 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( |
857 AccountId::FromUserEmail(public_session_auto_login_username_)); | 858 public_session_auto_login_account_id_); |
858 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) | 859 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) |
859 public_session_auto_login_username_.clear(); | 860 public_session_auto_login_account_id_ = EmptyAccountId(); |
860 | 861 |
861 if (!cros_settings_->GetInteger( | 862 if (!cros_settings_->GetInteger( |
862 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | 863 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
863 &public_session_auto_login_delay_)) { | 864 &public_session_auto_login_delay_)) { |
864 public_session_auto_login_delay_ = 0; | 865 public_session_auto_login_delay_ = 0; |
865 } | 866 } |
866 | 867 |
867 if (!public_session_auto_login_username_.empty()) | 868 if (public_session_auto_login_account_id_.is_valid()) |
868 StartPublicSessionAutoLoginTimer(); | 869 StartPublicSessionAutoLoginTimer(); |
869 else | 870 else |
870 StopPublicSessionAutoLoginTimer(); | 871 StopPublicSessionAutoLoginTimer(); |
871 } | 872 } |
872 | 873 |
873 void ExistingUserController::ResetPublicSessionAutoLoginTimer() { | 874 void ExistingUserController::ResetPublicSessionAutoLoginTimer() { |
874 // Only restart the auto-login timer if it's already running. | 875 // Only restart the auto-login timer if it's already running. |
875 if (auto_login_timer_ && auto_login_timer_->IsRunning()) { | 876 if (auto_login_timer_ && auto_login_timer_->IsRunning()) { |
876 StopPublicSessionAutoLoginTimer(); | 877 StopPublicSessionAutoLoginTimer(); |
877 StartPublicSessionAutoLoginTimer(); | 878 StartPublicSessionAutoLoginTimer(); |
878 } | 879 } |
879 } | 880 } |
880 | 881 |
881 void ExistingUserController::OnPublicSessionAutoLoginTimerFire() { | 882 void ExistingUserController::OnPublicSessionAutoLoginTimerFire() { |
882 CHECK(signin_screen_ready_ && !public_session_auto_login_username_.empty()); | 883 CHECK(signin_screen_ready_ && |
| 884 public_session_auto_login_account_id_.is_valid()); |
883 Login(UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 885 Login(UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
884 public_session_auto_login_username_), | 886 public_session_auto_login_account_id_), |
885 SigninSpecifics()); | 887 SigninSpecifics()); |
886 } | 888 } |
887 | 889 |
888 void ExistingUserController::StopPublicSessionAutoLoginTimer() { | 890 void ExistingUserController::StopPublicSessionAutoLoginTimer() { |
889 if (auto_login_timer_) | 891 if (auto_login_timer_) |
890 auto_login_timer_->Stop(); | 892 auto_login_timer_->Stop(); |
891 } | 893 } |
892 | 894 |
893 void ExistingUserController::StartPublicSessionAutoLoginTimer() { | 895 void ExistingUserController::StartPublicSessionAutoLoginTimer() { |
894 if (!signin_screen_ready_ || | 896 if (!signin_screen_ready_ || is_login_in_progress_ || |
895 is_login_in_progress_ || | 897 !public_session_auto_login_account_id_.is_valid()) { |
896 public_session_auto_login_username_.empty()) { | |
897 return; | 898 return; |
898 } | 899 } |
899 | 900 |
900 // Start the auto-login timer. | 901 // Start the auto-login timer. |
901 if (!auto_login_timer_) | 902 if (!auto_login_timer_) |
902 auto_login_timer_.reset(new base::OneShotTimer); | 903 auto_login_timer_.reset(new base::OneShotTimer); |
903 | 904 |
904 auto_login_timer_->Start( | 905 auto_login_timer_->Start( |
905 FROM_HERE, | 906 FROM_HERE, |
906 base::TimeDelta::FromMilliseconds( | 907 base::TimeDelta::FromMilliseconds( |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 if (!success) { | 1202 if (!success) { |
1202 LOG(ERROR) << "OAuth2 token fetch failed."; | 1203 LOG(ERROR) << "OAuth2 token fetch failed."; |
1203 OnAuthFailure(AuthFailure(AuthFailure::FAILED_TO_INITIALIZE_TOKEN)); | 1204 OnAuthFailure(AuthFailure(AuthFailure::FAILED_TO_INITIALIZE_TOKEN)); |
1204 return; | 1205 return; |
1205 } | 1206 } |
1206 UserSessionManager::GetInstance()->OnOAuth2TokensFetched(user_context); | 1207 UserSessionManager::GetInstance()->OnOAuth2TokensFetched(user_context); |
1207 PerformLogin(user_context, LoginPerformer::AUTH_MODE_EXTENSION); | 1208 PerformLogin(user_context, LoginPerformer::AUTH_MODE_EXTENSION); |
1208 } | 1209 } |
1209 | 1210 |
1210 } // namespace chromeos | 1211 } // namespace chromeos |
OLD | NEW |