| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 user_dict->Set(kKeyInitialKeyboardLayout, | 106 user_dict->Set(kKeyInitialKeyboardLayout, |
| 107 GetCurrentKeyboardLayout().release()); | 107 GetCurrentKeyboardLayout().release()); |
| 108 } | 108 } |
| 109 | 109 |
| 110 } // namespace | 110 } // namespace |
| 111 | 111 |
| 112 UserSelectionScreen::UserSelectionScreen(const std::string& display_type) | 112 UserSelectionScreen::UserSelectionScreen(const std::string& display_type) |
| 113 : handler_(nullptr), | 113 : handler_(nullptr), |
| 114 login_display_delegate_(nullptr), | 114 login_display_delegate_(nullptr), |
| 115 view_(nullptr), | 115 view_(nullptr), |
| 116 display_type_(display_type) { | 116 display_type_(display_type), |
| 117 weak_factory_(this) { |
| 117 } | 118 } |
| 118 | 119 |
| 119 UserSelectionScreen::~UserSelectionScreen() { | 120 UserSelectionScreen::~UserSelectionScreen() { |
| 120 ScreenlockBridge::Get()->SetLockHandler(nullptr); | 121 ScreenlockBridge::Get()->SetLockHandler(nullptr); |
| 121 ui::UserActivityDetector* activity_detector = ui::UserActivityDetector::Get(); | 122 ui::UserActivityDetector* activity_detector = ui::UserActivityDetector::Get(); |
| 122 if (activity_detector->HasObserver(this)) | 123 if (activity_detector->HasObserver(this)) |
| 123 activity_detector->RemoveObserver(this); | 124 activity_detector->RemoveObserver(this); |
| 124 } | 125 } |
| 125 | 126 |
| 126 void UserSelectionScreen::InitEasyUnlock() { | 127 void UserSelectionScreen::InitEasyUnlock() { |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 users_list.Append(user_dict); | 397 users_list.Append(user_dict); |
| 397 } | 398 } |
| 398 | 399 |
| 399 handler_->LoadUsers(users_list, show_guest_); | 400 handler_->LoadUsers(users_list, show_guest_); |
| 400 } | 401 } |
| 401 | 402 |
| 402 void UserSelectionScreen::HandleGetUsers() { | 403 void UserSelectionScreen::HandleGetUsers() { |
| 403 SendUserList(); | 404 SendUserList(); |
| 404 } | 405 } |
| 405 | 406 |
| 407 void UserSelectionScreen::CheckUserStatus(const std::string& user_id) { |
| 408 // No checks on lock screen. |
| 409 if (ScreenLocker::default_screen_locker()) |
| 410 return; |
| 411 |
| 412 if (!token_handle_util_.get()) { |
| 413 token_handle_util_.reset( |
| 414 new TokenHandleUtil(user_manager::UserManager::Get())); |
| 415 } |
| 416 |
| 417 if (token_handle_util_->HasToken(user_id)) { |
| 418 token_handle_util_->CheckToken( |
| 419 user_id, base::Bind(&UserSelectionScreen::OnUserStatusChecked, |
| 420 weak_factory_.GetWeakPtr())); |
| 421 } |
| 422 } |
| 423 |
| 424 void UserSelectionScreen::OnUserStatusChecked( |
| 425 const user_manager::UserID& user_id, |
| 426 TokenHandleUtil::TokenHandleStatus status) { |
| 427 if (status == TokenHandleUtil::INVALID) { |
| 428 user_manager::UserManager::Get()->SaveUserOAuthStatus( |
| 429 user_id, user_manager::User::OAUTH2_TOKEN_STATUS_INVALID); |
| 430 token_handle_util_->DeleteToken(user_id); |
| 431 SetAuthType(user_id, ONLINE_SIGN_IN, base::string16()); |
| 432 } |
| 433 } |
| 434 |
| 406 // EasyUnlock stuff | 435 // EasyUnlock stuff |
| 407 | 436 |
| 408 void UserSelectionScreen::SetAuthType(const std::string& user_id, | 437 void UserSelectionScreen::SetAuthType(const std::string& user_id, |
| 409 AuthType auth_type, | 438 AuthType auth_type, |
| 410 const base::string16& initial_value) { | 439 const base::string16& initial_value) { |
| 411 if (GetAuthType(user_id) == FORCE_OFFLINE_PASSWORD) | 440 if (GetAuthType(user_id) == FORCE_OFFLINE_PASSWORD) |
| 412 return; | 441 return; |
| 413 DCHECK(GetAuthType(user_id) != FORCE_OFFLINE_PASSWORD || | 442 DCHECK(GetAuthType(user_id) != FORCE_OFFLINE_PASSWORD || |
| 414 auth_type == FORCE_OFFLINE_PASSWORD); | 443 auth_type == FORCE_OFFLINE_PASSWORD); |
| 415 user_auth_type_map_[user_id] = auth_type; | 444 user_auth_type_map_[user_id] = auth_type; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 // The user profile should exist if and only if this is the lock screen. | 549 // The user profile should exist if and only if this is the lock screen. |
| 521 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); | 550 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); |
| 522 | 551 |
| 523 if (!profile) | 552 if (!profile) |
| 524 profile = profile_helper->GetSigninProfile(); | 553 profile = profile_helper->GetSigninProfile(); |
| 525 | 554 |
| 526 return EasyUnlockService::Get(profile); | 555 return EasyUnlockService::Get(profile); |
| 527 } | 556 } |
| 528 | 557 |
| 529 } // namespace chromeos | 558 } // namespace chromeos |
| OLD | NEW |