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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 // available when running into login screen on first boot. | 397 // available when running into login screen on first boot. |
398 // See http://crosbug.com/12723 | 398 // See http://crosbug.com/12723 |
399 bool can_remove_user = | 399 bool can_remove_user = |
400 ((!single_user || is_enterprise_managed) && !user_id.empty() && | 400 ((!single_user || is_enterprise_managed) && !user_id.empty() && |
401 !is_owner && !is_public_account && !signed_in && !is_signin_to_add); | 401 !is_owner && !is_public_account && !signed_in && !is_signin_to_add); |
402 user_dict->SetBoolean(kKeyCanRemove, can_remove_user); | 402 user_dict->SetBoolean(kKeyCanRemove, can_remove_user); |
403 users_list.Append(user_dict); | 403 users_list.Append(user_dict); |
404 } | 404 } |
405 | 405 |
406 handler_->LoadUsers(users_list, show_guest_); | 406 handler_->LoadUsers(users_list, show_guest_); |
| 407 |
| 408 CheckAllUserStatuses(); |
407 } | 409 } |
408 | 410 |
409 void UserSelectionScreen::HandleGetUsers() { | 411 void UserSelectionScreen::HandleGetUsers() { |
410 SendUserList(); | 412 SendUserList(); |
411 } | 413 } |
412 | 414 |
413 void UserSelectionScreen::CheckUserStatus(const std::string& user_id) { | 415 bool UserSelectionScreen::CheckUserStatus(const std::string& user_id) { |
414 // No checks on lock screen. | 416 // No checks on lock screen. |
415 if (ScreenLocker::default_screen_locker()) | 417 if (ScreenLocker::default_screen_locker()) |
416 return; | 418 return false; |
417 | 419 |
418 if (!token_handle_util_.get()) { | 420 if (!token_handle_util_.get()) { |
419 token_handle_util_.reset( | 421 token_handle_util_.reset( |
420 new TokenHandleUtil(user_manager::UserManager::Get())); | 422 new TokenHandleUtil(user_manager::UserManager::Get())); |
421 } | 423 } |
422 | 424 |
423 if (token_handle_util_->HasToken(user_id)) { | 425 if (token_handle_util_->HasToken(user_id)) { |
424 token_handle_util_->CheckToken( | 426 return token_handle_util_->CheckToken( |
425 user_id, base::Bind(&UserSelectionScreen::OnUserStatusChecked, | 427 user_id, base::Bind(&UserSelectionScreen::OnUserStatusChecked, |
426 weak_factory_.GetWeakPtr())); | 428 weak_factory_.GetWeakPtr())); |
427 } | 429 } |
| 430 return false; |
| 431 } |
| 432 |
| 433 void UserSelectionScreen::CheckAllUserStatuses() { |
| 434 const user_manager::UserList& users = GetUsers(); |
| 435 for (const user_manager::User* user : users) { |
| 436 // ignore return value. |
| 437 CheckUserStatus(user->email()); |
| 438 } |
428 } | 439 } |
429 | 440 |
430 void UserSelectionScreen::OnUserStatusChecked( | 441 void UserSelectionScreen::OnUserStatusChecked( |
431 const user_manager::UserID& user_id, | 442 const user_manager::UserID& user_id, |
432 TokenHandleUtil::TokenHandleStatus status) { | 443 TokenHandleUtil::TokenHandleStatus status) { |
433 if (status == TokenHandleUtil::INVALID) { | 444 if (status == TokenHandleUtil::INVALID) { |
434 RecordReauthReason(user_id, ReauthReason::INVALID_TOKEN_HANDLE); | 445 RecordReauthReason(user_id, ReauthReason::INVALID_TOKEN_HANDLE); |
435 token_handle_util_->MarkHandleInvalid(user_id); | 446 token_handle_util_->MarkHandleInvalid(user_id); |
436 SetAuthType(user_id, ONLINE_SIGN_IN, base::string16()); | 447 SetAuthType(user_id, ONLINE_SIGN_IN, base::string16()); |
437 } | 448 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 // The user profile should exist if and only if this is the lock screen. | 566 // The user profile should exist if and only if this is the lock screen. |
556 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); | 567 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); |
557 | 568 |
558 if (!profile) | 569 if (!profile) |
559 profile = profile_helper->GetSigninProfile(); | 570 profile = profile_helper->GetSigninProfile(); |
560 | 571 |
561 return EasyUnlockService::Get(profile); | 572 return EasyUnlockService::Get(profile); |
562 } | 573 } |
563 | 574 |
564 } // namespace chromeos | 575 } // namespace chromeos |
OLD | NEW |