| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 kAccountsPrefDeviceLocalAccountAutoLoginId, | 177 kAccountsPrefDeviceLocalAccountAutoLoginId, |
| 178 base::Bind(&ExistingUserController::ConfigurePublicSessionAutoLogin, | 178 base::Bind(&ExistingUserController::ConfigurePublicSessionAutoLogin, |
| 179 base::Unretained(this))); | 179 base::Unretained(this))); |
| 180 local_account_auto_login_delay_subscription_ = | 180 local_account_auto_login_delay_subscription_ = |
| 181 cros_settings_->AddSettingsObserver( | 181 cros_settings_->AddSettingsObserver( |
| 182 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | 182 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
| 183 base::Bind(&ExistingUserController::ConfigurePublicSessionAutoLogin, | 183 base::Bind(&ExistingUserController::ConfigurePublicSessionAutoLogin, |
| 184 base::Unretained(this))); | 184 base::Unretained(this))); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void ExistingUserController::Init(const UserList& users) { | 187 void ExistingUserController::Init(const user_manager::UserList& users) { |
| 188 time_init_ = base::Time::Now(); | 188 time_init_ = base::Time::Now(); |
| 189 UpdateLoginDisplay(users); | 189 UpdateLoginDisplay(users); |
| 190 ConfigurePublicSessionAutoLogin(); | 190 ConfigurePublicSessionAutoLogin(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void ExistingUserController::UpdateLoginDisplay(const UserList& users) { | 193 void ExistingUserController::UpdateLoginDisplay( |
| 194 const user_manager::UserList& users) { |
| 194 bool show_users_on_signin; | 195 bool show_users_on_signin; |
| 195 UserList filtered_users; | 196 user_manager::UserList filtered_users; |
| 196 | 197 |
| 197 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, | 198 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, |
| 198 &show_users_on_signin); | 199 &show_users_on_signin); |
| 199 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | 200 for (user_manager::UserList::const_iterator it = users.begin(); |
| 201 it != users.end(); |
| 202 ++it) { |
| 200 // TODO(xiyuan): Clean user profile whose email is not in whitelist. | 203 // TODO(xiyuan): Clean user profile whose email is not in whitelist. |
| 201 bool meets_supervised_requirements = | 204 bool meets_supervised_requirements = |
| 202 (*it)->GetType() != user_manager::USER_TYPE_SUPERVISED || | 205 (*it)->GetType() != user_manager::USER_TYPE_SUPERVISED || |
| 203 UserManager::Get()->AreSupervisedUsersAllowed(); | 206 UserManager::Get()->AreSupervisedUsersAllowed(); |
| 204 bool meets_whitelist_requirements = | 207 bool meets_whitelist_requirements = |
| 205 LoginUtils::IsWhitelisted((*it)->email(), NULL) || | 208 LoginUtils::IsWhitelisted((*it)->email(), NULL) || |
| 206 (*it)->GetType() != user_manager::USER_TYPE_REGULAR; | 209 (*it)->GetType() != user_manager::USER_TYPE_REGULAR; |
| 207 | 210 |
| 208 // Public session accounts are always shown on login screen. | 211 // Public session accounts are always shown on login screen. |
| 209 bool meets_show_users_requirements = | 212 bool meets_show_users_requirements = |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 DCHECK(signin_profile_context_getter.get()); | 283 DCHECK(signin_profile_context_getter.get()); |
| 281 content::BrowserThread::PostDelayedTask( | 284 content::BrowserThread::PostDelayedTask( |
| 282 content::BrowserThread::IO, FROM_HERE, | 285 content::BrowserThread::IO, FROM_HERE, |
| 283 base::Bind(&TransferContextAuthenticationsOnIOThread, | 286 base::Bind(&TransferContextAuthenticationsOnIOThread, |
| 284 signin_profile_context_getter, | 287 signin_profile_context_getter, |
| 285 browser_process_context_getter), | 288 browser_process_context_getter), |
| 286 base::TimeDelta::FromMilliseconds(kAuthCacheTransferDelayMs)); | 289 base::TimeDelta::FromMilliseconds(kAuthCacheTransferDelayMs)); |
| 287 } | 290 } |
| 288 if (type != chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED) | 291 if (type != chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED) |
| 289 return; | 292 return; |
| 290 login_display_->OnUserImageChanged(*content::Details<User>(details).ptr()); | 293 login_display_->OnUserImageChanged( |
| 294 *content::Details<user_manager::User>(details).ptr()); |
| 291 } | 295 } |
| 292 | 296 |
| 293 //////////////////////////////////////////////////////////////////////////////// | 297 //////////////////////////////////////////////////////////////////////////////// |
| 294 // ExistingUserController, private: | 298 // ExistingUserController, private: |
| 295 | 299 |
| 296 ExistingUserController::~ExistingUserController() { | 300 ExistingUserController::~ExistingUserController() { |
| 297 LoginUtils::Get()->DelegateDeleted(this); | 301 LoginUtils::Get()->DelegateDeleted(this); |
| 298 | 302 |
| 299 if (current_controller_ == this) { | 303 if (current_controller_ == this) { |
| 300 current_controller_ = NULL; | 304 current_controller_ = NULL; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 return; | 569 return; |
| 566 } | 570 } |
| 567 | 571 |
| 568 // If device policy is not verified yet, this function will be called again | 572 // If device policy is not verified yet, this function will be called again |
| 569 // when verification finishes. | 573 // when verification finishes. |
| 570 if (status != CrosSettingsProvider::TRUSTED) | 574 if (status != CrosSettingsProvider::TRUSTED) |
| 571 return; | 575 return; |
| 572 | 576 |
| 573 // If there is no public account with the given |username|, logging in is not | 577 // If there is no public account with the given |username|, logging in is not |
| 574 // possible. | 578 // possible. |
| 575 const User* user = UserManager::Get()->FindUser(username); | 579 const user_manager::User* user = UserManager::Get()->FindUser(username); |
| 576 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) { | 580 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) { |
| 577 // Re-enable clicking on other windows. | 581 // Re-enable clicking on other windows. |
| 578 login_display_->SetUIEnabled(true); | 582 login_display_->SetUIEnabled(true); |
| 579 StartPublicSessionAutoLoginTimer(); | 583 StartPublicSessionAutoLoginTimer(); |
| 580 return; | 584 return; |
| 581 } | 585 } |
| 582 | 586 |
| 583 // Only one instance of LoginPerformer should exist at a time. | 587 // Only one instance of LoginPerformer should exist at a time. |
| 584 login_performer_.reset(NULL); | 588 login_performer_.reset(NULL); |
| 585 login_performer_.reset(new LoginPerformer(this)); | 589 login_performer_.reset(new LoginPerformer(this)); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 public_session_auto_login_username_.clear(); | 990 public_session_auto_login_username_.clear(); |
| 987 for (std::vector<policy::DeviceLocalAccount>::const_iterator | 991 for (std::vector<policy::DeviceLocalAccount>::const_iterator |
| 988 it = device_local_accounts.begin(); | 992 it = device_local_accounts.begin(); |
| 989 it != device_local_accounts.end(); ++it) { | 993 it != device_local_accounts.end(); ++it) { |
| 990 if (it->account_id == auto_login_account_id) { | 994 if (it->account_id == auto_login_account_id) { |
| 991 public_session_auto_login_username_ = it->user_id; | 995 public_session_auto_login_username_ = it->user_id; |
| 992 break; | 996 break; |
| 993 } | 997 } |
| 994 } | 998 } |
| 995 | 999 |
| 996 const User* user = | 1000 const user_manager::User* user = |
| 997 UserManager::Get()->FindUser(public_session_auto_login_username_); | 1001 UserManager::Get()->FindUser(public_session_auto_login_username_); |
| 998 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) | 1002 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) |
| 999 public_session_auto_login_username_.clear(); | 1003 public_session_auto_login_username_.clear(); |
| 1000 | 1004 |
| 1001 if (!cros_settings_->GetInteger( | 1005 if (!cros_settings_->GetInteger( |
| 1002 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | 1006 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
| 1003 &public_session_auto_login_delay_)) { | 1007 &public_session_auto_login_delay_)) { |
| 1004 public_session_auto_login_delay_ = 0; | 1008 public_session_auto_login_delay_ = 0; |
| 1005 } | 1009 } |
| 1006 | 1010 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 break; | 1129 break; |
| 1126 default: | 1130 default: |
| 1127 help_topic_id = is_offline ? | 1131 help_topic_id = is_offline ? |
| 1128 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE : | 1132 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE : |
| 1129 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT; | 1133 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT; |
| 1130 break; | 1134 break; |
| 1131 } | 1135 } |
| 1132 | 1136 |
| 1133 if (error_id == IDS_LOGIN_ERROR_AUTHENTICATING) { | 1137 if (error_id == IDS_LOGIN_ERROR_AUTHENTICATING) { |
| 1134 if (num_login_attempts_ > 1) { | 1138 if (num_login_attempts_ > 1) { |
| 1135 const User* user = | 1139 const user_manager::User* user = |
| 1136 UserManager::Get()->FindUser(last_login_attempt_username_); | 1140 UserManager::Get()->FindUser(last_login_attempt_username_); |
| 1137 if (user && (user->GetType() == user_manager::USER_TYPE_SUPERVISED)) | 1141 if (user && (user->GetType() == user_manager::USER_TYPE_SUPERVISED)) |
| 1138 error_id = IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME_SUPERVISED; | 1142 error_id = IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME_SUPERVISED; |
| 1139 } | 1143 } |
| 1140 } | 1144 } |
| 1141 | 1145 |
| 1142 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id); | 1146 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id); |
| 1143 } | 1147 } |
| 1144 | 1148 |
| 1145 void ExistingUserController::ShowGaiaPasswordChanged( | 1149 void ExistingUserController::ShowGaiaPasswordChanged( |
| 1146 const std::string& username) { | 1150 const std::string& username) { |
| 1147 // Invalidate OAuth token, since it can't be correct after password is | 1151 // Invalidate OAuth token, since it can't be correct after password is |
| 1148 // changed. | 1152 // changed. |
| 1149 UserManager::Get()->SaveUserOAuthStatus( | 1153 UserManager::Get()->SaveUserOAuthStatus( |
| 1150 username, | 1154 username, user_manager::User::OAUTH2_TOKEN_STATUS_INVALID); |
| 1151 User::OAUTH2_TOKEN_STATUS_INVALID); | |
| 1152 | 1155 |
| 1153 login_display_->SetUIEnabled(true); | 1156 login_display_->SetUIEnabled(true); |
| 1154 login_display_->ShowGaiaPasswordChanged(username); | 1157 login_display_->ShowGaiaPasswordChanged(username); |
| 1155 } | 1158 } |
| 1156 | 1159 |
| 1157 void ExistingUserController::SendAccessibilityAlert( | 1160 void ExistingUserController::SendAccessibilityAlert( |
| 1158 const std::string& alert_text) { | 1161 const std::string& alert_text) { |
| 1159 AccessibilityAlertInfo event(ProfileHelper::GetSigninProfile(), alert_text); | 1162 AccessibilityAlertInfo event(ProfileHelper::GetSigninProfile(), alert_text); |
| 1160 SendControlAccessibilityNotification( | 1163 SendControlAccessibilityNotification( |
| 1161 ui::AX_EVENT_VALUE_CHANGED, &event); | 1164 ui::AX_EVENT_VALUE_CHANGED, &event); |
| 1162 } | 1165 } |
| 1163 | 1166 |
| 1164 } // namespace chromeos | 1167 } // namespace chromeos |
| OLD | NEW |