OLD | NEW |
---|---|
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 21 matching lines...) Expand all Loading... | |
32 #include "chrome/browser/browser_process_platform_part_chromeos.h" | 32 #include "chrome/browser/browser_process_platform_part_chromeos.h" |
33 #include "chrome/browser/browser_shutdown.h" | 33 #include "chrome/browser/browser_shutdown.h" |
34 #include "chrome/browser/chrome_notification_types.h" | 34 #include "chrome/browser/chrome_notification_types.h" |
35 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 35 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
36 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 36 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
37 #include "chrome/browser/chromeos/language_preferences.h" | 37 #include "chrome/browser/chromeos/language_preferences.h" |
38 #include "chrome/browser/chromeos/login/error_screens_histogram_helper.h" | 38 #include "chrome/browser/chromeos/login/error_screens_histogram_helper.h" |
39 #include "chrome/browser/chromeos/login/hwid_checker.h" | 39 #include "chrome/browser/chromeos/login/hwid_checker.h" |
40 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 40 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
41 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" | 41 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" |
42 #include "chrome/browser/chromeos/login/quick_unlock/pin_backend.h" | |
42 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h" | 43 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h" |
43 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h" | 44 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h" |
44 #include "chrome/browser/chromeos/login/reauth_stats.h" | 45 #include "chrome/browser/chromeos/login/reauth_stats.h" |
45 #include "chrome/browser/chromeos/login/screens/core_oobe_view.h" | 46 #include "chrome/browser/chromeos/login/screens/core_oobe_view.h" |
46 #include "chrome/browser/chromeos/login/screens/network_error.h" | 47 #include "chrome/browser/chromeos/login/screens/network_error.h" |
47 #include "chrome/browser/chromeos/login/startup_utils.h" | 48 #include "chrome/browser/chromeos/login/startup_utils.h" |
48 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 49 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
49 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 50 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
50 #include "chrome/browser/chromeos/login/ui/login_feedback.h" | 51 #include "chrome/browser/chromeos/login/ui/login_feedback.h" |
51 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 52 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
713 | 714 |
714 // Reset Caps Lock state when login screen is shown. | 715 // Reset Caps Lock state when login screen is shown. |
715 input_method::InputMethodManager::Get() | 716 input_method::InputMethodManager::Get() |
716 ->GetImeKeyboard() | 717 ->GetImeKeyboard() |
717 ->SetCapsLockEnabled(false); | 718 ->SetCapsLockEnabled(false); |
718 | 719 |
719 base::DictionaryValue params; | 720 base::DictionaryValue params; |
720 params.SetBoolean("disableAddUser", AllWhitelistedUsersPresent()); | 721 params.SetBoolean("disableAddUser", AllWhitelistedUsersPresent()); |
721 UpdateUIState(UI_STATE_ACCOUNT_PICKER, ¶ms); | 722 UpdateUIState(UI_STATE_ACCOUNT_PICKER, ¶ms); |
722 } | 723 } |
723 | |
724 // Enable pin for any users who can use it. | |
725 if (user_manager::UserManager::IsInitialized()) { | |
726 for (user_manager::User* user : | |
727 user_manager::UserManager::Get()->GetLoggedInUsers()) { | |
728 UpdatePinKeyboardState(user->GetAccountId()); | |
729 } | |
730 } | |
731 } | 724 } |
732 | 725 |
733 void SigninScreenHandler::UpdateUIState(UIState ui_state, | 726 void SigninScreenHandler::UpdateUIState(UIState ui_state, |
734 base::DictionaryValue* params) { | 727 base::DictionaryValue* params) { |
735 switch (ui_state) { | 728 switch (ui_state) { |
736 case UI_STATE_GAIA_SIGNIN: | 729 case UI_STATE_GAIA_SIGNIN: |
737 ui_state_ = UI_STATE_GAIA_SIGNIN; | 730 ui_state_ = UI_STATE_GAIA_SIGNIN; |
738 ShowScreenWithData(OobeScreen::SCREEN_GAIA_SIGNIN, params); | 731 ShowScreenWithData(OobeScreen::SCREEN_GAIA_SIGNIN, params); |
739 break; | 732 break; |
740 case UI_STATE_ACCOUNT_PICKER: | 733 case UI_STATE_ACCOUNT_PICKER: |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
956 // Forces a reload for Gaia screen on hiding error message. | 949 // Forces a reload for Gaia screen on hiding error message. |
957 if (IsGaiaVisible() || IsGaiaHiddenByError()) | 950 if (IsGaiaVisible() || IsGaiaHiddenByError()) |
958 ReloadGaia(reason == NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED); | 951 ReloadGaia(reason == NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED); |
959 } | 952 } |
960 | 953 |
961 void SigninScreenHandler::ReloadGaia(bool force_reload) { | 954 void SigninScreenHandler::ReloadGaia(bool force_reload) { |
962 gaia_screen_handler_->ReloadGaia(force_reload); | 955 gaia_screen_handler_->ReloadGaia(force_reload); |
963 } | 956 } |
964 | 957 |
965 void SigninScreenHandler::Initialize() { | 958 void SigninScreenHandler::Initialize() { |
966 // Preload PIN keyboard if any of the users can authenticate via PIN. | 959 // Preload pin keyboard if any of the users can authenticate via pin. |
967 if (user_manager::UserManager::IsInitialized()) { | 960 if (user_manager::UserManager::IsInitialized()) { |
968 for (user_manager::User* user : | 961 for (user_manager::User* user : |
969 user_manager::UserManager::Get()->GetUnlockUsers()) { | 962 user_manager::UserManager::Get()->GetUnlockUsers()) { |
970 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage = | 963 chromeos::quick_unlock::PinBackend::CanAuthenticate( |
971 chromeos::quick_unlock::QuickUnlockFactory::GetForUser(user); | 964 user->GetAccountId(), |
972 if (quick_unlock_storage && | 965 base::Bind(&SigninScreenHandler::PreloadPinKeyboardCallback, |
973 quick_unlock_storage->IsPinAuthenticationAvailable()) { | 966 weak_factory_.GetWeakPtr())); |
974 CallJS("cr.ui.Oobe.preloadPinKeyboard"); | |
975 break; | |
976 } | |
977 } | 967 } |
978 } | 968 } |
979 | 969 |
980 // |delegate_| is null when we are preloading the lock screen. | 970 // |delegate_| is null when we are preloading the lock screen. |
981 if (delegate_ && show_on_init_) { | 971 if (delegate_ && show_on_init_) { |
982 show_on_init_ = false; | 972 show_on_init_ = false; |
983 ShowImpl(); | 973 ShowImpl(); |
984 } | 974 } |
985 } | 975 } |
986 | 976 |
(...skipping 21 matching lines...) Expand all Loading... | |
1008 | 998 |
1009 void SigninScreenHandler::ClearUserPodPassword() { | 999 void SigninScreenHandler::ClearUserPodPassword() { |
1010 core_oobe_view_->ClearUserPodPassword(); | 1000 core_oobe_view_->ClearUserPodPassword(); |
1011 } | 1001 } |
1012 | 1002 |
1013 void SigninScreenHandler::RefocusCurrentPod() { | 1003 void SigninScreenHandler::RefocusCurrentPod() { |
1014 core_oobe_view_->RefocusCurrentPod(); | 1004 core_oobe_view_->RefocusCurrentPod(); |
1015 } | 1005 } |
1016 | 1006 |
1017 void SigninScreenHandler::UpdatePinKeyboardState(const AccountId& account_id) { | 1007 void SigninScreenHandler::UpdatePinKeyboardState(const AccountId& account_id) { |
1018 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage = | 1008 chromeos::quick_unlock::PinBackend::CanAuthenticate( |
1019 chromeos::quick_unlock::QuickUnlockFactory::GetForAccountId(account_id); | 1009 account_id, |
1020 if (!quick_unlock_storage) | 1010 base::Bind(&SigninScreenHandler::UpdatePinKeyboardStateCallback, |
1021 return; | 1011 weak_factory_.GetWeakPtr(), account_id)); |
1012 } | |
1022 | 1013 |
1023 bool is_enabled = quick_unlock_storage->IsPinAuthenticationAvailable(); | 1014 void SigninScreenHandler::UpdatePinKeyboardStateCallback( |
1015 const AccountId& account_id, | |
1016 bool is_enabled) { | |
1024 CallJS("login.AccountPickerScreen.setPinEnabledForUser", account_id, | 1017 CallJS("login.AccountPickerScreen.setPinEnabledForUser", account_id, |
1025 is_enabled); | 1018 is_enabled); |
1026 } | 1019 } |
1027 | 1020 |
1021 void SigninScreenHandler::PreloadPinKeyboardCallback(bool should_enabled) { | |
1022 if (should_enabled) | |
1023 CallJS("cr.ui.Oobe.preloadPinKeyboard"); | |
1024 } | |
1025 | |
1028 void SigninScreenHandler::OnUserRemoved(const AccountId& account_id, | 1026 void SigninScreenHandler::OnUserRemoved(const AccountId& account_id, |
1029 bool last_user_removed) { | 1027 bool last_user_removed) { |
1030 CallJS("login.AccountPickerScreen.removeUser", account_id); | 1028 CallJS("login.AccountPickerScreen.removeUser", account_id); |
1031 if (last_user_removed) | 1029 if (last_user_removed) |
1032 OnShowAddUser(); | 1030 OnShowAddUser(); |
1033 } | 1031 } |
1034 | 1032 |
1035 void SigninScreenHandler::OnUserImageChanged(const user_manager::User& user) { | 1033 void SigninScreenHandler::OnUserImageChanged(const user_manager::User& user) { |
1036 if (page_is_ready()) { | 1034 if (page_is_ready()) { |
1037 CallJSOrDefer("login.AccountPickerScreen.updateUserImage", | 1035 CallJSOrDefer("login.AccountPickerScreen.updateUserImage", |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1170 AllWhitelistedUsersPresent()); | 1168 AllWhitelistedUsersPresent()); |
1171 } | 1169 } |
1172 | 1170 |
1173 void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id, | 1171 void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id, |
1174 const std::string& password, | 1172 const std::string& password, |
1175 bool authenticated_by_pin) { | 1173 bool authenticated_by_pin) { |
1176 if (!delegate_) | 1174 if (!delegate_) |
1177 return; | 1175 return; |
1178 DCHECK_EQ(account_id.GetUserEmail(), | 1176 DCHECK_EQ(account_id.GetUserEmail(), |
1179 gaia::SanitizeEmail(account_id.GetUserEmail())); | 1177 gaia::SanitizeEmail(account_id.GetUserEmail())); |
1180 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage = | |
1181 chromeos::quick_unlock::QuickUnlockFactory::GetForAccountId(account_id); | |
1182 // If pin storage is unavailable, authenticated by PIN must be false. | |
1183 DCHECK(!quick_unlock_storage || | |
1184 quick_unlock_storage->IsPinAuthenticationAvailable() || | |
1185 !authenticated_by_pin); | |
1186 | 1178 |
1187 UserContext user_context(account_id); | 1179 UserContext user_context(account_id); |
1188 user_context.SetKey(Key(password)); | 1180 user_context.SetKey(Key(password)); |
1189 user_context.SetIsUsingPin(authenticated_by_pin); | 1181 user_context.SetIsUsingPin(authenticated_by_pin); |
1190 if (account_id.GetAccountType() == AccountType::ACTIVE_DIRECTORY) | 1182 if (account_id.GetAccountType() == AccountType::ACTIVE_DIRECTORY) |
1191 user_context.SetUserType(user_manager::USER_TYPE_ACTIVE_DIRECTORY); | 1183 user_context.SetUserType(user_manager::USER_TYPE_ACTIVE_DIRECTORY); |
1192 delegate_->Login(user_context, SigninSpecifics()); | 1184 delegate_->Login(user_context, SigninSpecifics()); |
1193 | 1185 |
1194 UpdatePinKeyboardState(account_id); | 1186 UpdatePinKeyboardState(account_id); |
1195 } | 1187 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1302 policy::BrowserPolicyConnectorChromeOS* connector = | 1294 policy::BrowserPolicyConnectorChromeOS* connector = |
1303 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 1295 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
1304 if (delegate_ && !connector->IsEnterpriseManaged()) | 1296 if (delegate_ && !connector->IsEnterpriseManaged()) |
1305 delegate_->ShowKioskAutolaunchScreen(); | 1297 delegate_->ShowKioskAutolaunchScreen(); |
1306 } | 1298 } |
1307 | 1299 |
1308 void SigninScreenHandler::LoadUsers(const user_manager::UserList& users, | 1300 void SigninScreenHandler::LoadUsers(const user_manager::UserList& users, |
1309 const base::ListValue& users_list) { | 1301 const base::ListValue& users_list) { |
1310 CallJSOrDefer("login.AccountPickerScreen.loadUsers", users_list, | 1302 CallJSOrDefer("login.AccountPickerScreen.loadUsers", users_list, |
1311 delegate_->IsShowGuest()); | 1303 delegate_->IsShowGuest()); |
1304 | |
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.
| |
1305 // Enable pin for any users who can use it. | |
1306 for (user_manager::User* user : users) | |
1307 UpdatePinKeyboardState(user->GetAccountId()); | |
1312 } | 1308 } |
1313 | 1309 |
1314 void SigninScreenHandler::HandleAccountPickerReady() { | 1310 void SigninScreenHandler::HandleAccountPickerReady() { |
1315 VLOG(0) << "Login WebUI >> AccountPickerReady"; | 1311 VLOG(0) << "Login WebUI >> AccountPickerReady"; |
1316 | 1312 |
1317 if (delegate_ && !ScreenLocker::default_screen_locker() && | 1313 if (delegate_ && !ScreenLocker::default_screen_locker() && |
1318 !chromeos::IsMachineHWIDCorrect() && | 1314 !chromeos::IsMachineHWIDCorrect() && |
1319 !oobe_ui_) { | 1315 !oobe_ui_) { |
1320 delegate_->ShowWrongHWIDScreen(); | 1316 delegate_->ShowWrongHWIDScreen(); |
1321 return; | 1317 return; |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1656 rate.initial_delay_in_ms = auto_repeat_delay; | 1652 rate.initial_delay_in_ms = auto_repeat_delay; |
1657 rate.repeat_interval_in_ms = auto_repeat_interval; | 1653 rate.repeat_interval_in_ms = auto_repeat_interval; |
1658 input_method::InputMethodManager::Get() | 1654 input_method::InputMethodManager::Get() |
1659 ->GetImeKeyboard() | 1655 ->GetImeKeyboard() |
1660 ->SetAutoRepeatEnabled(true); | 1656 ->SetAutoRepeatEnabled(true); |
1661 input_method::InputMethodManager::Get()->GetImeKeyboard()->SetAutoRepeatRate( | 1657 input_method::InputMethodManager::Get()->GetImeKeyboard()->SetAutoRepeatRate( |
1662 rate); | 1658 rate); |
1663 } | 1659 } |
1664 | 1660 |
1665 } // namespace chromeos | 1661 } // namespace chromeos |
OLD | NEW |