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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 // available when running into login screen on first boot. | 398 // available when running into login screen on first boot. |
399 // See http://crosbug.com/12723 | 399 // See http://crosbug.com/12723 |
400 bool can_remove_user = | 400 bool can_remove_user = |
401 ((!single_user || is_enterprise_managed) && !user_id.empty() && | 401 ((!single_user || is_enterprise_managed) && !user_id.empty() && |
402 !is_owner && !is_public_account && !signed_in && !is_signin_to_add); | 402 !is_owner && !is_public_account && !signed_in && !is_signin_to_add); |
403 user_dict->SetBoolean(kKeyCanRemove, can_remove_user); | 403 user_dict->SetBoolean(kKeyCanRemove, can_remove_user); |
404 users_list.Append(user_dict); | 404 users_list.Append(user_dict); |
405 } | 405 } |
406 | 406 |
407 handler_->LoadUsers(users_list, show_guest_); | 407 handler_->LoadUsers(users_list, show_guest_); |
408 | |
409 CheckNextUserStatus(""); | |
dzhioev (left Google)
2015/06/22 23:51:24
std::string()
dzhioev (left Google)
2015/06/22 23:51:24
In my opinion this implementation is too cryptic.
Denis Kuznetsov (DE-MUC)
2015/06/25 18:43:42
Some magic constant that is not explained in metho
dzhioev (left Google)
2015/06/25 22:19:36
Which constants are you talking about?
Alexander Alekseev
2015/06/30 20:43:39
Done.
Alexander Alekseev
2015/06/30 20:43:39
Done.
| |
408 } | 410 } |
409 | 411 |
410 void UserSelectionScreen::HandleGetUsers() { | 412 void UserSelectionScreen::HandleGetUsers() { |
411 SendUserList(); | 413 SendUserList(); |
412 } | 414 } |
413 | 415 |
414 void UserSelectionScreen::CheckUserStatus(const std::string& user_id) { | 416 void UserSelectionScreen::CheckUserStatus(const std::string& user_id) { |
417 CheckUserStatusImpl(user_id, false /* check_all_users */); | |
418 } | |
419 | |
420 bool UserSelectionScreen::CheckUserStatusImpl(const std::string& user_id, | |
421 bool check_all_users) { | |
415 // No checks on lock screen. | 422 // No checks on lock screen. |
416 if (ScreenLocker::default_screen_locker()) | 423 if (ScreenLocker::default_screen_locker()) |
417 return; | 424 return false; |
418 | 425 |
419 if (!token_handle_util_.get()) { | 426 if (!token_handle_util_.get()) { |
420 token_handle_util_.reset( | 427 token_handle_util_.reset( |
421 new TokenHandleUtil(user_manager::UserManager::Get())); | 428 new TokenHandleUtil(user_manager::UserManager::Get())); |
422 } | 429 } |
423 | 430 |
424 if (token_handle_util_->HasToken(user_id)) { | 431 if (token_handle_util_->HasToken(user_id)) { |
425 token_handle_util_->CheckToken( | 432 return token_handle_util_->CheckToken( |
426 user_id, base::Bind(&UserSelectionScreen::OnUserStatusChecked, | 433 user_id, base::Bind(&UserSelectionScreen::OnUserStatusChecked, |
427 weak_factory_.GetWeakPtr())); | 434 weak_factory_.GetWeakPtr(), check_all_users)); |
435 } | |
436 return false; | |
437 } | |
438 | |
439 void UserSelectionScreen::CheckNextUserStatus( | |
440 const std::string& current_user_id) { | |
441 const user_manager::UserList& users = GetUsers(); | |
442 bool found = current_user_id.empty(); | |
443 for (const user_manager::User* user : users) { | |
444 const std::string& next_user_id = user->email(); | |
445 | |
446 if (!found) { | |
447 if (next_user_id == current_user_id) | |
448 found = true; | |
449 | |
450 continue; | |
451 } | |
452 if (CheckUserStatusImpl(next_user_id, true /* check_all_users */)) | |
453 return; | |
428 } | 454 } |
429 } | 455 } |
430 | 456 |
431 void UserSelectionScreen::OnUserStatusChecked( | 457 void UserSelectionScreen::OnUserStatusChecked( |
458 const bool check_all_users, | |
432 const user_manager::UserID& user_id, | 459 const user_manager::UserID& user_id, |
433 TokenHandleUtil::TokenHandleStatus status) { | 460 TokenHandleUtil::TokenHandleStatus status) { |
434 if (status == TokenHandleUtil::INVALID) { | 461 if (status == TokenHandleUtil::INVALID) { |
435 RecordReauthReason(user_id, ReauthReason::INVALID_TOKEN_HANDLE); | 462 RecordReauthReason(user_id, ReauthReason::INVALID_TOKEN_HANDLE); |
436 token_handle_util_->MarkHandleInvalid(user_id); | 463 token_handle_util_->MarkHandleInvalid(user_id); |
437 SetAuthType(user_id, ONLINE_SIGN_IN, base::string16()); | 464 SetAuthType(user_id, ONLINE_SIGN_IN, base::string16()); |
438 } | 465 } |
466 if (check_all_users) | |
467 CheckNextUserStatus(user_id); | |
439 } | 468 } |
440 | 469 |
441 // EasyUnlock stuff | 470 // EasyUnlock stuff |
442 | 471 |
443 void UserSelectionScreen::SetAuthType(const std::string& user_id, | 472 void UserSelectionScreen::SetAuthType(const std::string& user_id, |
444 AuthType auth_type, | 473 AuthType auth_type, |
445 const base::string16& initial_value) { | 474 const base::string16& initial_value) { |
446 if (GetAuthType(user_id) == FORCE_OFFLINE_PASSWORD) | 475 if (GetAuthType(user_id) == FORCE_OFFLINE_PASSWORD) |
447 return; | 476 return; |
448 DCHECK(GetAuthType(user_id) != FORCE_OFFLINE_PASSWORD || | 477 DCHECK(GetAuthType(user_id) != FORCE_OFFLINE_PASSWORD || |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
556 // The user profile should exist if and only if this is the lock screen. | 585 // The user profile should exist if and only if this is the lock screen. |
557 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); | 586 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); |
558 | 587 |
559 if (!profile) | 588 if (!profile) |
560 profile = profile_helper->GetSigninProfile(); | 589 profile = profile_helper->GetSigninProfile(); |
561 | 590 |
562 return EasyUnlockService::Get(profile); | 591 return EasyUnlockService::Get(profile); |
563 } | 592 } |
564 | 593 |
565 } // namespace chromeos | 594 } // namespace chromeos |
OLD | NEW |