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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/ui/webui/chromeos/login/signin_screen_handler.h" 5 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 22 matching lines...) Expand all
33 #include "chrome/browser/browser_process_platform_part_chromeos.h" 33 #include "chrome/browser/browser_process_platform_part_chromeos.h"
34 #include "chrome/browser/browser_shutdown.h" 34 #include "chrome/browser/browser_shutdown.h"
35 #include "chrome/browser/chrome_notification_types.h" 35 #include "chrome/browser/chrome_notification_types.h"
36 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" 36 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
37 #include "chrome/browser/chromeos/language_preferences.h" 37 #include "chrome/browser/chromeos/language_preferences.h"
38 #include "chrome/browser/chromeos/lock_screen_apps/state_controller.h" 38 #include "chrome/browser/chromeos/lock_screen_apps/state_controller.h"
39 #include "chrome/browser/chromeos/login/error_screens_histogram_helper.h" 39 #include "chrome/browser/chromeos/login/error_screens_histogram_helper.h"
40 #include "chrome/browser/chromeos/login/hwid_checker.h" 40 #include "chrome/browser/chromeos/login/hwid_checker.h"
41 #include "chrome/browser/chromeos/login/lock/screen_locker.h" 41 #include "chrome/browser/chromeos/login/lock/screen_locker.h"
42 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" 42 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h"
43 #include "chrome/browser/chromeos/login/quick_unlock/pin_backend.h"
43 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h" 44 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h"
44 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h" 45 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h"
45 #include "chrome/browser/chromeos/login/reauth_stats.h" 46 #include "chrome/browser/chromeos/login/reauth_stats.h"
46 #include "chrome/browser/chromeos/login/screens/core_oobe_view.h" 47 #include "chrome/browser/chromeos/login/screens/core_oobe_view.h"
47 #include "chrome/browser/chromeos/login/screens/network_error.h" 48 #include "chrome/browser/chromeos/login/screens/network_error.h"
48 #include "chrome/browser/chromeos/login/startup_utils.h" 49 #include "chrome/browser/chromeos/login/startup_utils.h"
49 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 50 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
50 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 51 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
51 #include "chrome/browser/chromeos/login/ui/login_feedback.h" 52 #include "chrome/browser/chromeos/login/ui/login_feedback.h"
52 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" 53 #include "chrome/browser/chromeos/login/ui/webui_login_display.h"
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 728
728 // Reset Caps Lock state when login screen is shown. 729 // Reset Caps Lock state when login screen is shown.
729 input_method::InputMethodManager::Get() 730 input_method::InputMethodManager::Get()
730 ->GetImeKeyboard() 731 ->GetImeKeyboard()
731 ->SetCapsLockEnabled(false); 732 ->SetCapsLockEnabled(false);
732 733
733 base::DictionaryValue params; 734 base::DictionaryValue params;
734 params.SetBoolean("disableAddUser", AllWhitelistedUsersPresent()); 735 params.SetBoolean("disableAddUser", AllWhitelistedUsersPresent());
735 UpdateUIState(UI_STATE_ACCOUNT_PICKER, &params); 736 UpdateUIState(UI_STATE_ACCOUNT_PICKER, &params);
736 } 737 }
737
738 // Enable pin for any users who can use it.
739 if (user_manager::UserManager::IsInitialized()) {
740 for (user_manager::User* user :
741 user_manager::UserManager::Get()->GetLoggedInUsers()) {
742 UpdatePinKeyboardState(user->GetAccountId());
743 }
744 }
745 } 738 }
746 739
747 void SigninScreenHandler::UpdateUIState(UIState ui_state, 740 void SigninScreenHandler::UpdateUIState(UIState ui_state,
748 base::DictionaryValue* params) { 741 base::DictionaryValue* params) {
749 switch (ui_state) { 742 switch (ui_state) {
750 case UI_STATE_GAIA_SIGNIN: 743 case UI_STATE_GAIA_SIGNIN:
751 ui_state_ = UI_STATE_GAIA_SIGNIN; 744 ui_state_ = UI_STATE_GAIA_SIGNIN;
752 ShowScreenWithData(OobeScreen::SCREEN_GAIA_SIGNIN, params); 745 ShowScreenWithData(OobeScreen::SCREEN_GAIA_SIGNIN, params);
753 break; 746 break;
754 case UI_STATE_ACCOUNT_PICKER: 747 case UI_STATE_ACCOUNT_PICKER:
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 // Forces a reload for Gaia screen on hiding error message. 963 // Forces a reload for Gaia screen on hiding error message.
971 if (IsGaiaVisible() || IsGaiaHiddenByError()) 964 if (IsGaiaVisible() || IsGaiaHiddenByError())
972 ReloadGaia(reason == NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED); 965 ReloadGaia(reason == NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED);
973 } 966 }
974 967
975 void SigninScreenHandler::ReloadGaia(bool force_reload) { 968 void SigninScreenHandler::ReloadGaia(bool force_reload) {
976 gaia_screen_handler_->ReloadGaia(force_reload); 969 gaia_screen_handler_->ReloadGaia(force_reload);
977 } 970 }
978 971
979 void SigninScreenHandler::Initialize() { 972 void SigninScreenHandler::Initialize() {
980 // Preload PIN keyboard if any of the users can authenticate via PIN. 973 // Preload pin keyboard if any of the users can authenticate via pin.
981 if (user_manager::UserManager::IsInitialized()) { 974 if (user_manager::UserManager::IsInitialized()) {
982 for (user_manager::User* user : 975 for (user_manager::User* user :
983 user_manager::UserManager::Get()->GetUnlockUsers()) { 976 user_manager::UserManager::Get()->GetUnlockUsers()) {
984 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage = 977 chromeos::quick_unlock::PinBackend::CanAuthenticate(
985 chromeos::quick_unlock::QuickUnlockFactory::GetForUser(user); 978 user->GetAccountId(),
986 if (quick_unlock_storage && 979 base::Bind(&SigninScreenHandler::PreloadPinKeyboardCallback,
987 quick_unlock_storage->IsPinAuthenticationAvailable()) { 980 weak_factory_.GetWeakPtr()));
988 CallJS("cr.ui.Oobe.preloadPinKeyboard");
989 break;
990 }
991 } 981 }
992 } 982 }
993 983
994 // |delegate_| is null when we are preloading the lock screen. 984 // |delegate_| is null when we are preloading the lock screen.
995 if (delegate_ && show_on_init_) { 985 if (delegate_ && show_on_init_) {
996 show_on_init_ = false; 986 show_on_init_ = false;
997 ShowImpl(); 987 ShowImpl();
998 } 988 }
999 } 989 }
1000 990
(...skipping 21 matching lines...) Expand all
1022 1012
1023 void SigninScreenHandler::ClearUserPodPassword() { 1013 void SigninScreenHandler::ClearUserPodPassword() {
1024 core_oobe_view_->ClearUserPodPassword(); 1014 core_oobe_view_->ClearUserPodPassword();
1025 } 1015 }
1026 1016
1027 void SigninScreenHandler::RefocusCurrentPod() { 1017 void SigninScreenHandler::RefocusCurrentPod() {
1028 core_oobe_view_->RefocusCurrentPod(); 1018 core_oobe_view_->RefocusCurrentPod();
1029 } 1019 }
1030 1020
1031 void SigninScreenHandler::UpdatePinKeyboardState(const AccountId& account_id) { 1021 void SigninScreenHandler::UpdatePinKeyboardState(const AccountId& account_id) {
1032 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage = 1022 chromeos::quick_unlock::PinBackend::CanAuthenticate(
1033 chromeos::quick_unlock::QuickUnlockFactory::GetForAccountId(account_id); 1023 account_id,
1034 if (!quick_unlock_storage) 1024 base::Bind(&SigninScreenHandler::UpdatePinKeyboardStateCallback,
1035 return; 1025 weak_factory_.GetWeakPtr(), account_id));
1026 }
1036 1027
1037 bool is_enabled = quick_unlock_storage->IsPinAuthenticationAvailable(); 1028 void SigninScreenHandler::UpdatePinKeyboardStateCallback(
1029 const AccountId& account_id,
1030 bool is_enabled) {
1038 CallJS("login.AccountPickerScreen.setPinEnabledForUser", account_id, 1031 CallJS("login.AccountPickerScreen.setPinEnabledForUser", account_id,
1039 is_enabled); 1032 is_enabled);
1040 } 1033 }
1041 1034
1035 void SigninScreenHandler::PreloadPinKeyboardCallback(bool should_enabled) {
1036 if (should_enabled)
1037 CallJS("cr.ui.Oobe.preloadPinKeyboard");
1038 }
1039
1042 void SigninScreenHandler::OnUserRemoved(const AccountId& account_id, 1040 void SigninScreenHandler::OnUserRemoved(const AccountId& account_id,
1043 bool last_user_removed) { 1041 bool last_user_removed) {
1044 CallJS("login.AccountPickerScreen.removeUser", account_id); 1042 CallJS("login.AccountPickerScreen.removeUser", account_id);
1045 if (last_user_removed) 1043 if (last_user_removed)
1046 OnShowAddUser(); 1044 OnShowAddUser();
1047 } 1045 }
1048 1046
1049 void SigninScreenHandler::OnUserImageChanged(const user_manager::User& user) { 1047 void SigninScreenHandler::OnUserImageChanged(const user_manager::User& user) {
1050 if (page_is_ready()) { 1048 if (page_is_ready()) {
1051 CallJSOrDefer("login.AccountPickerScreen.updateUserImage", 1049 CallJSOrDefer("login.AccountPickerScreen.updateUserImage",
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 AllWhitelistedUsersPresent()); 1202 AllWhitelistedUsersPresent());
1205 } 1203 }
1206 1204
1207 void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id, 1205 void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id,
1208 const std::string& password, 1206 const std::string& password,
1209 bool authenticated_by_pin) { 1207 bool authenticated_by_pin) {
1210 if (!delegate_) 1208 if (!delegate_)
1211 return; 1209 return;
1212 DCHECK_EQ(account_id.GetUserEmail(), 1210 DCHECK_EQ(account_id.GetUserEmail(),
1213 gaia::SanitizeEmail(account_id.GetUserEmail())); 1211 gaia::SanitizeEmail(account_id.GetUserEmail()));
1214 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage =
1215 chromeos::quick_unlock::QuickUnlockFactory::GetForAccountId(account_id);
1216 // If pin storage is unavailable, authenticated by PIN must be false.
1217 DCHECK(!quick_unlock_storage ||
1218 quick_unlock_storage->IsPinAuthenticationAvailable() ||
1219 !authenticated_by_pin);
1220 1212
1221 UserContext user_context(account_id); 1213 UserContext user_context(account_id);
1222 user_context.SetKey(Key(password)); 1214 user_context.SetKey(Key(password));
1223 user_context.SetIsUsingPin(authenticated_by_pin); 1215 user_context.SetIsUsingPin(authenticated_by_pin);
1224 if (account_id.GetAccountType() == AccountType::ACTIVE_DIRECTORY) 1216 if (account_id.GetAccountType() == AccountType::ACTIVE_DIRECTORY)
1225 user_context.SetUserType(user_manager::USER_TYPE_ACTIVE_DIRECTORY); 1217 user_context.SetUserType(user_manager::USER_TYPE_ACTIVE_DIRECTORY);
1226 delegate_->Login(user_context, SigninSpecifics()); 1218 delegate_->Login(user_context, SigninSpecifics());
1227 1219
1228 UpdatePinKeyboardState(account_id); 1220 UpdatePinKeyboardState(account_id);
1229 } 1221 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 policy::BrowserPolicyConnectorChromeOS* connector = 1328 policy::BrowserPolicyConnectorChromeOS* connector =
1337 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 1329 g_browser_process->platform_part()->browser_policy_connector_chromeos();
1338 if (delegate_ && !connector->IsEnterpriseManaged()) 1330 if (delegate_ && !connector->IsEnterpriseManaged())
1339 delegate_->ShowKioskAutolaunchScreen(); 1331 delegate_->ShowKioskAutolaunchScreen();
1340 } 1332 }
1341 1333
1342 void SigninScreenHandler::LoadUsers(const user_manager::UserList& users, 1334 void SigninScreenHandler::LoadUsers(const user_manager::UserList& users,
1343 const base::ListValue& users_list) { 1335 const base::ListValue& users_list) {
1344 CallJSOrDefer("login.AccountPickerScreen.loadUsers", users_list, 1336 CallJSOrDefer("login.AccountPickerScreen.loadUsers", users_list,
1345 delegate_->IsShowGuest()); 1337 delegate_->IsShowGuest());
1338
1339 // Enable pin for any users who can use it.
1340 // TODO(jdufault): Cache pin state (in storage accessible in login) so we
1341 // don't need to requery cryptohome every time we show login. See
1342 // crbug.com/721938.
1343 for (user_manager::User* user : users)
1344 UpdatePinKeyboardState(user->GetAccountId());
1346 } 1345 }
1347 1346
1348 void SigninScreenHandler::HandleAccountPickerReady() { 1347 void SigninScreenHandler::HandleAccountPickerReady() {
1349 VLOG(0) << "Login WebUI >> AccountPickerReady"; 1348 VLOG(0) << "Login WebUI >> AccountPickerReady";
1350 1349
1351 if (delegate_ && !ScreenLocker::default_screen_locker() && 1350 if (delegate_ && !ScreenLocker::default_screen_locker() &&
1352 !chromeos::IsMachineHWIDCorrect() && 1351 !chromeos::IsMachineHWIDCorrect() &&
1353 !oobe_ui_) { 1352 !oobe_ui_) {
1354 delegate_->ShowWrongHWIDScreen(); 1353 delegate_->ShowWrongHWIDScreen();
1355 return; 1354 return;
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 rate.initial_delay_in_ms = auto_repeat_delay; 1705 rate.initial_delay_in_ms = auto_repeat_delay;
1707 rate.repeat_interval_in_ms = auto_repeat_interval; 1706 rate.repeat_interval_in_ms = auto_repeat_interval;
1708 input_method::InputMethodManager::Get() 1707 input_method::InputMethodManager::Get()
1709 ->GetImeKeyboard() 1708 ->GetImeKeyboard()
1710 ->SetAutoRepeatEnabled(true); 1709 ->SetAutoRepeatEnabled(true);
1711 input_method::InputMethodManager::Get()->GetImeKeyboard()->SetAutoRepeatRate( 1710 input_method::InputMethodManager::Get()->GetImeKeyboard()->SetAutoRepeatRate(
1712 rate); 1711 rate);
1713 } 1712 }
1714 1713
1715 } // namespace chromeos 1714 } // namespace chromeos
OLDNEW
« 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