OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/lock/screen_locker.h" | 5 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 IDS_LOGIN_ERROR_AUTHENTICATING, | 190 IDS_LOGIN_ERROR_AUTHENTICATING, |
191 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); | 191 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
192 | 192 |
193 if (auth_status_consumer_) | 193 if (auth_status_consumer_) |
194 auth_status_consumer_->OnAuthFailure(error); | 194 auth_status_consumer_->OnAuthFailure(error); |
195 } | 195 } |
196 | 196 |
197 void ScreenLocker::OnAuthSuccess(const UserContext& user_context) { | 197 void ScreenLocker::OnAuthSuccess(const UserContext& user_context) { |
198 incorrect_passwords_count_ = 0; | 198 incorrect_passwords_count_ = 0; |
199 if (authentication_start_time_.is_null()) { | 199 if (authentication_start_time_.is_null()) { |
200 if (!user_context.GetUserID().empty()) | 200 if (user_context.GetAccountId().is_valid()) |
201 LOG(ERROR) << "Start time is not set at authentication success"; | 201 LOG(ERROR) << "Start time is not set at authentication success"; |
202 } else { | 202 } else { |
203 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; | 203 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; |
204 VLOG(1) << "Authentication success: " << delta.InSecondsF() << " second(s)"; | 204 VLOG(1) << "Authentication success: " << delta.InSecondsF() << " second(s)"; |
205 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationSuccessTime", delta); | 205 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationSuccessTime", delta); |
206 } | 206 } |
207 | 207 |
208 const user_manager::User* user = | 208 const user_manager::User* user = |
209 user_manager::UserManager::Get()->FindUser(user_context.GetUserID()); | 209 user_manager::UserManager::Get()->FindUser(user_context.GetAccountId()); |
210 if (user) { | 210 if (user) { |
211 if (!user->is_active()) { | 211 if (!user->is_active()) { |
212 saved_ime_state_ = NULL; | 212 saved_ime_state_ = NULL; |
213 user_manager::UserManager::Get()->SwitchActiveUser( | 213 user_manager::UserManager::Get()->SwitchActiveUser( |
214 user_context.GetUserID()); | 214 user_context.GetAccountId()); |
215 } | 215 } |
216 UserSessionManager::GetInstance()->UpdateEasyUnlockKeys(user_context); | 216 UserSessionManager::GetInstance()->UpdateEasyUnlockKeys(user_context); |
217 } else { | 217 } else { |
218 NOTREACHED() << "Logged in user not found."; | 218 NOTREACHED() << "Logged in user not found."; |
219 } | 219 } |
220 | 220 |
221 authentication_capture_.reset(new AuthenticationParametersCapture()); | 221 authentication_capture_.reset(new AuthenticationParametersCapture()); |
222 authentication_capture_->user_context = user_context; | 222 authentication_capture_->user_context = user_context; |
223 | 223 |
224 // Add guard for case when something get broken in call chain to unlock | 224 // Add guard for case when something get broken in call chain to unlock |
(...skipping 18 matching lines...) Expand all Loading... | |
243 auth_status_consumer_->OnAuthSuccess(authentication_capture_->user_context); | 243 auth_status_consumer_->OnAuthSuccess(authentication_capture_->user_context); |
244 } | 244 } |
245 authentication_capture_.reset(); | 245 authentication_capture_.reset(); |
246 weak_factory_.InvalidateWeakPtrs(); | 246 weak_factory_.InvalidateWeakPtrs(); |
247 | 247 |
248 VLOG(1) << "Hiding the lock screen."; | 248 VLOG(1) << "Hiding the lock screen."; |
249 chromeos::ScreenLocker::Hide(); | 249 chromeos::ScreenLocker::Hide(); |
250 } | 250 } |
251 | 251 |
252 void ScreenLocker::Authenticate(const UserContext& user_context) { | 252 void ScreenLocker::Authenticate(const UserContext& user_context) { |
253 LOG_ASSERT(IsUserLoggedIn(user_context.GetUserID())) | 253 LOG_ASSERT(IsUserLoggedIn(user_context.GetAccountId().GetUserEmail())) |
254 << "Invalid user trying to unlock."; | 254 << "Invalid user trying to unlock."; |
255 | 255 |
256 authentication_start_time_ = base::Time::Now(); | 256 authentication_start_time_ = base::Time::Now(); |
257 delegate_->SetInputEnabled(false); | 257 delegate_->SetInputEnabled(false); |
258 delegate_->OnAuthenticate(); | 258 delegate_->OnAuthenticate(); |
259 | 259 |
260 // Special case: supervised users. Use special authenticator. | 260 // Special case: supervised users. Use special authenticator. |
261 if (const user_manager::User* user = | 261 if (const user_manager::User* user = |
262 FindUnlockUser(user_context.GetUserID())) { | 262 FindUnlockUser(user_context.GetAccountId().GetUserEmail())) { |
263 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED) { | 263 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED) { |
264 UserContext updated_context = ChromeUserManager::Get() | 264 UserContext updated_context = ChromeUserManager::Get() |
265 ->GetSupervisedUserManager() | 265 ->GetSupervisedUserManager() |
266 ->GetAuthentication() | 266 ->GetAuthentication() |
267 ->TransformKey(user_context); | 267 ->TransformKey(user_context); |
268 // TODO(antrim) : replace empty closure with explicit method. | 268 // TODO(antrim) : replace empty closure with explicit method. |
269 // http://crbug.com/351268 | 269 // http://crbug.com/351268 |
270 BrowserThread::PostTask( | 270 BrowserThread::PostTask( |
271 BrowserThread::UI, | 271 BrowserThread::UI, |
272 FROM_HERE, | 272 FROM_HERE, |
273 base::Bind(&ExtendedAuthenticator::AuthenticateToCheck, | 273 base::Bind(&ExtendedAuthenticator::AuthenticateToCheck, |
274 extended_authenticator_.get(), | 274 extended_authenticator_.get(), |
275 updated_context, | 275 updated_context, |
276 base::Closure())); | 276 base::Closure())); |
277 return; | 277 return; |
278 } | 278 } |
279 } | 279 } |
280 | 280 |
281 BrowserThread::PostTask( | 281 BrowserThread::PostTask( |
282 BrowserThread::UI, FROM_HERE, | 282 BrowserThread::UI, FROM_HERE, |
283 base::Bind(&ExtendedAuthenticator::AuthenticateToCheck, | 283 base::Bind(&ExtendedAuthenticator::AuthenticateToCheck, |
284 extended_authenticator_.get(), | 284 extended_authenticator_.get(), |
285 user_context, | 285 user_context, |
286 base::Closure())); | 286 base::Closure())); |
287 } | 287 } |
288 | 288 |
289 const user_manager::User* ScreenLocker::FindUnlockUser( | 289 const user_manager::User* ScreenLocker::FindUnlockUser( |
290 const std::string& user_id) { | 290 const std::string& user_id) { |
achuithb
2015/10/28 23:11:45
AccountId?
Alexander Alekseev
2015/10/29 02:00:40
Sure. In another CL.
| |
291 const user_manager::User* unlock_user = NULL; | 291 const user_manager::User* unlock_user = NULL; |
292 for (user_manager::UserList::const_iterator it = users_.begin(); | 292 for (user_manager::UserList::const_iterator it = users_.begin(); |
293 it != users_.end(); | 293 it != users_.end(); |
294 ++it) { | 294 ++it) { |
295 if ((*it)->email() == user_id) { | 295 if ((*it)->email() == user_id) { |
296 unlock_user = *it; | 296 unlock_user = *it; |
297 break; | 297 break; |
298 } | 298 } |
299 } | 299 } |
300 return unlock_user; | 300 return unlock_user; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
494 | 494 |
495 input_method::InputMethodManager::Get() | 495 input_method::InputMethodManager::Get() |
496 ->GetActiveIMEState() | 496 ->GetActiveIMEState() |
497 ->EnableLockScreenLayouts(); | 497 ->EnableLockScreenLayouts(); |
498 } | 498 } |
499 | 499 |
500 content::WebUI* ScreenLocker::GetAssociatedWebUI() { | 500 content::WebUI* ScreenLocker::GetAssociatedWebUI() { |
501 return delegate_->GetAssociatedWebUI(); | 501 return delegate_->GetAssociatedWebUI(); |
502 } | 502 } |
503 | 503 |
504 bool ScreenLocker::IsUserLoggedIn(const std::string& username) { | 504 bool ScreenLocker::IsUserLoggedIn(const std::string& username) { |
achuithb
2015/10/28 23:11:45
AccountId instead?
Alexander Alekseev
2015/10/29 02:00:40
In another CL.
| |
505 for (user_manager::UserList::const_iterator it = users_.begin(); | 505 for (user_manager::UserList::const_iterator it = users_.begin(); |
506 it != users_.end(); | 506 it != users_.end(); |
507 ++it) { | 507 ++it) { |
508 if ((*it)->email() == username) | 508 if ((*it)->email() == username) |
509 return true; | 509 return true; |
510 } | 510 } |
511 return false; | 511 return false; |
512 } | 512 } |
513 | 513 |
514 } // namespace chromeos | 514 } // namespace chromeos |
OLD | NEW |