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

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

Issue 484353005: ChromeOS: "Add New User" screen should enable all hardware keyboards. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after review. Created 6 years, 3 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
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 <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 std::string GetNetworkName(const std::string& service_path) { 168 std::string GetNetworkName(const std::string& service_path) {
169 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> 169 const NetworkState* network = NetworkHandler::Get()->network_state_handler()->
170 GetNetworkState(service_path); 170 GetNetworkState(service_path);
171 if (!network) 171 if (!network)
172 return std::string(); 172 return std::string();
173 return network->name(); 173 return network->name();
174 } 174 }
175 175
176 static bool SetUserInputMethodImpl( 176 static bool SetUserInputMethodImpl(
177 const std::string& username, 177 const std::string& username,
178 chromeos::input_method::InputMethodManager* manager) { 178 const std::string& user_input_method,
179 PrefService* const local_state = g_browser_process->local_state(); 179 input_method::InputMethodManager::State* ime_state) {
180 180 if (!chromeos::input_method::InputMethodManager::Get()->IsLoginKeyboard(
181 const base::DictionaryValue* users_lru_input_methods = 181 user_input_method)) {
182 local_state->GetDictionary(prefs::kUsersLRUInputMethod);
183
184 if (users_lru_input_methods == NULL) {
185 DLOG(WARNING) << "SetUserInputMethod('" << username
186 << "'): no kUsersLRUInputMethod";
187 return false;
188 }
189
190 std::string input_method;
191
192 if (!users_lru_input_methods->GetStringWithoutPathExpansion(username,
193 &input_method)) {
194 DVLOG(0) << "SetUserInputMethod('" << username
195 << "'): no input method for this user";
196 return false;
197 }
198
199 if (input_method.empty())
200 return false;
201
202 if (!manager->IsLoginKeyboard(input_method)) {
203 LOG(WARNING) << "SetUserInputMethod('" << username 182 LOG(WARNING) << "SetUserInputMethod('" << username
204 << "'): stored user LRU input method '" << input_method 183 << "'): stored user LRU input method '" << user_input_method
205 << "' is no longer Full Latin Keyboard Language" 184 << "' is no longer Full Latin Keyboard Language"
206 << " (entry dropped). Use hardware default instead."; 185 << " (entry dropped). Use hardware default instead.";
207 186
187 PrefService* const local_state = g_browser_process->local_state();
208 DictionaryPrefUpdate updater(local_state, prefs::kUsersLRUInputMethod); 188 DictionaryPrefUpdate updater(local_state, prefs::kUsersLRUInputMethod);
209 189
210 base::DictionaryValue* const users_lru_input_methods = updater.Get(); 190 base::DictionaryValue* const users_lru_input_methods = updater.Get();
211 if (users_lru_input_methods != NULL) { 191 if (users_lru_input_methods != NULL) {
212 users_lru_input_methods->SetStringWithoutPathExpansion(username, ""); 192 users_lru_input_methods->SetStringWithoutPathExpansion(username, "");
213 } 193 }
214 return false; 194 return false;
215 } 195 }
216 196
217 if (!Contains(manager->GetActiveIMEState()->GetActiveInputMethodIds(), 197 if (!Contains(ime_state->GetActiveInputMethodIds(), user_input_method)) {
218 input_method)) { 198 if (!ime_state->EnableInputMethod(user_input_method)) {
219 if (!manager->GetActiveIMEState()->EnableInputMethod(input_method)) {
220 DLOG(ERROR) << "SigninScreenHandler::SetUserInputMethod('" << username 199 DLOG(ERROR) << "SigninScreenHandler::SetUserInputMethod('" << username
221 << "'): user input method '" << input_method 200 << "'): user input method '" << user_input_method
222 << "' is not enabled and enabling failed (ignored!)."; 201 << "' is not enabled and enabling failed (ignored!).";
223 } 202 }
224 } 203 }
225 manager->GetActiveIMEState()->ChangeInputMethod(input_method, 204 ime_state->ChangeInputMethod(user_input_method, false /* show_message */);
226 false /* show_message */);
227 205
228 return true; 206 return true;
229 } 207 }
230 208
231 } // namespace 209 } // namespace
232 210
233 // LoginScreenContext implementation ------------------------------------------ 211 // LoginScreenContext implementation ------------------------------------------
234 212
235 LoginScreenContext::LoginScreenContext() { 213 LoginScreenContext::LoginScreenContext() {
236 Init(); 214 Init();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 policy::ConsumerManagementService* consumer_management = 285 policy::ConsumerManagementService* consumer_management =
308 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> 286 g_browser_process->platform_part()->browser_policy_connector_chromeos()->
309 GetConsumerManagementService(); 287 GetConsumerManagementService();
310 is_enrolling_consumer_management_ = 288 is_enrolling_consumer_management_ =
311 consumer_management && 289 consumer_management &&
312 consumer_management->GetEnrollmentStage() == 290 consumer_management->GetEnrollmentStage() ==
313 policy::ConsumerManagementService::ENROLLMENT_STAGE_REQUESTED; 291 policy::ConsumerManagementService::ENROLLMENT_STAGE_REQUESTED;
314 } 292 }
315 293
316 SigninScreenHandler::~SigninScreenHandler() { 294 SigninScreenHandler::~SigninScreenHandler() {
295 OobeUI* oobe_ui = GetOobeUI();
296 if (oobe_ui)
297 oobe_ui->RemoveObserver(this);
317 chromeos::input_method::ImeKeyboard* keyboard = 298 chromeos::input_method::ImeKeyboard* keyboard =
318 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); 299 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard();
319 if (keyboard) 300 if (keyboard)
320 keyboard->RemoveObserver(this); 301 keyboard->RemoveObserver(this);
321 weak_factory_.InvalidateWeakPtrs(); 302 weak_factory_.InvalidateWeakPtrs();
322 if (delegate_) 303 if (delegate_)
323 delegate_->SetWebUIHandler(NULL); 304 delegate_->SetWebUIHandler(NULL);
324 network_state_informer_->RemoveObserver(this); 305 network_state_informer_->RemoveObserver(this);
325 if (max_mode_delegate_) { 306 if (max_mode_delegate_) {
326 max_mode_delegate_->RemoveObserver(this); 307 max_mode_delegate_->RemoveObserver(this);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 void SigninScreenHandler::OnNetworkReady() { 451 void SigninScreenHandler::OnNetworkReady() {
471 VLOG(1) << "OnNetworkReady() call."; 452 VLOG(1) << "OnNetworkReady() call.";
472 DCHECK(gaia_screen_handler_); 453 DCHECK(gaia_screen_handler_);
473 gaia_screen_handler_->MaybePreloadAuthExtension(); 454 gaia_screen_handler_->MaybePreloadAuthExtension();
474 } 455 }
475 456
476 void SigninScreenHandler::UpdateState(ErrorScreenActor::ErrorReason reason) { 457 void SigninScreenHandler::UpdateState(ErrorScreenActor::ErrorReason reason) {
477 UpdateStateInternal(reason, false); 458 UpdateStateInternal(reason, false);
478 } 459 }
479 460
461 void SigninScreenHandler::SetFocusPODCallbackForTesting(
462 base::Closure callback) {
463 test_focus_pod_callback_ = callback;
464 }
465
480 // SigninScreenHandler, private: ----------------------------------------------- 466 // SigninScreenHandler, private: -----------------------------------------------
481 467
482 void SigninScreenHandler::ShowImpl() { 468 void SigninScreenHandler::ShowImpl() {
483 if (!page_is_ready()) { 469 if (!page_is_ready()) {
484 show_on_init_ = true; 470 show_on_init_ = true;
485 return; 471 return;
486 } 472 }
487 473
474 if (!ime_state_.get())
475 ime_state_ = input_method::InputMethodManager::Get()->GetActiveIMEState();
476
477 GetOobeUI()->AddObserver(this);
478
488 if (oobe_ui_ || is_enrolling_consumer_management_) { 479 if (oobe_ui_ || is_enrolling_consumer_management_) {
489 // Shows new user sign-in for OOBE. 480 // Shows new user sign-in for OOBE.
490 OnShowAddUser(); 481 OnShowAddUser();
491 } else { 482 } else {
492 // Populates account picker. Animation is turned off for now until we 483 // Populates account picker. Animation is turned off for now until we
493 // figure out how to make it fast enough. 484 // figure out how to make it fast enough.
494 delegate_->HandleGetUsers(); 485 delegate_->HandleGetUsers();
495 486
496 // Reset Caps Lock state when login screen is shown. 487 // Reset Caps Lock state when login screen is shown.
497 input_method::InputMethodManager::Get() 488 input_method::InputMethodManager::Get()
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 777
787 // This message is sent by the kiosk app menu, but is handled here 778 // This message is sent by the kiosk app menu, but is handled here
788 // so we can tell the delegate to launch the app. 779 // so we can tell the delegate to launch the app.
789 AddCallback("launchKioskApp", &SigninScreenHandler::HandleLaunchKioskApp); 780 AddCallback("launchKioskApp", &SigninScreenHandler::HandleLaunchKioskApp);
790 } 781 }
791 782
792 void SigninScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) { 783 void SigninScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) {
793 registry->RegisterDictionaryPref(prefs::kUsersLRUInputMethod); 784 registry->RegisterDictionaryPref(prefs::kUsersLRUInputMethod);
794 } 785 }
795 786
787 void SigninScreenHandler::OnCurrentScreenChanged(OobeUI::Screen current_screen,
788 OobeUI::Screen new_screen) {
789 if (new_screen == OobeUI::SCREEN_ACCOUNT_PICKER) {
790 // Restore active IME state if returning to user pod row screen.
791 input_method::InputMethodManager::Get()->SetState(ime_state_);
792 }
793 }
794
795 std::string SigninScreenHandler::GetUserLRUInputMethod(
796 const std::string& username) const {
797 PrefService* const local_state = g_browser_process->local_state();
798 const base::DictionaryValue* users_lru_input_methods =
799 local_state->GetDictionary(prefs::kUsersLRUInputMethod);
800
801 if (users_lru_input_methods == NULL) {
802 DLOG(WARNING) << "GetUserLRUInputMethod('" << username
803 << "'): no kUsersLRUInputMethod";
804 return std::string();
805 }
806
807 std::string input_method;
808
809 if (!users_lru_input_methods->GetStringWithoutPathExpansion(username,
810 &input_method)) {
811 DVLOG(0) << "GetUserLRUInputMethod('" << username
812 << "'): no input method for this user";
813 return std::string();
814 }
815
816 return input_method;
817 }
818
796 void SigninScreenHandler::HandleGetUsers() { 819 void SigninScreenHandler::HandleGetUsers() {
797 if (delegate_) 820 if (delegate_)
798 delegate_->HandleGetUsers(); 821 delegate_->HandleGetUsers();
799 } 822 }
800 823
801 void SigninScreenHandler::ClearAndEnablePassword() { 824 void SigninScreenHandler::ClearAndEnablePassword() {
802 core_oobe_actor_->ResetSignInUI(false); 825 core_oobe_actor_->ResetSignInUI(false);
803 } 826 }
804 827
805 void SigninScreenHandler::ClearUserPodPassword() { 828 void SigninScreenHandler::ClearUserPodPassword() {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 1015
993 bool SigninScreenHandler::ShouldLoadGaia() const { 1016 bool SigninScreenHandler::ShouldLoadGaia() const {
994 // Fetching of the extension is not started before account picker page is 1017 // Fetching of the extension is not started before account picker page is
995 // loaded because it can affect the loading speed. 1018 // loaded because it can affect the loading speed.
996 // Do not load the extension for the screen locker, see crosbug.com/25018. 1019 // Do not load the extension for the screen locker, see crosbug.com/25018.
997 return !ScreenLocker::default_screen_locker() && 1020 return !ScreenLocker::default_screen_locker() &&
998 is_account_picker_showing_first_time_; 1021 is_account_picker_showing_first_time_;
999 } 1022 }
1000 1023
1001 // Update keyboard layout to least recently used by the user. 1024 // Update keyboard layout to least recently used by the user.
1002 void SigninScreenHandler::SetUserInputMethod(const std::string& username) { 1025 void SigninScreenHandler::SetUserInputMethod(
1026 const std::string& username,
1027 input_method::InputMethodManager::State* ime_state) {
1003 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); 1028 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
1004 if (user_manager->IsUserLoggedIn()) { 1029 if (user_manager->IsUserLoggedIn()) {
1005 // We are on sign-in screen inside user session (adding new user to 1030 // We are on sign-in screen inside user session (adding new user to
1006 // the session or on lock screen), don't switch input methods in this case. 1031 // the session or on lock screen), don't switch input methods in this case.
1007 // TODO(dpolukhin): adding user and sign-in should be consistent 1032 // TODO(dpolukhin): adding user and sign-in should be consistent
1008 // crbug.com/292774 1033 // crbug.com/292774
1009 return; 1034 return;
1010 } 1035 }
1011 1036
1012 chromeos::input_method::InputMethodManager* const manager = 1037 bool succeed = false;
1013 chromeos::input_method::InputMethodManager::Get();
1014 1038
1015 const bool succeed = SetUserInputMethodImpl(username, manager); 1039 const std::string input_method = GetUserLRUInputMethod(username);
1040
1041 if (!input_method.empty())
1042 succeed = SetUserInputMethodImpl(username, input_method, ime_state);
1016 1043
1017 // This is also a case when LRU layout is set only for a few local users, 1044 // This is also a case when LRU layout is set only for a few local users,
1018 // thus others need to be switched to default locale. 1045 // thus others need to be switched to default locale.
1019 // Otherwise they will end up using another user's locale to log in. 1046 // Otherwise they will end up using another user's locale to log in.
1020 if (!succeed) { 1047 if (!succeed) {
1021 DVLOG(0) << "SetUserInputMethod('" << username 1048 DVLOG(0) << "SetUserInputMethod('" << username
1022 << "'): failed to set user layout. Switching to default."; 1049 << "'): failed to set user layout. Switching to default.";
1023 1050
1024 manager->GetActiveIMEState()->SetInputMethodLoginDefault(); 1051 ime_state->SetInputMethodLoginDefault();
1025 } 1052 }
1026 } 1053 }
1027 1054
1028 1055
1029 void SigninScreenHandler::UserSettingsChanged() { 1056 void SigninScreenHandler::UserSettingsChanged() {
1030 DCHECK(gaia_screen_handler_); 1057 DCHECK(gaia_screen_handler_);
1031 GaiaContext context; 1058 GaiaContext context;
1032 if (delegate_) 1059 if (delegate_)
1033 context.has_users = !delegate_->GetUsers().empty(); 1060 context.has_users = !delegate_->GetUsers().empty();
1034 gaia_screen_handler_->UpdateGaia(context); 1061 gaia_screen_handler_->UpdateGaia(context);
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 1344
1318 void SigninScreenHandler::HandleShowLoadingTimeoutError() { 1345 void SigninScreenHandler::HandleShowLoadingTimeoutError() {
1319 UpdateState(ErrorScreenActor::ERROR_REASON_LOADING_TIMEOUT); 1346 UpdateState(ErrorScreenActor::ERROR_REASON_LOADING_TIMEOUT);
1320 } 1347 }
1321 1348
1322 void SigninScreenHandler::HandleUpdateOfflineLogin(bool offline_login_active) { 1349 void SigninScreenHandler::HandleUpdateOfflineLogin(bool offline_login_active) {
1323 offline_login_active_ = offline_login_active; 1350 offline_login_active_ = offline_login_active;
1324 } 1351 }
1325 1352
1326 void SigninScreenHandler::HandleFocusPod(const std::string& user_id) { 1353 void SigninScreenHandler::HandleFocusPod(const std::string& user_id) {
1327 SetUserInputMethod(user_id); 1354 SetUserInputMethod(user_id, ime_state_.get());
1328 WallpaperManager::Get()->SetUserWallpaperDelayed(user_id); 1355 WallpaperManager::Get()->SetUserWallpaperDelayed(user_id);
1356 if (!test_focus_pod_callback_.is_null())
1357 test_focus_pod_callback_.Run();
1329 } 1358 }
1330 1359
1331 void SigninScreenHandler::HandleHardlockPod(const std::string& user_id) { 1360 void SigninScreenHandler::HandleHardlockPod(const std::string& user_id) {
1332 SetAuthType(user_id, 1361 SetAuthType(user_id,
1333 ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD, 1362 ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD,
1334 base::string16()); 1363 base::string16());
1335 HideUserPodCustomIcon(user_id); 1364 HideUserPodCustomIcon(user_id);
1336 } 1365 }
1337 1366
1338 void SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail( 1367 void SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail(
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 return true; 1448 return true;
1420 } 1449 }
1421 1450
1422 void SigninScreenHandler::CancelPasswordChangedFlowInternal() { 1451 void SigninScreenHandler::CancelPasswordChangedFlowInternal() {
1423 if (delegate_) { 1452 if (delegate_) {
1424 ShowImpl(); 1453 ShowImpl();
1425 delegate_->CancelPasswordChangedFlow(); 1454 delegate_->CancelPasswordChangedFlow();
1426 } 1455 }
1427 } 1456 }
1428 1457
1458 OobeUI* SigninScreenHandler::GetOobeUI() const {
1459 return static_cast<OobeUI*>(web_ui()->GetController());
1460 }
1461
1429 OobeUI::Screen SigninScreenHandler::GetCurrentScreen() const { 1462 OobeUI::Screen SigninScreenHandler::GetCurrentScreen() const {
1430 OobeUI::Screen screen = OobeUI::SCREEN_UNKNOWN; 1463 OobeUI::Screen screen = OobeUI::SCREEN_UNKNOWN;
1431 OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController()); 1464 OobeUI* oobe_ui = GetOobeUI();
1432 if (oobe_ui) 1465 if (oobe_ui)
1433 screen = oobe_ui->current_screen(); 1466 screen = oobe_ui->current_screen();
1434 return screen; 1467 return screen;
1435 } 1468 }
1436 1469
1437 bool SigninScreenHandler::IsGaiaVisible() const { 1470 bool SigninScreenHandler::IsGaiaVisible() const {
1438 return IsSigninScreen(GetCurrentScreen()) && 1471 return IsSigninScreen(GetCurrentScreen()) &&
1439 ui_state_ == UI_STATE_GAIA_SIGNIN; 1472 ui_state_ == UI_STATE_GAIA_SIGNIN;
1440 } 1473 }
1441 1474
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 return gaia_screen_handler_->frame_error(); 1545 return gaia_screen_handler_->frame_error();
1513 } 1546 }
1514 1547
1515 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { 1548 void SigninScreenHandler::OnCapsLockChanged(bool enabled) {
1516 caps_lock_enabled_ = enabled; 1549 caps_lock_enabled_ = enabled;
1517 if (page_is_ready()) 1550 if (page_is_ready())
1518 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); 1551 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_);
1519 } 1552 }
1520 1553
1521 } // namespace chromeos 1554 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698