Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: chrome/browser/chromeos/login/screens/user_selection_screen.cc

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 136 }
137 137
138 // static 138 // static
139 void UserSelectionScreen::FillUserDictionary( 139 void UserSelectionScreen::FillUserDictionary(
140 user_manager::User* user, 140 user_manager::User* user,
141 bool is_owner, 141 bool is_owner,
142 bool is_signin_to_add, 142 bool is_signin_to_add,
143 AuthType auth_type, 143 AuthType auth_type,
144 const std::vector<std::string>* public_session_recommended_locales, 144 const std::vector<std::string>* public_session_recommended_locales,
145 base::DictionaryValue* user_dict) { 145 base::DictionaryValue* user_dict) {
146 const user_manager::UserID user_id = user->email(); 146 const user_manager::UserID user_id = user->GetUserID();
147 const bool is_public_session = 147 const bool is_public_session =
148 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT; 148 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT;
149 const bool is_legacy_supervised_user = 149 const bool is_legacy_supervised_user =
150 user->GetType() == user_manager::USER_TYPE_SUPERVISED; 150 user->GetType() == user_manager::USER_TYPE_SUPERVISED;
151 const bool is_child_user = user->GetType() == user_manager::USER_TYPE_CHILD; 151 const bool is_child_user = user->GetType() == user_manager::USER_TYPE_CHILD;
152 152
153 user_dict->SetString(kKeyUsername, user_id); 153 user_dict->SetString(kKeyUsername, user_id.GetUserEmail());
154 user_dict->SetString(kKeyEmailAddress, user->display_email()); 154 user_dict->SetString(kKeyEmailAddress, user->display_email());
155 user_dict->SetString(kKeyDisplayName, user->GetDisplayName()); 155 user_dict->SetString(kKeyDisplayName, user->GetDisplayName());
156 user_dict->SetBoolean(kKeyPublicAccount, is_public_session); 156 user_dict->SetBoolean(kKeyPublicAccount, is_public_session);
157 user_dict->SetBoolean(kKeyLegacySupervisedUser, is_legacy_supervised_user); 157 user_dict->SetBoolean(kKeyLegacySupervisedUser, is_legacy_supervised_user);
158 user_dict->SetBoolean(kKeyChildUser, is_child_user); 158 user_dict->SetBoolean(kKeyChildUser, is_child_user);
159 user_dict->SetBoolean(kKeyDesktopUser, false); 159 user_dict->SetBoolean(kKeyDesktopUser, false);
160 user_dict->SetInteger(kKeyInitialAuthType, auth_type); 160 user_dict->SetInteger(kKeyInitialAuthType, auth_type);
161 user_dict->SetBoolean(kKeySignedIn, user->is_logged_in()); 161 user_dict->SetBoolean(kKeySignedIn, user->is_logged_in());
162 user_dict->SetBoolean(kKeyIsOwner, is_owner); 162 user_dict->SetBoolean(kKeyIsOwner, is_owner);
163 163
164 FillMultiProfileUserPrefs(user, user_dict, is_signin_to_add); 164 FillMultiProfileUserPrefs(user, user_dict, is_signin_to_add);
165 FillKnownUserPrefs(user, user_dict); 165 FillKnownUserPrefs(user, user_dict);
166 166
167 if (is_public_session) { 167 if (is_public_session) {
168 AddPublicSessionDetailsToUserDictionaryEntry( 168 AddPublicSessionDetailsToUserDictionaryEntry(
169 user_dict, public_session_recommended_locales); 169 user_dict, public_session_recommended_locales);
170 } 170 }
171 } 171 }
172 172
173 // static 173 // static
174 void UserSelectionScreen::FillKnownUserPrefs(user_manager::User* user, 174 void UserSelectionScreen::FillKnownUserPrefs(user_manager::User* user,
175 base::DictionaryValue* user_dict) { 175 base::DictionaryValue* user_dict) {
176 std::string gaia_id; 176 std::string gaia_id;
177 if (user_manager::UserManager::Get()->FindGaiaID(user->email(), &gaia_id)) { 177 if (user_manager::UserManager::Get()->FindGaiaID(user->GetUserID(), &gaia_id)) {
178 user_dict->SetString(kKeyGaiaID, gaia_id); 178 user_dict->SetString(kKeyGaiaID, gaia_id);
179 } 179 }
180 } 180 }
181 181
182 // static 182 // static
183 void UserSelectionScreen::FillMultiProfileUserPrefs( 183 void UserSelectionScreen::FillMultiProfileUserPrefs(
184 user_manager::User* user, 184 user_manager::User* user,
185 base::DictionaryValue* user_dict, 185 base::DictionaryValue* user_dict,
186 bool is_signin_to_add) { 186 bool is_signin_to_add) {
187 const std::string& user_id = user->email(); 187 const user_manager::UserID& user_id = user->GetUserID();
188 188
189 if (is_signin_to_add) { 189 if (is_signin_to_add) {
190 MultiProfileUserController* multi_profile_user_controller = 190 MultiProfileUserController* multi_profile_user_controller =
191 ChromeUserManager::Get()->GetMultiProfileUserController(); 191 ChromeUserManager::Get()->GetMultiProfileUserController();
192 MultiProfileUserController::UserAllowedInSessionReason isUserAllowedReason; 192 MultiProfileUserController::UserAllowedInSessionReason isUserAllowedReason;
193 bool isUserAllowed = multi_profile_user_controller->IsUserAllowedInSession( 193 bool isUserAllowed = multi_profile_user_controller->IsUserAllowedInSession(
194 user_id, &isUserAllowedReason); 194 user_id, &isUserAllowedReason);
195 user_dict->SetBoolean(kKeyMultiProfilesAllowed, isUserAllowed); 195 user_dict->SetBoolean(kKeyMultiProfilesAllowed, isUserAllowed);
196 196
197 std::string behavior; 197 std::string behavior;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 token_status == user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN) { 233 token_status == user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN) {
234 return false; 234 return false;
235 } 235 }
236 236
237 if (is_public_session) 237 if (is_public_session)
238 return false; 238 return false;
239 239
240 // At this point the reason for invalid token should be already set. If not, 240 // At this point the reason for invalid token should be already set. If not,
241 // this might be a leftover from an old version. 241 // this might be a leftover from an old version.
242 if (token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) 242 if (token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID)
243 RecordReauthReason(user->email(), ReauthReason::OTHER); 243 RecordReauthReason(user->GetUserID(), ReauthReason::OTHER);
244 244
245 return user->force_online_signin() || 245 return user->force_online_signin() ||
246 (token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) || 246 (token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) ||
247 (token_status == user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN); 247 (token_status == user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN);
248 } 248 }
249 249
250 void UserSelectionScreen::SetHandler(LoginDisplayWebUIHandler* handler) { 250 void UserSelectionScreen::SetHandler(LoginDisplayWebUIHandler* handler) {
251 handler_ = handler; 251 handler_ = handler;
252 } 252 }
253 253
254 void UserSelectionScreen::SetView(UserBoardView* view) { 254 void UserSelectionScreen::SetView(UserBoardView* view) {
255 view_ = view; 255 view_ = view;
256 } 256 }
257 257
258 void UserSelectionScreen::Init(const user_manager::UserList& users, 258 void UserSelectionScreen::Init(const user_manager::UserList& users,
259 bool show_guest) { 259 bool show_guest) {
260 users_ = users; 260 users_ = users;
261 show_guest_ = show_guest; 261 show_guest_ = show_guest;
262 262
263 ui::UserActivityDetector* activity_detector = ui::UserActivityDetector::Get(); 263 ui::UserActivityDetector* activity_detector = ui::UserActivityDetector::Get();
264 if (!activity_detector->HasObserver(this)) 264 if (!activity_detector->HasObserver(this))
265 activity_detector->AddObserver(this); 265 activity_detector->AddObserver(this);
266 } 266 }
267 267
268 void UserSelectionScreen::OnBeforeUserRemoved(const std::string& username) { 268 void UserSelectionScreen::OnBeforeUserRemoved(const user_manager::UserID& user_i d) {
269 for (user_manager::UserList::iterator it = users_.begin(); it != users_.end(); 269 for (user_manager::UserList::iterator it = users_.begin(); it != users_.end();
270 ++it) { 270 ++it) {
271 if ((*it)->email() == username) { 271 if ((*it)->GetUserID() == user_id) {
272 users_.erase(it); 272 users_.erase(it);
273 break; 273 break;
274 } 274 }
275 } 275 }
276 } 276 }
277 277
278 void UserSelectionScreen::OnUserRemoved(const std::string& username) { 278 void UserSelectionScreen::OnUserRemoved(const user_manager::UserID& user_id) {
279 if (!handler_) 279 if (!handler_)
280 return; 280 return;
281 281
282 handler_->OnUserRemoved(username); 282 handler_->OnUserRemoved(user_id);
283 } 283 }
284 284
285 void UserSelectionScreen::OnUserImageChanged(const user_manager::User& user) { 285 void UserSelectionScreen::OnUserImageChanged(const user_manager::User& user) {
286 if (!handler_) 286 if (!handler_)
287 return; 287 return;
288 handler_->OnUserImageChanged(user); 288 handler_->OnUserImageChanged(user);
289 // TODO(antrim) : updateUserImage(user.email()) 289 // TODO(antrim) : updateUserImage(user.email())
290 } 290 }
291 291
292 const user_manager::UserList& UserSelectionScreen::GetUsers() const { 292 const user_manager::UserList& UserSelectionScreen::GetUsers() const {
(...skipping 12 matching lines...) Expand all
305 base::TimeDelta::FromSeconds(kPasswordClearTimeoutSec), 305 base::TimeDelta::FromSeconds(kPasswordClearTimeoutSec),
306 this, 306 this,
307 &UserSelectionScreen::OnPasswordClearTimerExpired); 307 &UserSelectionScreen::OnPasswordClearTimerExpired);
308 } 308 }
309 password_clear_timer_.Reset(); 309 password_clear_timer_.Reset();
310 } 310 }
311 311
312 // static 312 // static
313 const user_manager::UserList UserSelectionScreen::PrepareUserListForSending( 313 const user_manager::UserList UserSelectionScreen::PrepareUserListForSending(
314 const user_manager::UserList& users, 314 const user_manager::UserList& users,
315 std::string owner, 315 const user_manager::UserID& owner,
316 bool is_signin_to_add) { 316 bool is_signin_to_add) {
317 user_manager::UserList users_to_send; 317 user_manager::UserList users_to_send;
318 bool has_owner = owner.size() > 0; 318 bool has_owner = !owner.empty();
319 size_t max_non_owner_users = has_owner ? kMaxUsers - 1 : kMaxUsers; 319 size_t max_non_owner_users = has_owner ? kMaxUsers - 1 : kMaxUsers;
320 size_t non_owner_count = 0; 320 size_t non_owner_count = 0;
321 321
322 for (user_manager::UserList::const_iterator it = users.begin(); 322 for (user_manager::UserList::const_iterator it = users.begin();
323 it != users.end(); 323 it != users.end();
324 ++it) { 324 ++it) {
325 const std::string& user_id = (*it)->email(); 325 const user_manager::UserID& user_id = (*it)->GetUserID();
Denis Kuznetsov (DE-MUC) 2015/06/10 16:50:46 auto
326 bool is_owner = (user_id == owner); 326 bool is_owner = (user_id == owner);
327 bool is_public_account = 327 bool is_public_account =
328 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); 328 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT);
329 329
330 if ((is_public_account && !is_signin_to_add) || is_owner || 330 if ((is_public_account && !is_signin_to_add) || is_owner ||
331 (!is_public_account && non_owner_count < max_non_owner_users)) { 331 (!is_public_account && non_owner_count < max_non_owner_users)) {
332 332
333 if (!is_owner) 333 if (!is_owner)
334 ++non_owner_count; 334 ++non_owner_count;
335 if (is_owner && users_to_send.size() > kMaxUsers) { 335 if (is_owner && users_to_send.size() > kMaxUsers) {
(...skipping 11 matching lines...) Expand all
347 347
348 void UserSelectionScreen::SendUserList() { 348 void UserSelectionScreen::SendUserList() {
349 base::ListValue users_list; 349 base::ListValue users_list;
350 const user_manager::UserList& users = GetUsers(); 350 const user_manager::UserList& users = GetUsers();
351 351
352 // TODO(nkostylev): Move to a separate method in UserManager. 352 // TODO(nkostylev): Move to a separate method in UserManager.
353 // http://crbug.com/230852 353 // http://crbug.com/230852
354 bool single_user = users.size() == 1; 354 bool single_user = users.size() == 1;
355 bool is_signin_to_add = LoginDisplayHostImpl::default_host() && 355 bool is_signin_to_add = LoginDisplayHostImpl::default_host() &&
356 user_manager::UserManager::Get()->IsUserLoggedIn(); 356 user_manager::UserManager::Get()->IsUserLoggedIn();
357 std::string owner; 357 std::string owner_email;
358 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); 358 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner_email) ;
359 const user_manager::UserID owner(user_manager::UserID::FromUserEmail(owner_ema il));
359 360
360 policy::BrowserPolicyConnectorChromeOS* connector = 361 policy::BrowserPolicyConnectorChromeOS* connector =
361 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 362 g_browser_process->platform_part()->browser_policy_connector_chromeos();
362 bool is_enterprise_managed = connector->IsEnterpriseManaged(); 363 bool is_enterprise_managed = connector->IsEnterpriseManaged();
363 364
364 const user_manager::UserList users_to_send = 365 const user_manager::UserList users_to_send =
365 PrepareUserListForSending(users, owner, is_signin_to_add); 366 PrepareUserListForSending(users, owner, is_signin_to_add);
366 367
367 user_auth_type_map_.clear(); 368 user_auth_type_map_.clear();
368 369
369 const std::vector<std::string> kEmptyRecommendedLocales; 370 const std::vector<std::string> kEmptyRecommendedLocales;
370 for (user_manager::UserList::const_iterator it = users_to_send.begin(); 371 for (user_manager::UserList::const_iterator it = users_to_send.begin();
371 it != users_to_send.end(); 372 it != users_to_send.end();
372 ++it) { 373 ++it) {
373 const std::string& user_id = (*it)->email(); 374 const user_manager::UserID& user_id = (*it)->GetUserID();
374 bool is_owner = (user_id == owner); 375 bool is_owner = (user_id == owner);
375 const bool is_public_account = 376 const bool is_public_account =
376 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); 377 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT);
377 const AuthType initial_auth_type = 378 const AuthType initial_auth_type =
378 is_public_account ? EXPAND_THEN_USER_CLICK 379 is_public_account ? EXPAND_THEN_USER_CLICK
379 : (ShouldForceOnlineSignIn(*it) ? ONLINE_SIGN_IN 380 : (ShouldForceOnlineSignIn(*it) ? ONLINE_SIGN_IN
380 : OFFLINE_PASSWORD); 381 : OFFLINE_PASSWORD);
381 user_auth_type_map_[user_id] = initial_auth_type; 382 user_auth_type_map_[user_id] = initial_auth_type;
382 383
383 base::DictionaryValue* user_dict = new base::DictionaryValue(); 384 base::DictionaryValue* user_dict = new base::DictionaryValue();
(...skipping 20 matching lines...) Expand all
404 users_list.Append(user_dict); 405 users_list.Append(user_dict);
405 } 406 }
406 407
407 handler_->LoadUsers(users_list, show_guest_); 408 handler_->LoadUsers(users_list, show_guest_);
408 } 409 }
409 410
410 void UserSelectionScreen::HandleGetUsers() { 411 void UserSelectionScreen::HandleGetUsers() {
411 SendUserList(); 412 SendUserList();
412 } 413 }
413 414
414 void UserSelectionScreen::CheckUserStatus(const std::string& user_id) { 415 void UserSelectionScreen::CheckUserStatus(const user_manager::UserID& user_id) {
415 // No checks on lock screen. 416 // No checks on lock screen.
416 if (ScreenLocker::default_screen_locker()) 417 if (ScreenLocker::default_screen_locker())
417 return; 418 return;
418 419
419 if (!token_handle_util_.get()) { 420 if (!token_handle_util_.get()) {
420 token_handle_util_.reset( 421 token_handle_util_.reset(
421 new TokenHandleUtil(user_manager::UserManager::Get())); 422 new TokenHandleUtil(user_manager::UserManager::Get()));
422 } 423 }
423 424
424 if (token_handle_util_->HasToken(user_id)) { 425 if (token_handle_util_->HasToken(user_id)) {
425 token_handle_util_->CheckToken( 426 token_handle_util_->CheckToken(
426 user_id, base::Bind(&UserSelectionScreen::OnUserStatusChecked, 427 user_id, base::Bind(&UserSelectionScreen::OnUserStatusChecked,
427 weak_factory_.GetWeakPtr())); 428 weak_factory_.GetWeakPtr()));
428 } 429 }
429 } 430 }
430 431
431 void UserSelectionScreen::OnUserStatusChecked( 432 void UserSelectionScreen::OnUserStatusChecked(
432 const user_manager::UserID& user_id, 433 const user_manager::UserID& user_id,
433 TokenHandleUtil::TokenHandleStatus status) { 434 TokenHandleUtil::TokenHandleStatus status) {
434 if (status == TokenHandleUtil::INVALID) { 435 if (status == TokenHandleUtil::INVALID) {
435 RecordReauthReason(user_id, ReauthReason::INVALID_TOKEN_HANDLE); 436 RecordReauthReason(user_id, ReauthReason::INVALID_TOKEN_HANDLE);
436 token_handle_util_->MarkHandleInvalid(user_id); 437 token_handle_util_->MarkHandleInvalid(user_id);
437 SetAuthType(user_id, ONLINE_SIGN_IN, base::string16()); 438 SetAuthType(user_id, ONLINE_SIGN_IN, base::string16());
438 } 439 }
439 } 440 }
440 441
441 // EasyUnlock stuff 442 // EasyUnlock stuff
442 443
443 void UserSelectionScreen::SetAuthType(const std::string& user_id, 444 void UserSelectionScreen::SetAuthType(const user_manager::UserID& user_id,
444 AuthType auth_type, 445 AuthType auth_type,
445 const base::string16& initial_value) { 446 const base::string16& initial_value) {
446 if (GetAuthType(user_id) == FORCE_OFFLINE_PASSWORD) 447 if (GetAuthType(user_id) == FORCE_OFFLINE_PASSWORD)
447 return; 448 return;
448 DCHECK(GetAuthType(user_id) != FORCE_OFFLINE_PASSWORD || 449 DCHECK(GetAuthType(user_id) != FORCE_OFFLINE_PASSWORD ||
449 auth_type == FORCE_OFFLINE_PASSWORD); 450 auth_type == FORCE_OFFLINE_PASSWORD);
450 user_auth_type_map_[user_id] = auth_type; 451 user_auth_type_map_[user_id] = auth_type;
451 view_->SetAuthType(user_id, auth_type, initial_value); 452 view_->SetAuthType(user_id, auth_type, initial_value);
452 } 453 }
453 454
454 proximity_auth::ScreenlockBridge::LockHandler::AuthType 455 proximity_auth::ScreenlockBridge::LockHandler::AuthType
455 UserSelectionScreen::GetAuthType(const std::string& username) const { 456 UserSelectionScreen::GetAuthType(const user_manager::UserID& user_id) const {
456 if (user_auth_type_map_.find(username) == user_auth_type_map_.end()) 457 if (user_auth_type_map_.find(user_id) == user_auth_type_map_.end())
457 return OFFLINE_PASSWORD; 458 return OFFLINE_PASSWORD;
458 return user_auth_type_map_.find(username)->second; 459 return user_auth_type_map_.find(user_id)->second;
459 } 460 }
460 461
461 proximity_auth::ScreenlockBridge::LockHandler::ScreenType 462 proximity_auth::ScreenlockBridge::LockHandler::ScreenType
462 UserSelectionScreen::GetScreenType() const { 463 UserSelectionScreen::GetScreenType() const {
463 if (display_type_ == OobeUI::kLockDisplay) 464 if (display_type_ == OobeUI::kLockDisplay)
464 return LOCK_SCREEN; 465 return LOCK_SCREEN;
465 466
466 if (display_type_ == OobeUI::kLoginDisplay) 467 if (display_type_ == OobeUI::kLoginDisplay)
467 return SIGNIN_SCREEN; 468 return SIGNIN_SCREEN;
468 469
469 return OTHER_SCREEN; 470 return OTHER_SCREEN;
470 } 471 }
471 472
472 void UserSelectionScreen::ShowBannerMessage(const base::string16& message) { 473 void UserSelectionScreen::ShowBannerMessage(const base::string16& message) {
473 view_->ShowBannerMessage(message); 474 view_->ShowBannerMessage(message);
474 } 475 }
475 476
476 void UserSelectionScreen::ShowUserPodCustomIcon( 477 void UserSelectionScreen::ShowUserPodCustomIcon(
477 const std::string& user_id, 478 const user_manager::UserID& user_id,
478 const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& 479 const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions&
479 icon_options) { 480 icon_options) {
480 scoped_ptr<base::DictionaryValue> icon = icon_options.ToDictionaryValue(); 481 scoped_ptr<base::DictionaryValue> icon = icon_options.ToDictionaryValue();
481 if (!icon || icon->empty()) 482 if (!icon || icon->empty())
482 return; 483 return;
483 view_->ShowUserPodCustomIcon(user_id, *icon); 484 view_->ShowUserPodCustomIcon(user_id, *icon);
484 } 485 }
485 486
486 void UserSelectionScreen::HideUserPodCustomIcon(const std::string& user_id) { 487 void UserSelectionScreen::HideUserPodCustomIcon(const user_manager::UserID& user _id) {
487 view_->HideUserPodCustomIcon(user_id); 488 view_->HideUserPodCustomIcon(user_id);
488 } 489 }
489 490
490 void UserSelectionScreen::EnableInput() { 491 void UserSelectionScreen::EnableInput() {
491 // If Easy Unlock fails to unlock the screen, re-enable the password input. 492 // If Easy Unlock fails to unlock the screen, re-enable the password input.
492 // This is only necessary on the lock screen, because the error handling for 493 // This is only necessary on the lock screen, because the error handling for
493 // the sign-in screen uses a different code path. 494 // the sign-in screen uses a different code path.
494 if (ScreenLocker::default_screen_locker()) 495 if (ScreenLocker::default_screen_locker())
495 ScreenLocker::default_screen_locker()->EnableInput(); 496 ScreenLocker::default_screen_locker()->EnableInput();
496 } 497 }
497 498
498 void UserSelectionScreen::Unlock(const std::string& user_email) { 499 void UserSelectionScreen::Unlock(const user_manager::UserID& user_id) {
499 DCHECK_EQ(GetScreenType(), LOCK_SCREEN); 500 DCHECK_EQ(GetScreenType(), LOCK_SCREEN);
500 ScreenLocker::Hide(); 501 ScreenLocker::Hide();
501 } 502 }
502 503
503 void UserSelectionScreen::AttemptEasySignin(const std::string& user_id, 504 void UserSelectionScreen::AttemptEasySignin(const user_manager::UserID& user_id,
504 const std::string& secret, 505 const std::string& secret,
505 const std::string& key_label) { 506 const std::string& key_label) {
506 DCHECK_EQ(GetScreenType(), SIGNIN_SCREEN); 507 DCHECK_EQ(GetScreenType(), SIGNIN_SCREEN);
507 508
508 UserContext user_context(user_id); 509 UserContext user_context(user_id);
509 user_context.SetAuthFlow(UserContext::AUTH_FLOW_EASY_UNLOCK); 510 user_context.SetAuthFlow(UserContext::AUTH_FLOW_EASY_UNLOCK);
510 user_context.SetKey(Key(secret)); 511 user_context.SetKey(Key(secret));
511 user_context.GetKey()->SetLabel(key_label); 512 user_context.GetKey()->SetLabel(key_label);
512 513
513 login_display_delegate_->Login(user_context, SigninSpecifics()); 514 login_display_delegate_->Login(user_context, SigninSpecifics());
514 } 515 }
515 516
516 void UserSelectionScreen::HardLockPod(const std::string& user_id) { 517 void UserSelectionScreen::HardLockPod(const user_manager::UserID& user_id) {
517 view_->SetAuthType(user_id, OFFLINE_PASSWORD, base::string16()); 518 view_->SetAuthType(user_id, OFFLINE_PASSWORD, base::string16());
518 EasyUnlockService* service = GetEasyUnlockServiceForUser(user_id); 519 EasyUnlockService* service = GetEasyUnlockServiceForUser(user_id);
519 if (!service) 520 if (!service)
520 return; 521 return;
521 service->SetHardlockState(EasyUnlockScreenlockStateHandler::USER_HARDLOCK); 522 service->SetHardlockState(EasyUnlockScreenlockStateHandler::USER_HARDLOCK);
522 } 523 }
523 524
524 void UserSelectionScreen::AttemptEasyUnlock(const std::string& user_id) { 525 void UserSelectionScreen::AttemptEasyUnlock(const user_manager::UserID& user_id) {
525 EasyUnlockService* service = GetEasyUnlockServiceForUser(user_id); 526 EasyUnlockService* service = GetEasyUnlockServiceForUser(user_id);
526 if (!service) 527 if (!service)
527 return; 528 return;
528 service->AttemptAuth(user_id); 529 service->AttemptAuth(user_id);
529 } 530 }
530 531
531 void UserSelectionScreen::RecordClickOnLockIcon(const std::string& user_id) { 532 void UserSelectionScreen::RecordClickOnLockIcon(const user_manager::UserID& user _id) {
532 EasyUnlockService* service = GetEasyUnlockServiceForUser(user_id); 533 EasyUnlockService* service = GetEasyUnlockServiceForUser(user_id);
533 if (!service) 534 if (!service)
534 return; 535 return;
535 service->RecordClickOnLockIcon(); 536 service->RecordClickOnLockIcon();
536 } 537 }
537 538
538 EasyUnlockService* UserSelectionScreen::GetEasyUnlockServiceForUser( 539 EasyUnlockService* UserSelectionScreen::GetEasyUnlockServiceForUser(
539 const std::string& user_id) const { 540 const user_manager::UserID& user_id) const {
540 if (GetScreenType() == OTHER_SCREEN) 541 if (GetScreenType() == OTHER_SCREEN)
541 return nullptr; 542 return nullptr;
542 543
543 const user_manager::User* unlock_user = nullptr; 544 const user_manager::User* unlock_user = nullptr;
544 for (const user_manager::User* user : GetUsers()) { 545 for (const user_manager::User* user : GetUsers()) {
545 if (user->email() == user_id) { 546 if (user->GetUserID() == user_id) {
546 unlock_user = user; 547 unlock_user = user;
547 break; 548 break;
548 } 549 }
549 } 550 }
550 if (!unlock_user) 551 if (!unlock_user)
551 return nullptr; 552 return nullptr;
552 553
553 ProfileHelper* profile_helper = ProfileHelper::Get(); 554 ProfileHelper* profile_helper = ProfileHelper::Get();
554 Profile* profile = profile_helper->GetProfileByUser(unlock_user); 555 Profile* profile = profile_helper->GetProfileByUser(unlock_user);
555 556
556 // The user profile should exist if and only if this is the lock screen. 557 // The user profile should exist if and only if this is the lock screen.
557 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); 558 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN);
558 559
559 if (!profile) 560 if (!profile)
560 profile = profile_helper->GetSigninProfile(); 561 profile = profile_helper->GetSigninProfile();
561 562
562 return EasyUnlockService::Get(profile); 563 return EasyUnlockService::Get(profile);
563 } 564 }
564 565
565 } // namespace chromeos 566 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698