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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 191 } |
192 | 192 |
193 void ExistingUserController::UpdateLoginDisplay(const UserList& users) { | 193 void ExistingUserController::UpdateLoginDisplay(const UserList& users) { |
194 bool show_users_on_signin; | 194 bool show_users_on_signin; |
195 UserList filtered_users; | 195 UserList filtered_users; |
196 | 196 |
197 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, | 197 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, |
198 &show_users_on_signin); | 198 &show_users_on_signin); |
199 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | 199 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { |
200 // TODO(xiyuan): Clean user profile whose email is not in whitelist. | 200 // TODO(xiyuan): Clean user profile whose email is not in whitelist. |
201 bool meets_locally_managed_requirements = | 201 bool meets_supervised_requirements = |
202 (*it)->GetType() != user_manager::USER_TYPE_LOCALLY_MANAGED || | 202 (*it)->GetType() != user_manager::USER_TYPE_SUPERVISED || |
203 UserManager::Get()->AreLocallyManagedUsersAllowed(); | 203 UserManager::Get()->AreSupervisedUsersAllowed(); |
204 bool meets_whitelist_requirements = | 204 bool meets_whitelist_requirements = |
205 LoginUtils::IsWhitelisted((*it)->email(), NULL) || | 205 LoginUtils::IsWhitelisted((*it)->email(), NULL) || |
206 (*it)->GetType() != user_manager::USER_TYPE_REGULAR; | 206 (*it)->GetType() != user_manager::USER_TYPE_REGULAR; |
207 | 207 |
208 // Public session accounts are always shown on login screen. | 208 // Public session accounts are always shown on login screen. |
209 bool meets_show_users_requirements = | 209 bool meets_show_users_requirements = |
210 show_users_on_signin || | 210 show_users_on_signin || |
211 (*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT; | 211 (*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT; |
212 if (meets_locally_managed_requirements && | 212 if (meets_supervised_requirements && |
213 meets_whitelist_requirements && | 213 meets_whitelist_requirements && |
214 meets_show_users_requirements) { | 214 meets_show_users_requirements) { |
215 filtered_users.push_back(*it); | 215 filtered_users.push_back(*it); |
216 } | 216 } |
217 } | 217 } |
218 | 218 |
219 // If no user pods are visible, fallback to single new user pod which will | 219 // If no user pods are visible, fallback to single new user pod which will |
220 // have guest session link. | 220 // have guest session link. |
221 bool show_guest; | 221 bool show_guest; |
222 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &show_guest); | 222 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &show_guest); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 LoginPerformer::Delegate* delegate = this; | 446 LoginPerformer::Delegate* delegate = this; |
447 if (login_performer_delegate_.get()) | 447 if (login_performer_delegate_.get()) |
448 delegate = login_performer_delegate_.get(); | 448 delegate = login_performer_delegate_.get(); |
449 // Only one instance of LoginPerformer should exist at a time. | 449 // Only one instance of LoginPerformer should exist at a time. |
450 login_performer_.reset(NULL); | 450 login_performer_.reset(NULL); |
451 login_performer_.reset(new LoginPerformer(delegate)); | 451 login_performer_.reset(new LoginPerformer(delegate)); |
452 } | 452 } |
453 | 453 |
454 is_login_in_progress_ = true; | 454 is_login_in_progress_ = true; |
455 if (gaia::ExtractDomainName(user_context.GetUserID()) == | 455 if (gaia::ExtractDomainName(user_context.GetUserID()) == |
456 chromeos::login::kLocallyManagedUserDomain) { | 456 chromeos::login::kSupervisedUserDomain) { |
457 login_performer_->LoginAsLocallyManagedUser(user_context); | 457 login_performer_->LoginAsSupervisedUser(user_context); |
458 } else { | 458 } else { |
459 login_performer_->PerformLogin(user_context, auth_mode); | 459 login_performer_->PerformLogin(user_context, auth_mode); |
460 } | 460 } |
461 SendAccessibilityAlert( | 461 SendAccessibilityAlert( |
462 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); | 462 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); |
463 } | 463 } |
464 | 464 |
465 void ExistingUserController::LoginAsRetailModeUser() { | 465 void ExistingUserController::LoginAsRetailModeUser() { |
466 // Stop the auto-login timer when attempting login. | 466 // Stop the auto-login timer when attempting login. |
467 StopPublicSessionAutoLoginTimer(); | 467 StopPublicSessionAutoLoginTimer(); |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 false, // Start session for user. | 811 false, // Start session for user. |
812 this); | 812 this); |
813 } | 813 } |
814 | 814 |
815 void ExistingUserController::OnProfilePrepared(Profile* profile) { | 815 void ExistingUserController::OnProfilePrepared(Profile* profile) { |
816 // Reenable clicking on other windows and status area. | 816 // Reenable clicking on other windows and status area. |
817 login_display_->SetUIEnabled(true); | 817 login_display_->SetUIEnabled(true); |
818 | 818 |
819 UserManager* user_manager = UserManager::Get(); | 819 UserManager* user_manager = UserManager::Get(); |
820 if (user_manager->IsCurrentUserNew() && | 820 if (user_manager->IsCurrentUserNew() && |
821 user_manager->IsLoggedInAsLocallyManagedUser()) { | 821 user_manager->IsLoggedInAsSupervisedUser()) { |
822 // Supervised users should launch into empty desktop on first run. | 822 // Supervised users should launch into empty desktop on first run. |
823 CommandLine::ForCurrentProcess()->AppendSwitch(::switches::kSilentLaunch); | 823 CommandLine::ForCurrentProcess()->AppendSwitch(::switches::kSilentLaunch); |
824 } | 824 } |
825 | 825 |
826 if (user_manager->IsCurrentUserNew() && | 826 if (user_manager->IsCurrentUserNew() && |
827 !user_manager->GetCurrentUserFlow()->ShouldSkipPostLoginScreens() && | 827 !user_manager->GetCurrentUserFlow()->ShouldSkipPostLoginScreens() && |
828 !WizardController::default_controller()->skip_post_login_screens()) { | 828 !WizardController::default_controller()->skip_post_login_screens()) { |
829 // Don't specify start URLs if the administrator has configured the start | 829 // Don't specify start URLs if the administrator has configured the start |
830 // URLs via policy. | 830 // URLs via policy. |
831 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) | 831 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 help_topic_id = is_offline ? | 1127 help_topic_id = is_offline ? |
1128 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE : | 1128 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE : |
1129 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT; | 1129 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT; |
1130 break; | 1130 break; |
1131 } | 1131 } |
1132 | 1132 |
1133 if (error_id == IDS_LOGIN_ERROR_AUTHENTICATING) { | 1133 if (error_id == IDS_LOGIN_ERROR_AUTHENTICATING) { |
1134 if (num_login_attempts_ > 1) { | 1134 if (num_login_attempts_ > 1) { |
1135 const User* user = | 1135 const User* user = |
1136 UserManager::Get()->FindUser(last_login_attempt_username_); | 1136 UserManager::Get()->FindUser(last_login_attempt_username_); |
1137 if (user && (user->GetType() == user_manager::USER_TYPE_LOCALLY_MANAGED)) | 1137 if (user && (user->GetType() == user_manager::USER_TYPE_SUPERVISED)) |
1138 error_id = IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME_SUPERVISED; | 1138 error_id = IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME_SUPERVISED; |
1139 } | 1139 } |
1140 } | 1140 } |
1141 | 1141 |
1142 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id); | 1142 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id); |
1143 } | 1143 } |
1144 | 1144 |
1145 void ExistingUserController::ShowGaiaPasswordChanged( | 1145 void ExistingUserController::ShowGaiaPasswordChanged( |
1146 const std::string& username) { | 1146 const std::string& username) { |
1147 // Invalidate OAuth token, since it can't be correct after password is | 1147 // Invalidate OAuth token, since it can't be correct after password is |
1148 // changed. | 1148 // changed. |
1149 UserManager::Get()->SaveUserOAuthStatus( | 1149 UserManager::Get()->SaveUserOAuthStatus( |
1150 username, | 1150 username, |
1151 User::OAUTH2_TOKEN_STATUS_INVALID); | 1151 User::OAUTH2_TOKEN_STATUS_INVALID); |
1152 | 1152 |
1153 login_display_->SetUIEnabled(true); | 1153 login_display_->SetUIEnabled(true); |
1154 login_display_->ShowGaiaPasswordChanged(username); | 1154 login_display_->ShowGaiaPasswordChanged(username); |
1155 } | 1155 } |
1156 | 1156 |
1157 void ExistingUserController::SendAccessibilityAlert( | 1157 void ExistingUserController::SendAccessibilityAlert( |
1158 const std::string& alert_text) { | 1158 const std::string& alert_text) { |
1159 AccessibilityAlertInfo event(ProfileHelper::GetSigninProfile(), alert_text); | 1159 AccessibilityAlertInfo event(ProfileHelper::GetSigninProfile(), alert_text); |
1160 SendControlAccessibilityNotification( | 1160 SendControlAccessibilityNotification( |
1161 ui::AX_EVENT_VALUE_CHANGED, &event); | 1161 ui::AX_EVENT_VALUE_CHANGED, &event); |
1162 } | 1162 } |
1163 | 1163 |
1164 } // namespace chromeos | 1164 } // namespace chromeos |
OLD | NEW |