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

Unified Diff: chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc

Issue 2809993004: cros: Implement cryptohome backend for pin.
Patch Set: Address comments Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 902da5a07a7c574a3b4fed9dfbd680c0f7247e66..4f280de1fd671496a250aae702814c449c81bbad 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
@@ -40,6 +40,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"
@@ -734,14 +735,6 @@ void SigninScreenHandler::ShowImpl() {
params.SetBoolean("disableAddUser", AllWhitelistedUsersPresent());
UpdateUIState(UI_STATE_ACCOUNT_PICKER, &params);
}
-
- // 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,
@@ -977,17 +970,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()));
}
}
@@ -1029,16 +1019,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);
@@ -1211,12 +1209,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));
@@ -1343,6 +1335,13 @@ void SigninScreenHandler::LoadUsers(const user_manager::UserList& users,
const base::ListValue& users_list) {
CallJSOrDefer("login.AccountPickerScreen.loadUsers", users_list,
delegate_->IsShowGuest());
+
+ // Enable pin for any users who can use it.
+ // TODO(jdufault): Cache pin state (in storage accessible in login) so we
+ // don't need to requery cryptohome every time we show login. See
+ // crbug.com/721938.
+ for (user_manager::User* user : users)
+ UpdatePinKeyboardState(user->GetAccountId());
}
void SigninScreenHandler::HandleAccountPickerReady() {
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698