Index: chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc |
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc |
index c52fde6eb51ef8e314241bbca543cbb538dc0f4c..15da1f1f83546d4d05be952744109b5e038d7d1e 100644 |
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc |
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc |
@@ -39,6 +39,7 @@ |
#include "chrome/browser/chromeos/login/hwid_checker.h" |
#include "chrome/browser/chromeos/login/lock/screen_locker.h" |
#include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" |
+#include "chrome/browser/chromeos/login/quick_unlock/pin_backend.h" |
#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h" |
#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h" |
#include "chrome/browser/chromeos/login/reauth_stats.h" |
@@ -720,14 +721,6 @@ void SigninScreenHandler::ShowImpl() { |
params.SetBoolean("disableAddUser", AllWhitelistedUsersPresent()); |
UpdateUIState(UI_STATE_ACCOUNT_PICKER, ¶ms); |
} |
- |
- // Enable pin for any users who can use it. |
- if (user_manager::UserManager::IsInitialized()) { |
- for (user_manager::User* user : |
- user_manager::UserManager::Get()->GetLoggedInUsers()) { |
- UpdatePinKeyboardState(user->GetAccountId()); |
- } |
- } |
} |
void SigninScreenHandler::UpdateUIState(UIState ui_state, |
@@ -963,17 +956,14 @@ void SigninScreenHandler::ReloadGaia(bool force_reload) { |
} |
void SigninScreenHandler::Initialize() { |
- // Preload PIN keyboard if any of the users can authenticate via PIN. |
+ // Preload pin keyboard if any of the users can authenticate via pin. |
if (user_manager::UserManager::IsInitialized()) { |
for (user_manager::User* user : |
user_manager::UserManager::Get()->GetUnlockUsers()) { |
- chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage = |
- chromeos::quick_unlock::QuickUnlockFactory::GetForUser(user); |
- if (quick_unlock_storage && |
- quick_unlock_storage->IsPinAuthenticationAvailable()) { |
- CallJS("cr.ui.Oobe.preloadPinKeyboard"); |
- break; |
- } |
+ chromeos::quick_unlock::PinBackend::CanAuthenticate( |
+ user->GetAccountId(), |
+ base::Bind(&SigninScreenHandler::PreloadPinKeyboardCallback, |
+ weak_factory_.GetWeakPtr())); |
} |
} |
@@ -1015,16 +1005,24 @@ void SigninScreenHandler::RefocusCurrentPod() { |
} |
void SigninScreenHandler::UpdatePinKeyboardState(const AccountId& account_id) { |
- chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage = |
- chromeos::quick_unlock::QuickUnlockFactory::GetForAccountId(account_id); |
- if (!quick_unlock_storage) |
- return; |
+ chromeos::quick_unlock::PinBackend::CanAuthenticate( |
+ account_id, |
+ base::Bind(&SigninScreenHandler::UpdatePinKeyboardStateCallback, |
+ weak_factory_.GetWeakPtr(), account_id)); |
+} |
- bool is_enabled = quick_unlock_storage->IsPinAuthenticationAvailable(); |
+void SigninScreenHandler::UpdatePinKeyboardStateCallback( |
+ const AccountId& account_id, |
+ bool is_enabled) { |
CallJS("login.AccountPickerScreen.setPinEnabledForUser", account_id, |
is_enabled); |
} |
+void SigninScreenHandler::PreloadPinKeyboardCallback(bool should_enabled) { |
+ if (should_enabled) |
+ CallJS("cr.ui.Oobe.preloadPinKeyboard"); |
+} |
+ |
void SigninScreenHandler::OnUserRemoved(const AccountId& account_id, |
bool last_user_removed) { |
CallJS("login.AccountPickerScreen.removeUser", account_id); |
@@ -1177,12 +1175,6 @@ void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id, |
return; |
DCHECK_EQ(account_id.GetUserEmail(), |
gaia::SanitizeEmail(account_id.GetUserEmail())); |
- chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage = |
- chromeos::quick_unlock::QuickUnlockFactory::GetForAccountId(account_id); |
- // If pin storage is unavailable, authenticated by PIN must be false. |
- DCHECK(!quick_unlock_storage || |
- quick_unlock_storage->IsPinAuthenticationAvailable() || |
- !authenticated_by_pin); |
UserContext user_context(account_id); |
user_context.SetKey(Key(password)); |
@@ -1309,6 +1301,10 @@ void SigninScreenHandler::LoadUsers(const user_manager::UserList& users, |
const base::ListValue& users_list) { |
CallJSOrDefer("login.AccountPickerScreen.loadUsers", users_list, |
delegate_->IsShowGuest()); |
+ |
Alexander Alekseev
2017/05/12 22:40:39
Please, add TODO https://crbug.com/721938 to opti
jdufault
2017/06/06 18:17:06
Done.
|
+ // Enable pin for any users who can use it. |
+ for (user_manager::User* user : users) |
+ UpdatePinKeyboardState(user->GetAccountId()); |
} |
void SigninScreenHandler::HandleAccountPickerReady() { |