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/screens/user_selection_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/user_selection_screen.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 bool is_signin_to_add, | 141 bool is_signin_to_add, |
142 AuthType auth_type, | 142 AuthType auth_type, |
143 const std::vector<std::string>* public_session_recommended_locales, | 143 const std::vector<std::string>* public_session_recommended_locales, |
144 base::DictionaryValue* user_dict) { | 144 base::DictionaryValue* user_dict) { |
145 const bool is_public_session = | 145 const bool is_public_session = |
146 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT; | 146 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT; |
147 const bool is_legacy_supervised_user = | 147 const bool is_legacy_supervised_user = |
148 user->GetType() == user_manager::USER_TYPE_SUPERVISED; | 148 user->GetType() == user_manager::USER_TYPE_SUPERVISED; |
149 const bool is_child_user = user->GetType() == user_manager::USER_TYPE_CHILD; | 149 const bool is_child_user = user->GetType() == user_manager::USER_TYPE_CHILD; |
150 | 150 |
151 user_dict->SetString(kKeyUsername, user->GetAccountId().GetUserEmail()); | 151 user_dict->SetString(kKeyUsername, user->GetAccountId().Serialize()); |
152 user_dict->SetString(kKeyEmailAddress, user->display_email()); | 152 user_dict->SetString(kKeyEmailAddress, user->display_email()); |
153 user_dict->SetString(kKeyDisplayName, user->GetDisplayName()); | 153 user_dict->SetString(kKeyDisplayName, user->GetDisplayName()); |
154 user_dict->SetBoolean(kKeyPublicAccount, is_public_session); | 154 user_dict->SetBoolean(kKeyPublicAccount, is_public_session); |
155 user_dict->SetBoolean(kKeyLegacySupervisedUser, is_legacy_supervised_user); | 155 user_dict->SetBoolean(kKeyLegacySupervisedUser, is_legacy_supervised_user); |
156 user_dict->SetBoolean(kKeyChildUser, is_child_user); | 156 user_dict->SetBoolean(kKeyChildUser, is_child_user); |
157 user_dict->SetBoolean(kKeyDesktopUser, false); | 157 user_dict->SetBoolean(kKeyDesktopUser, false); |
158 user_dict->SetInteger(kKeyInitialAuthType, auth_type); | 158 user_dict->SetInteger(kKeyInitialAuthType, auth_type); |
159 user_dict->SetBoolean(kKeySignedIn, user->is_logged_in()); | 159 user_dict->SetBoolean(kKeySignedIn, user->is_logged_in()); |
160 user_dict->SetBoolean(kKeyIsOwner, is_owner); | 160 user_dict->SetBoolean(kKeyIsOwner, is_owner); |
161 | 161 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 // At this point the reason for invalid token should be already set. If not, | 239 // At this point the reason for invalid token should be already set. If not, |
240 // this might be a leftover from an old version. | 240 // this might be a leftover from an old version. |
241 if (token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) | 241 if (token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) |
242 RecordReauthReason(user->GetAccountId(), ReauthReason::OTHER); | 242 RecordReauthReason(user->GetAccountId(), ReauthReason::OTHER); |
243 | 243 |
244 return user->force_online_signin() || | 244 return user->force_online_signin() || |
245 (token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) || | 245 (token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) || |
246 (token_status == user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN); | 246 (token_status == user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN); |
247 } | 247 } |
248 | 248 |
249 // static | |
250 AccountId UserSelectionScreen::GetAccountIdOfKnownUser( | |
251 const std::string& user_id) { | |
252 if (user_id.empty()) | |
253 return EmptyAccountId(); | |
oshima
2015/11/13 15:45:10
can this happen? The caller of this seems to acces
Alexander Alekseev
2015/11/13 16:04:11
This happens for me in tests
(For example, when de
| |
254 | |
255 const AccountId initial_account_id(AccountId::FromUserEmail(user_id)); | |
256 | |
257 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | |
258 if (!user_manager) | |
259 return initial_account_id; | |
260 | |
261 AccountId known_account_id(EmptyAccountId()); | |
262 if (user_manager->GetKnownUserAccountId(initial_account_id, | |
263 &known_account_id)) | |
264 return known_account_id; | |
265 | |
266 return initial_account_id; | |
267 } | |
268 | |
249 void UserSelectionScreen::SetHandler(LoginDisplayWebUIHandler* handler) { | 269 void UserSelectionScreen::SetHandler(LoginDisplayWebUIHandler* handler) { |
250 handler_ = handler; | 270 handler_ = handler; |
251 } | 271 } |
252 | 272 |
253 void UserSelectionScreen::SetView(UserBoardView* view) { | 273 void UserSelectionScreen::SetView(UserBoardView* view) { |
254 view_ = view; | 274 view_ = view; |
255 } | 275 } |
256 | 276 |
257 void UserSelectionScreen::Init(const user_manager::UserList& users, | 277 void UserSelectionScreen::Init(const user_manager::UserList& users, |
258 bool show_guest) { | 278 bool show_guest) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 base::TimeDelta::FromSeconds(kPasswordClearTimeoutSec), | 319 base::TimeDelta::FromSeconds(kPasswordClearTimeoutSec), |
300 this, | 320 this, |
301 &UserSelectionScreen::OnPasswordClearTimerExpired); | 321 &UserSelectionScreen::OnPasswordClearTimerExpired); |
302 } | 322 } |
303 password_clear_timer_.Reset(); | 323 password_clear_timer_.Reset(); |
304 } | 324 } |
305 | 325 |
306 // static | 326 // static |
307 const user_manager::UserList UserSelectionScreen::PrepareUserListForSending( | 327 const user_manager::UserList UserSelectionScreen::PrepareUserListForSending( |
308 const user_manager::UserList& users, | 328 const user_manager::UserList& users, |
309 std::string owner, | 329 const AccountId& owner, |
310 bool is_signin_to_add) { | 330 bool is_signin_to_add) { |
311 user_manager::UserList users_to_send; | 331 user_manager::UserList users_to_send; |
312 bool has_owner = owner.size() > 0; | 332 bool has_owner = owner.is_valid(); |
313 size_t max_non_owner_users = has_owner ? kMaxUsers - 1 : kMaxUsers; | 333 size_t max_non_owner_users = has_owner ? kMaxUsers - 1 : kMaxUsers; |
314 size_t non_owner_count = 0; | 334 size_t non_owner_count = 0; |
315 | 335 |
316 for (user_manager::UserList::const_iterator it = users.begin(); | 336 for (user_manager::UserList::const_iterator it = users.begin(); |
317 it != users.end(); | 337 it != users.end(); |
318 ++it) { | 338 ++it) { |
319 const std::string& user_id = (*it)->email(); | 339 bool is_owner = ((*it)->GetAccountId() == owner); |
320 bool is_owner = (user_id == owner); | |
321 bool is_public_account = | 340 bool is_public_account = |
322 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); | 341 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); |
323 | 342 |
324 if ((is_public_account && !is_signin_to_add) || is_owner || | 343 if ((is_public_account && !is_signin_to_add) || is_owner || |
325 (!is_public_account && non_owner_count < max_non_owner_users)) { | 344 (!is_public_account && non_owner_count < max_non_owner_users)) { |
326 | 345 |
327 if (!is_owner) | 346 if (!is_owner) |
328 ++non_owner_count; | 347 ++non_owner_count; |
329 if (is_owner && users_to_send.size() > kMaxUsers) { | 348 if (is_owner && users_to_send.size() > kMaxUsers) { |
330 // Owner is always in the list. | 349 // Owner is always in the list. |
331 users_to_send.insert(users_to_send.begin() + (kMaxUsers - 1), *it); | 350 users_to_send.insert(users_to_send.begin() + (kMaxUsers - 1), *it); |
332 while (users_to_send.size() > kMaxUsers) | 351 while (users_to_send.size() > kMaxUsers) |
333 users_to_send.erase(users_to_send.begin() + kMaxUsers); | 352 users_to_send.erase(users_to_send.begin() + kMaxUsers); |
334 } else if (users_to_send.size() < kMaxUsers) { | 353 } else if (users_to_send.size() < kMaxUsers) { |
335 users_to_send.push_back(*it); | 354 users_to_send.push_back(*it); |
336 } | 355 } |
337 } | 356 } |
338 } | 357 } |
339 return users_to_send; | 358 return users_to_send; |
340 } | 359 } |
341 | 360 |
342 void UserSelectionScreen::SendUserList() { | 361 void UserSelectionScreen::SendUserList() { |
343 base::ListValue users_list; | 362 base::ListValue users_list; |
344 | 363 |
345 // TODO(nkostylev): Move to a separate method in UserManager. | 364 // TODO(nkostylev): Move to a separate method in UserManager. |
346 // http://crbug.com/230852 | 365 // http://crbug.com/230852 |
347 bool single_user = users_.size() == 1; | 366 bool single_user = users_.size() == 1; |
348 bool is_signin_to_add = LoginDisplayHostImpl::default_host() && | 367 bool is_signin_to_add = LoginDisplayHostImpl::default_host() && |
349 user_manager::UserManager::Get()->IsUserLoggedIn(); | 368 user_manager::UserManager::Get()->IsUserLoggedIn(); |
350 std::string owner; | 369 std::string owner_email; |
351 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); | 370 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, |
371 &owner_email); | |
372 const AccountId owner(GetAccountIdOfKnownUser(owner_email)); | |
352 | 373 |
353 policy::BrowserPolicyConnectorChromeOS* connector = | 374 policy::BrowserPolicyConnectorChromeOS* connector = |
354 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 375 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
355 bool is_enterprise_managed = connector->IsEnterpriseManaged(); | 376 bool is_enterprise_managed = connector->IsEnterpriseManaged(); |
356 | 377 |
357 const user_manager::UserList users_to_send = | 378 const user_manager::UserList users_to_send = |
358 PrepareUserListForSending(users_, owner, is_signin_to_add); | 379 PrepareUserListForSending(users_, owner, is_signin_to_add); |
359 | 380 |
360 user_auth_type_map_.clear(); | 381 user_auth_type_map_.clear(); |
361 | 382 |
362 const std::vector<std::string> kEmptyRecommendedLocales; | 383 const std::vector<std::string> kEmptyRecommendedLocales; |
363 for (user_manager::UserList::const_iterator it = users_to_send.begin(); | 384 for (user_manager::UserList::const_iterator it = users_to_send.begin(); |
364 it != users_to_send.end(); | 385 it != users_to_send.end(); |
365 ++it) { | 386 ++it) { |
366 const std::string& user_id = (*it)->email(); | 387 const AccountId& account_id = (*it)->GetAccountId(); |
367 bool is_owner = (user_id == owner); | 388 bool is_owner = (account_id == owner); |
368 const bool is_public_account = | 389 const bool is_public_account = |
369 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); | 390 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); |
370 const AuthType initial_auth_type = | 391 const AuthType initial_auth_type = |
371 is_public_account ? EXPAND_THEN_USER_CLICK | 392 is_public_account ? EXPAND_THEN_USER_CLICK |
372 : (ShouldForceOnlineSignIn(*it) ? ONLINE_SIGN_IN | 393 : (ShouldForceOnlineSignIn(*it) ? ONLINE_SIGN_IN |
373 : OFFLINE_PASSWORD); | 394 : OFFLINE_PASSWORD); |
374 user_auth_type_map_[user_id] = initial_auth_type; | 395 user_auth_type_map_[account_id] = initial_auth_type; |
375 | 396 |
376 base::DictionaryValue* user_dict = new base::DictionaryValue(); | 397 base::DictionaryValue* user_dict = new base::DictionaryValue(); |
377 const std::vector<std::string>* public_session_recommended_locales = | 398 const std::vector<std::string>* public_session_recommended_locales = |
378 public_session_recommended_locales_.find(user_id) == | 399 public_session_recommended_locales_.find(account_id) == |
379 public_session_recommended_locales_.end() ? | 400 public_session_recommended_locales_.end() |
380 &kEmptyRecommendedLocales : | 401 ? &kEmptyRecommendedLocales |
381 &public_session_recommended_locales_[user_id]; | 402 : &public_session_recommended_locales_[account_id]; |
382 FillUserDictionary(*it, | 403 FillUserDictionary(*it, |
383 is_owner, | 404 is_owner, |
384 is_signin_to_add, | 405 is_signin_to_add, |
385 initial_auth_type, | 406 initial_auth_type, |
386 public_session_recommended_locales, | 407 public_session_recommended_locales, |
387 user_dict); | 408 user_dict); |
388 bool signed_in = (*it)->is_logged_in(); | 409 bool signed_in = (*it)->is_logged_in(); |
389 | 410 |
390 // Single user check here is necessary because owner info might not be | 411 // Single user check here is necessary because owner info might not be |
391 // available when running into login screen on first boot. | 412 // available when running into login screen on first boot. |
392 // See http://crosbug.com/12723 | 413 // See http://crosbug.com/12723 |
393 bool can_remove_user = | 414 bool can_remove_user = |
394 ((!single_user || is_enterprise_managed) && !user_id.empty() && | 415 ((!single_user || is_enterprise_managed) && account_id.is_valid() && |
395 !is_owner && !is_public_account && !signed_in && !is_signin_to_add); | 416 !is_owner && !is_public_account && !signed_in && !is_signin_to_add); |
396 user_dict->SetBoolean(kKeyCanRemove, can_remove_user); | 417 user_dict->SetBoolean(kKeyCanRemove, can_remove_user); |
397 users_list.Append(user_dict); | 418 users_list.Append(user_dict); |
398 } | 419 } |
399 | 420 |
400 handler_->LoadUsers(users_list, show_guest_); | 421 handler_->LoadUsers(users_list, show_guest_); |
401 } | 422 } |
402 | 423 |
403 void UserSelectionScreen::HandleGetUsers() { | 424 void UserSelectionScreen::HandleGetUsers() { |
404 SendUserList(); | 425 SendUserList(); |
405 } | 426 } |
406 | 427 |
407 void UserSelectionScreen::CheckUserStatus(const std::string& user_email) { | 428 void UserSelectionScreen::CheckUserStatus(const AccountId& account_id) { |
408 // No checks on lock screen. | 429 // No checks on lock screen. |
409 if (ScreenLocker::default_screen_locker()) | 430 if (ScreenLocker::default_screen_locker()) |
410 return; | 431 return; |
411 | 432 |
412 if (!token_handle_util_.get()) { | 433 if (!token_handle_util_.get()) { |
413 token_handle_util_.reset( | 434 token_handle_util_.reset( |
414 new TokenHandleUtil(user_manager::UserManager::Get())); | 435 new TokenHandleUtil(user_manager::UserManager::Get())); |
415 } | 436 } |
416 | 437 |
417 const AccountId account_id = AccountId::FromUserEmail(user_email); | |
418 if (token_handle_util_->HasToken(account_id)) { | 438 if (token_handle_util_->HasToken(account_id)) { |
419 token_handle_util_->CheckToken( | 439 token_handle_util_->CheckToken( |
420 account_id, base::Bind(&UserSelectionScreen::OnUserStatusChecked, | 440 account_id, base::Bind(&UserSelectionScreen::OnUserStatusChecked, |
421 weak_factory_.GetWeakPtr())); | 441 weak_factory_.GetWeakPtr())); |
422 } | 442 } |
423 } | 443 } |
424 | 444 |
425 void UserSelectionScreen::OnUserStatusChecked( | 445 void UserSelectionScreen::OnUserStatusChecked( |
426 const AccountId& account_id, | 446 const AccountId& account_id, |
427 TokenHandleUtil::TokenHandleStatus status) { | 447 TokenHandleUtil::TokenHandleStatus status) { |
428 if (status == TokenHandleUtil::INVALID) { | 448 if (status == TokenHandleUtil::INVALID) { |
429 RecordReauthReason(account_id, ReauthReason::INVALID_TOKEN_HANDLE); | 449 RecordReauthReason(account_id, ReauthReason::INVALID_TOKEN_HANDLE); |
430 token_handle_util_->MarkHandleInvalid(account_id); | 450 token_handle_util_->MarkHandleInvalid(account_id); |
431 SetAuthType(account_id.GetUserEmail(), ONLINE_SIGN_IN, base::string16()); | 451 SetAuthType(account_id.GetUserEmail(), ONLINE_SIGN_IN, base::string16()); |
432 } | 452 } |
433 } | 453 } |
434 | 454 |
435 // EasyUnlock stuff | 455 // EasyUnlock stuff |
436 | 456 |
437 void UserSelectionScreen::SetAuthType(const std::string& user_id, | 457 void UserSelectionScreen::SetAuthType(const std::string& user_id, |
438 AuthType auth_type, | 458 AuthType auth_type, |
439 const base::string16& initial_value) { | 459 const base::string16& initial_value) { |
440 if (GetAuthType(user_id) == FORCE_OFFLINE_PASSWORD) | 460 const AccountId& account_id(GetAccountIdOfKnownUser(user_id)); |
461 if (GetAuthType(account_id.GetUserEmail()) == FORCE_OFFLINE_PASSWORD) | |
441 return; | 462 return; |
442 DCHECK(GetAuthType(user_id) != FORCE_OFFLINE_PASSWORD || | 463 DCHECK(GetAuthType(account_id.GetUserEmail()) != FORCE_OFFLINE_PASSWORD || |
443 auth_type == FORCE_OFFLINE_PASSWORD); | 464 auth_type == FORCE_OFFLINE_PASSWORD); |
444 user_auth_type_map_[user_id] = auth_type; | 465 user_auth_type_map_[account_id] = auth_type; |
445 view_->SetAuthType(user_id, auth_type, initial_value); | 466 view_->SetAuthType(account_id, auth_type, initial_value); |
446 } | 467 } |
447 | 468 |
448 proximity_auth::ScreenlockBridge::LockHandler::AuthType | 469 proximity_auth::ScreenlockBridge::LockHandler::AuthType |
449 UserSelectionScreen::GetAuthType(const std::string& username) const { | 470 UserSelectionScreen::GetAuthType(const std::string& username) const { |
450 if (user_auth_type_map_.find(username) == user_auth_type_map_.end()) | 471 const AccountId& account_id(GetAccountIdOfKnownUser(username)); |
472 if (user_auth_type_map_.find(account_id) == user_auth_type_map_.end()) | |
451 return OFFLINE_PASSWORD; | 473 return OFFLINE_PASSWORD; |
452 return user_auth_type_map_.find(username)->second; | 474 return user_auth_type_map_.find(account_id)->second; |
453 } | 475 } |
454 | 476 |
455 proximity_auth::ScreenlockBridge::LockHandler::ScreenType | 477 proximity_auth::ScreenlockBridge::LockHandler::ScreenType |
456 UserSelectionScreen::GetScreenType() const { | 478 UserSelectionScreen::GetScreenType() const { |
457 if (display_type_ == OobeUI::kLockDisplay) | 479 if (display_type_ == OobeUI::kLockDisplay) |
458 return LOCK_SCREEN; | 480 return LOCK_SCREEN; |
459 | 481 |
460 if (display_type_ == OobeUI::kLoginDisplay) | 482 if (display_type_ == OobeUI::kLoginDisplay) |
461 return SIGNIN_SCREEN; | 483 return SIGNIN_SCREEN; |
462 | 484 |
463 return OTHER_SCREEN; | 485 return OTHER_SCREEN; |
464 } | 486 } |
465 | 487 |
466 void UserSelectionScreen::ShowBannerMessage(const base::string16& message) { | 488 void UserSelectionScreen::ShowBannerMessage(const base::string16& message) { |
467 view_->ShowBannerMessage(message); | 489 view_->ShowBannerMessage(message); |
468 } | 490 } |
469 | 491 |
470 void UserSelectionScreen::ShowUserPodCustomIcon( | 492 void UserSelectionScreen::ShowUserPodCustomIcon( |
471 const std::string& user_id, | 493 const std::string& user_id, |
472 const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& | 494 const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& |
473 icon_options) { | 495 icon_options) { |
474 scoped_ptr<base::DictionaryValue> icon = icon_options.ToDictionaryValue(); | 496 scoped_ptr<base::DictionaryValue> icon = icon_options.ToDictionaryValue(); |
475 if (!icon || icon->empty()) | 497 if (!icon || icon->empty()) |
476 return; | 498 return; |
477 view_->ShowUserPodCustomIcon(user_id, *icon); | 499 const AccountId account_id(GetAccountIdOfKnownUser(user_id)); |
500 view_->ShowUserPodCustomIcon(account_id, *icon); | |
478 } | 501 } |
479 | 502 |
480 void UserSelectionScreen::HideUserPodCustomIcon(const std::string& user_id) { | 503 void UserSelectionScreen::HideUserPodCustomIcon(const std::string& user_id) { |
481 view_->HideUserPodCustomIcon(user_id); | 504 const AccountId account_id(GetAccountIdOfKnownUser(user_id)); |
505 view_->HideUserPodCustomIcon(account_id); | |
482 } | 506 } |
483 | 507 |
484 void UserSelectionScreen::EnableInput() { | 508 void UserSelectionScreen::EnableInput() { |
485 // If Easy Unlock fails to unlock the screen, re-enable the password input. | 509 // If Easy Unlock fails to unlock the screen, re-enable the password input. |
486 // This is only necessary on the lock screen, because the error handling for | 510 // This is only necessary on the lock screen, because the error handling for |
487 // the sign-in screen uses a different code path. | 511 // the sign-in screen uses a different code path. |
488 if (ScreenLocker::default_screen_locker()) | 512 if (ScreenLocker::default_screen_locker()) |
489 ScreenLocker::default_screen_locker()->EnableInput(); | 513 ScreenLocker::default_screen_locker()->EnableInput(); |
490 } | 514 } |
491 | 515 |
492 void UserSelectionScreen::Unlock(const std::string& user_email) { | 516 void UserSelectionScreen::Unlock(const std::string& user_email) { |
493 DCHECK_EQ(GetScreenType(), LOCK_SCREEN); | 517 DCHECK_EQ(GetScreenType(), LOCK_SCREEN); |
494 ScreenLocker::Hide(); | 518 ScreenLocker::Hide(); |
495 } | 519 } |
496 | 520 |
497 void UserSelectionScreen::AttemptEasySignin(const std::string& user_id, | 521 void UserSelectionScreen::AttemptEasySignin(const std::string& user_id, |
498 const std::string& secret, | 522 const std::string& secret, |
499 const std::string& key_label) { | 523 const std::string& key_label) { |
500 DCHECK_EQ(GetScreenType(), SIGNIN_SCREEN); | 524 DCHECK_EQ(GetScreenType(), SIGNIN_SCREEN); |
501 | 525 |
502 UserContext user_context(AccountId::FromUserEmail(user_id)); | 526 UserContext user_context(GetAccountIdOfKnownUser(user_id)); |
503 user_context.SetAuthFlow(UserContext::AUTH_FLOW_EASY_UNLOCK); | 527 user_context.SetAuthFlow(UserContext::AUTH_FLOW_EASY_UNLOCK); |
504 user_context.SetKey(Key(secret)); | 528 user_context.SetKey(Key(secret)); |
505 user_context.GetKey()->SetLabel(key_label); | 529 user_context.GetKey()->SetLabel(key_label); |
506 | 530 |
507 login_display_delegate_->Login(user_context, SigninSpecifics()); | 531 login_display_delegate_->Login(user_context, SigninSpecifics()); |
508 } | 532 } |
509 | 533 |
510 void UserSelectionScreen::HardLockPod(const std::string& user_id) { | 534 void UserSelectionScreen::HardLockPod(const AccountId& account_id) { |
511 view_->SetAuthType(user_id, OFFLINE_PASSWORD, base::string16()); | 535 view_->SetAuthType(account_id, OFFLINE_PASSWORD, base::string16()); |
512 EasyUnlockService* service = GetEasyUnlockServiceForUser(user_id); | 536 EasyUnlockService* service = GetEasyUnlockServiceForUser(account_id); |
513 if (!service) | 537 if (!service) |
514 return; | 538 return; |
515 service->SetHardlockState(EasyUnlockScreenlockStateHandler::USER_HARDLOCK); | 539 service->SetHardlockState(EasyUnlockScreenlockStateHandler::USER_HARDLOCK); |
516 } | 540 } |
517 | 541 |
518 void UserSelectionScreen::AttemptEasyUnlock(const std::string& user_id) { | 542 void UserSelectionScreen::AttemptEasyUnlock(const AccountId& account_id) { |
519 EasyUnlockService* service = GetEasyUnlockServiceForUser(user_id); | 543 EasyUnlockService* service = GetEasyUnlockServiceForUser(account_id); |
520 if (!service) | 544 if (!service) |
521 return; | 545 return; |
522 service->AttemptAuth(user_id); | 546 service->AttemptAuth(account_id.GetUserEmail()); |
523 } | 547 } |
524 | 548 |
525 void UserSelectionScreen::RecordClickOnLockIcon(const std::string& user_id) { | 549 void UserSelectionScreen::RecordClickOnLockIcon(const AccountId& account_id) { |
526 EasyUnlockService* service = GetEasyUnlockServiceForUser(user_id); | 550 EasyUnlockService* service = GetEasyUnlockServiceForUser(account_id); |
527 if (!service) | 551 if (!service) |
528 return; | 552 return; |
529 service->RecordClickOnLockIcon(); | 553 service->RecordClickOnLockIcon(); |
530 } | 554 } |
531 | 555 |
532 EasyUnlockService* UserSelectionScreen::GetEasyUnlockServiceForUser( | 556 EasyUnlockService* UserSelectionScreen::GetEasyUnlockServiceForUser( |
533 const std::string& user_id) const { | 557 const AccountId& account_id) const { |
534 if (GetScreenType() == OTHER_SCREEN) | 558 if (GetScreenType() == OTHER_SCREEN) |
535 return nullptr; | 559 return nullptr; |
536 | 560 |
537 const user_manager::User* unlock_user = nullptr; | 561 const user_manager::User* unlock_user = nullptr; |
538 for (const user_manager::User* user : users_) { | 562 for (const user_manager::User* user : users_) { |
539 if (user->email() == user_id) { | 563 if (user->GetAccountId() == account_id) { |
540 unlock_user = user; | 564 unlock_user = user; |
541 break; | 565 break; |
542 } | 566 } |
543 } | 567 } |
544 if (!unlock_user) | 568 if (!unlock_user) |
545 return nullptr; | 569 return nullptr; |
546 | 570 |
547 ProfileHelper* profile_helper = ProfileHelper::Get(); | 571 ProfileHelper* profile_helper = ProfileHelper::Get(); |
548 Profile* profile = profile_helper->GetProfileByUser(unlock_user); | 572 Profile* profile = profile_helper->GetProfileByUser(unlock_user); |
549 | 573 |
550 // The user profile should exist if and only if this is the lock screen. | 574 // The user profile should exist if and only if this is the lock screen. |
551 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); | 575 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); |
552 | 576 |
553 if (!profile) | 577 if (!profile) |
554 profile = profile_helper->GetSigninProfile(); | 578 profile = profile_helper->GetSigninProfile(); |
555 | 579 |
556 return EasyUnlockService::Get(profile); | 580 return EasyUnlockService::Get(profile); |
557 } | 581 } |
558 | 582 |
559 } // namespace chromeos | 583 } // namespace chromeos |
OLD | NEW |