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