| 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 weak_factory_.GetWeakPtr())); | 422 weak_factory_.GetWeakPtr())); |
| 423 } | 423 } |
| 424 } | 424 } |
| 425 | 425 |
| 426 void UserSelectionScreen::OnUserStatusChecked( | 426 void UserSelectionScreen::OnUserStatusChecked( |
| 427 const AccountId& account_id, | 427 const AccountId& account_id, |
| 428 TokenHandleUtil::TokenHandleStatus status) { | 428 TokenHandleUtil::TokenHandleStatus status) { |
| 429 if (status == TokenHandleUtil::INVALID) { | 429 if (status == TokenHandleUtil::INVALID) { |
| 430 RecordReauthReason(account_id, ReauthReason::INVALID_TOKEN_HANDLE); | 430 RecordReauthReason(account_id, ReauthReason::INVALID_TOKEN_HANDLE); |
| 431 token_handle_util_->MarkHandleInvalid(account_id); | 431 token_handle_util_->MarkHandleInvalid(account_id); |
| 432 SetAuthType(account_id.GetUserEmail(), ONLINE_SIGN_IN, base::string16()); | 432 SetAuthType(account_id, ONLINE_SIGN_IN, base::string16()); |
| 433 } | 433 } |
| 434 } | 434 } |
| 435 | 435 |
| 436 // EasyUnlock stuff | 436 // EasyUnlock stuff |
| 437 | 437 |
| 438 void UserSelectionScreen::SetAuthType(const std::string& user_id, | 438 void UserSelectionScreen::SetAuthType(const AccountId& account_id, |
| 439 AuthType auth_type, | 439 AuthType auth_type, |
| 440 const base::string16& initial_value) { | 440 const base::string16& initial_value) { |
| 441 const AccountId& account_id = | 441 if (GetAuthType(account_id) == FORCE_OFFLINE_PASSWORD) |
| 442 user_manager::UserManager::GetKnownUserAccountId(user_id, std::string()); | |
| 443 if (GetAuthType(account_id.GetUserEmail()) == FORCE_OFFLINE_PASSWORD) | |
| 444 return; | 442 return; |
| 445 DCHECK(GetAuthType(account_id.GetUserEmail()) != FORCE_OFFLINE_PASSWORD || | 443 DCHECK(GetAuthType(account_id) != FORCE_OFFLINE_PASSWORD || |
| 446 auth_type == FORCE_OFFLINE_PASSWORD); | 444 auth_type == FORCE_OFFLINE_PASSWORD); |
| 447 user_auth_type_map_[account_id] = auth_type; | 445 user_auth_type_map_[account_id] = auth_type; |
| 448 view_->SetAuthType(account_id, auth_type, initial_value); | 446 view_->SetAuthType(account_id, auth_type, initial_value); |
| 449 } | 447 } |
| 450 | 448 |
| 451 proximity_auth::ScreenlockBridge::LockHandler::AuthType | 449 proximity_auth::ScreenlockBridge::LockHandler::AuthType |
| 452 UserSelectionScreen::GetAuthType(const std::string& username) const { | 450 UserSelectionScreen::GetAuthType(const AccountId& account_id) const { |
| 453 const AccountId& account_id = | |
| 454 user_manager::UserManager::GetKnownUserAccountId(username, std::string()); | |
| 455 if (user_auth_type_map_.find(account_id) == user_auth_type_map_.end()) | 451 if (user_auth_type_map_.find(account_id) == user_auth_type_map_.end()) |
| 456 return OFFLINE_PASSWORD; | 452 return OFFLINE_PASSWORD; |
| 457 return user_auth_type_map_.find(account_id)->second; | 453 return user_auth_type_map_.find(account_id)->second; |
| 458 } | 454 } |
| 459 | 455 |
| 460 proximity_auth::ScreenlockBridge::LockHandler::ScreenType | 456 proximity_auth::ScreenlockBridge::LockHandler::ScreenType |
| 461 UserSelectionScreen::GetScreenType() const { | 457 UserSelectionScreen::GetScreenType() const { |
| 462 if (display_type_ == OobeUI::kLockDisplay) | 458 if (display_type_ == OobeUI::kLockDisplay) |
| 463 return LOCK_SCREEN; | 459 return LOCK_SCREEN; |
| 464 | 460 |
| 465 if (display_type_ == OobeUI::kLoginDisplay) | 461 if (display_type_ == OobeUI::kLoginDisplay) |
| 466 return SIGNIN_SCREEN; | 462 return SIGNIN_SCREEN; |
| 467 | 463 |
| 468 return OTHER_SCREEN; | 464 return OTHER_SCREEN; |
| 469 } | 465 } |
| 470 | 466 |
| 471 void UserSelectionScreen::ShowBannerMessage(const base::string16& message) { | 467 void UserSelectionScreen::ShowBannerMessage(const base::string16& message) { |
| 472 view_->ShowBannerMessage(message); | 468 view_->ShowBannerMessage(message); |
| 473 } | 469 } |
| 474 | 470 |
| 475 void UserSelectionScreen::ShowUserPodCustomIcon( | 471 void UserSelectionScreen::ShowUserPodCustomIcon( |
| 476 const std::string& user_id, | 472 const AccountId& account_id, |
| 477 const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& | 473 const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& |
| 478 icon_options) { | 474 icon_options) { |
| 479 scoped_ptr<base::DictionaryValue> icon = icon_options.ToDictionaryValue(); | 475 scoped_ptr<base::DictionaryValue> icon = icon_options.ToDictionaryValue(); |
| 480 if (!icon || icon->empty()) | 476 if (!icon || icon->empty()) |
| 481 return; | 477 return; |
| 482 const AccountId account_id = | |
| 483 user_manager::UserManager::GetKnownUserAccountId(user_id, std::string()); | |
| 484 view_->ShowUserPodCustomIcon(account_id, *icon); | 478 view_->ShowUserPodCustomIcon(account_id, *icon); |
| 485 } | 479 } |
| 486 | 480 |
| 487 void UserSelectionScreen::HideUserPodCustomIcon(const std::string& user_id) { | 481 void UserSelectionScreen::HideUserPodCustomIcon(const AccountId& account_id) { |
| 488 const AccountId account_id = | |
| 489 user_manager::UserManager::GetKnownUserAccountId(user_id, std::string()); | |
| 490 view_->HideUserPodCustomIcon(account_id); | 482 view_->HideUserPodCustomIcon(account_id); |
| 491 } | 483 } |
| 492 | 484 |
| 493 void UserSelectionScreen::EnableInput() { | 485 void UserSelectionScreen::EnableInput() { |
| 494 // If Easy Unlock fails to unlock the screen, re-enable the password input. | 486 // If Easy Unlock fails to unlock the screen, re-enable the password input. |
| 495 // This is only necessary on the lock screen, because the error handling for | 487 // This is only necessary on the lock screen, because the error handling for |
| 496 // the sign-in screen uses a different code path. | 488 // the sign-in screen uses a different code path. |
| 497 if (ScreenLocker::default_screen_locker()) | 489 if (ScreenLocker::default_screen_locker()) |
| 498 ScreenLocker::default_screen_locker()->EnableInput(); | 490 ScreenLocker::default_screen_locker()->EnableInput(); |
| 499 } | 491 } |
| 500 | 492 |
| 501 void UserSelectionScreen::Unlock(const std::string& user_email) { | 493 void UserSelectionScreen::Unlock(const AccountId& account_id) { |
| 502 DCHECK_EQ(GetScreenType(), LOCK_SCREEN); | 494 DCHECK_EQ(GetScreenType(), LOCK_SCREEN); |
| 503 ScreenLocker::Hide(); | 495 ScreenLocker::Hide(); |
| 504 } | 496 } |
| 505 | 497 |
| 506 void UserSelectionScreen::AttemptEasySignin(const std::string& user_id, | 498 void UserSelectionScreen::AttemptEasySignin(const AccountId& account_id, |
| 507 const std::string& secret, | 499 const std::string& secret, |
| 508 const std::string& key_label) { | 500 const std::string& key_label) { |
| 509 DCHECK_EQ(GetScreenType(), SIGNIN_SCREEN); | 501 DCHECK_EQ(GetScreenType(), SIGNIN_SCREEN); |
| 510 | 502 |
| 511 UserContext user_context( | 503 UserContext user_context(account_id); |
| 512 user_manager::UserManager::GetKnownUserAccountId(user_id, std::string())); | |
| 513 user_context.SetAuthFlow(UserContext::AUTH_FLOW_EASY_UNLOCK); | 504 user_context.SetAuthFlow(UserContext::AUTH_FLOW_EASY_UNLOCK); |
| 514 user_context.SetKey(Key(secret)); | 505 user_context.SetKey(Key(secret)); |
| 515 user_context.GetKey()->SetLabel(key_label); | 506 user_context.GetKey()->SetLabel(key_label); |
| 516 | 507 |
| 517 login_display_delegate_->Login(user_context, SigninSpecifics()); | 508 login_display_delegate_->Login(user_context, SigninSpecifics()); |
| 518 } | 509 } |
| 519 | 510 |
| 520 void UserSelectionScreen::HardLockPod(const AccountId& account_id) { | 511 void UserSelectionScreen::HardLockPod(const AccountId& account_id) { |
| 521 view_->SetAuthType(account_id, OFFLINE_PASSWORD, base::string16()); | 512 view_->SetAuthType(account_id, OFFLINE_PASSWORD, base::string16()); |
| 522 EasyUnlockService* service = GetEasyUnlockServiceForUser(account_id); | 513 EasyUnlockService* service = GetEasyUnlockServiceForUser(account_id); |
| 523 if (!service) | 514 if (!service) |
| 524 return; | 515 return; |
| 525 service->SetHardlockState(EasyUnlockScreenlockStateHandler::USER_HARDLOCK); | 516 service->SetHardlockState(EasyUnlockScreenlockStateHandler::USER_HARDLOCK); |
| 526 } | 517 } |
| 527 | 518 |
| 528 void UserSelectionScreen::AttemptEasyUnlock(const AccountId& account_id) { | 519 void UserSelectionScreen::AttemptEasyUnlock(const AccountId& account_id) { |
| 529 EasyUnlockService* service = GetEasyUnlockServiceForUser(account_id); | 520 EasyUnlockService* service = GetEasyUnlockServiceForUser(account_id); |
| 530 if (!service) | 521 if (!service) |
| 531 return; | 522 return; |
| 532 service->AttemptAuth(account_id.GetUserEmail()); | 523 service->AttemptAuth(account_id); |
| 533 } | 524 } |
| 534 | 525 |
| 535 void UserSelectionScreen::RecordClickOnLockIcon(const AccountId& account_id) { | 526 void UserSelectionScreen::RecordClickOnLockIcon(const AccountId& account_id) { |
| 536 EasyUnlockService* service = GetEasyUnlockServiceForUser(account_id); | 527 EasyUnlockService* service = GetEasyUnlockServiceForUser(account_id); |
| 537 if (!service) | 528 if (!service) |
| 538 return; | 529 return; |
| 539 service->RecordClickOnLockIcon(); | 530 service->RecordClickOnLockIcon(); |
| 540 } | 531 } |
| 541 | 532 |
| 542 EasyUnlockService* UserSelectionScreen::GetEasyUnlockServiceForUser( | 533 EasyUnlockService* UserSelectionScreen::GetEasyUnlockServiceForUser( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 560 // The user profile should exist if and only if this is the lock screen. | 551 // The user profile should exist if and only if this is the lock screen. |
| 561 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); | 552 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); |
| 562 | 553 |
| 563 if (!profile) | 554 if (!profile) |
| 564 profile = profile_helper->GetSigninProfile(); | 555 profile = profile_helper->GetSigninProfile(); |
| 565 | 556 |
| 566 return EasyUnlockService::Get(profile); | 557 return EasyUnlockService::Get(profile); |
| 567 } | 558 } |
| 568 | 559 |
| 569 } // namespace chromeos | 560 } // namespace chromeos |
| OLD | NEW |