| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 return network->name(); | 197 return network->name(); |
| 198 } | 198 } |
| 199 | 199 |
| 200 static bool SetUserInputMethodImpl( | 200 static bool SetUserInputMethodImpl( |
| 201 const std::string& username, | 201 const std::string& username, |
| 202 const std::string& user_input_method, | 202 const std::string& user_input_method, |
| 203 input_method::InputMethodManager::State* ime_state) { | 203 input_method::InputMethodManager::State* ime_state) { |
| 204 if (!chromeos::input_method::InputMethodManager::Get()->IsLoginKeyboard( | 204 if (!chromeos::input_method::InputMethodManager::Get()->IsLoginKeyboard( |
| 205 user_input_method)) { | 205 user_input_method)) { |
| 206 LOG(WARNING) << "SetUserInputMethod('" << username | 206 LOG(WARNING) << "SetUserInputMethod('" << username |
| 207 << "'): stored user LRU input method '" << user_input_method | 207 << "'): stored user last input method '" << user_input_method |
| 208 << "' is no longer Full Latin Keyboard Language" | 208 << "' is no longer Full Latin Keyboard Language" |
| 209 << " (entry dropped). Use hardware default instead."; | 209 << " (entry dropped). Use hardware default instead."; |
| 210 | 210 |
| 211 PrefService* const local_state = g_browser_process->local_state(); | 211 PrefService* const local_state = g_browser_process->local_state(); |
| 212 DictionaryPrefUpdate updater(local_state, prefs::kUsersLRUInputMethod); | 212 DictionaryPrefUpdate updater(local_state, prefs::kUsersLastInputMethod); |
| 213 | 213 |
| 214 base::DictionaryValue* const users_lru_input_methods = updater.Get(); | 214 base::DictionaryValue* const users_last_input_methods = updater.Get(); |
| 215 if (users_lru_input_methods != nullptr) { | 215 if (users_last_input_methods != nullptr) { |
| 216 users_lru_input_methods->SetStringWithoutPathExpansion(username, ""); | 216 users_last_input_methods->SetStringWithoutPathExpansion(username, ""); |
| 217 } | 217 } |
| 218 return false; | 218 return false; |
| 219 } | 219 } |
| 220 | 220 |
| 221 if (!Contains(ime_state->GetActiveInputMethodIds(), user_input_method)) { | 221 if (!Contains(ime_state->GetActiveInputMethodIds(), user_input_method)) { |
| 222 if (!ime_state->EnableInputMethod(user_input_method)) { | 222 if (!ime_state->EnableInputMethod(user_input_method)) { |
| 223 DLOG(ERROR) << "SigninScreenHandler::SetUserInputMethod('" << username | 223 DLOG(ERROR) << "SigninScreenHandler::SetUserInputMethod('" << username |
| 224 << "'): user input method '" << user_input_method | 224 << "'): user input method '" << user_input_method |
| 225 << "' is not enabled and enabling failed (ignored!)."; | 225 << "' is not enabled and enabling failed (ignored!)."; |
| 226 } | 226 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 StopEnforcingPolicyInputMethods(); | 356 StopEnforcingPolicyInputMethods(); |
| 357 weak_factory_.InvalidateWeakPtrs(); | 357 weak_factory_.InvalidateWeakPtrs(); |
| 358 if (delegate_) | 358 if (delegate_) |
| 359 delegate_->SetWebUIHandler(nullptr); | 359 delegate_->SetWebUIHandler(nullptr); |
| 360 network_state_informer_->RemoveObserver(this); | 360 network_state_informer_->RemoveObserver(this); |
| 361 proximity_auth::ScreenlockBridge::Get()->SetLockHandler(nullptr); | 361 proximity_auth::ScreenlockBridge::Get()->SetLockHandler(nullptr); |
| 362 proximity_auth::ScreenlockBridge::Get()->SetFocusedUser(EmptyAccountId()); | 362 proximity_auth::ScreenlockBridge::Get()->SetFocusedUser(EmptyAccountId()); |
| 363 } | 363 } |
| 364 | 364 |
| 365 // static | 365 // static |
| 366 std::string SigninScreenHandler::GetUserLRUInputMethod( | 366 std::string SigninScreenHandler::GetUserLastInputMethod( |
| 367 const std::string& username) { | 367 const std::string& username) { |
| 368 PrefService* const local_state = g_browser_process->local_state(); | 368 PrefService* const local_state = g_browser_process->local_state(); |
| 369 const base::DictionaryValue* users_lru_input_methods = | 369 const base::DictionaryValue* users_last_input_methods = |
| 370 local_state->GetDictionary(prefs::kUsersLRUInputMethod); | 370 local_state->GetDictionary(prefs::kUsersLastInputMethod); |
| 371 | 371 |
| 372 if (!users_lru_input_methods) { | 372 if (!users_last_input_methods) { |
| 373 DLOG(WARNING) << "GetUserLRUInputMethod('" << username | 373 DLOG(WARNING) << "GetUserLastInputMethod('" << username |
| 374 << "'): no kUsersLRUInputMethod"; | 374 << "'): no kUsersLastInputMethod"; |
| 375 return std::string(); | 375 return std::string(); |
| 376 } | 376 } |
| 377 | 377 |
| 378 std::string input_method; | 378 std::string input_method; |
| 379 | 379 |
| 380 if (!users_lru_input_methods->GetStringWithoutPathExpansion(username, | 380 if (!users_last_input_methods->GetStringWithoutPathExpansion(username, |
| 381 &input_method)) { | 381 &input_method)) { |
| 382 DVLOG(0) << "GetUserLRUInputMethod('" << username | 382 DVLOG(0) << "GetUserLastInputMethod('" << username |
| 383 << "'): no input method for this user"; | 383 << "'): no input method for this user"; |
| 384 return std::string(); | 384 return std::string(); |
| 385 } | 385 } |
| 386 | 386 |
| 387 return input_method; | 387 return input_method; |
| 388 } | 388 } |
| 389 | 389 |
| 390 // static | 390 // static |
| 391 // Update keyboard layout to least recently used by the user. | 391 // Update keyboard layout to least recently used by the user. |
| 392 void SigninScreenHandler::SetUserInputMethod( | 392 void SigninScreenHandler::SetUserInputMethod( |
| 393 const std::string& username, | 393 const std::string& username, |
| 394 input_method::InputMethodManager::State* ime_state) { | 394 input_method::InputMethodManager::State* ime_state) { |
| 395 bool succeed = false; | 395 bool succeed = false; |
| 396 | 396 |
| 397 const std::string input_method = GetUserLRUInputMethod(username); | 397 const std::string input_method = GetUserLastInputMethod(username); |
| 398 | 398 |
| 399 EnforcePolicyInputMethods(input_method); | 399 EnforcePolicyInputMethods(input_method); |
| 400 | 400 |
| 401 if (!input_method.empty()) | 401 if (!input_method.empty()) |
| 402 succeed = SetUserInputMethodImpl(username, input_method, ime_state); | 402 succeed = SetUserInputMethodImpl(username, input_method, ime_state); |
| 403 | 403 |
| 404 // This is also a case when LRU layout is set only for a few local users, | 404 // This is also a case when last layout is set only for a few local users, |
| 405 // thus others need to be switched to default locale. | 405 // thus others need to be switched to default locale. |
| 406 // Otherwise they will end up using another user's locale to log in. | 406 // Otherwise they will end up using another user's locale to log in. |
| 407 if (!succeed) { | 407 if (!succeed) { |
| 408 DVLOG(0) << "SetUserInputMethod('" << username | 408 DVLOG(0) << "SetUserInputMethod('" << username |
| 409 << "'): failed to set user layout. Switching to default."; | 409 << "'): failed to set user layout. Switching to default."; |
| 410 | 410 |
| 411 ime_state->SetInputMethodLoginDefault(); | 411 ime_state->SetInputMethodLoginDefault(); |
| 412 } | 412 } |
| 413 } | 413 } |
| 414 | 414 |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 } | 975 } |
| 976 } | 976 } |
| 977 | 977 |
| 978 gfx::NativeWindow SigninScreenHandler::GetNativeWindow() { | 978 gfx::NativeWindow SigninScreenHandler::GetNativeWindow() { |
| 979 if (native_window_delegate_) | 979 if (native_window_delegate_) |
| 980 return native_window_delegate_->GetNativeWindow(); | 980 return native_window_delegate_->GetNativeWindow(); |
| 981 return nullptr; | 981 return nullptr; |
| 982 } | 982 } |
| 983 | 983 |
| 984 void SigninScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) { | 984 void SigninScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) { |
| 985 registry->RegisterDictionaryPref(prefs::kUsersLRUInputMethod); | 985 registry->RegisterDictionaryPref(prefs::kUsersLastInputMethod); |
| 986 } | 986 } |
| 987 | 987 |
| 988 void SigninScreenHandler::OnCurrentScreenChanged(OobeScreen current_screen, | 988 void SigninScreenHandler::OnCurrentScreenChanged(OobeScreen current_screen, |
| 989 OobeScreen new_screen) { | 989 OobeScreen new_screen) { |
| 990 if (new_screen == OobeScreen::SCREEN_ACCOUNT_PICKER) { | 990 if (new_screen == OobeScreen::SCREEN_ACCOUNT_PICKER) { |
| 991 // Restore active IME state if returning to user pod row screen. | 991 // Restore active IME state if returning to user pod row screen. |
| 992 input_method::InputMethodManager::Get()->SetState(ime_state_); | 992 input_method::InputMethodManager::Get()->SetState(ime_state_); |
| 993 } | 993 } |
| 994 } | 994 } |
| 995 | 995 |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1612 void SigninScreenHandler::OnFeedbackFinished() { | 1612 void SigninScreenHandler::OnFeedbackFinished() { |
| 1613 CallJS("login.UnrecoverableCryptohomeErrorScreen.resumeAfterFeedbackUI"); | 1613 CallJS("login.UnrecoverableCryptohomeErrorScreen.resumeAfterFeedbackUI"); |
| 1614 | 1614 |
| 1615 // Recreate user's cryptohome after the feedback is attempted. | 1615 // Recreate user's cryptohome after the feedback is attempted. |
| 1616 HandleResyncUserData(); | 1616 HandleResyncUserData(); |
| 1617 } | 1617 } |
| 1618 | 1618 |
| 1619 void SigninScreenHandler::OnAllowedInputMethodsChanged() { | 1619 void SigninScreenHandler::OnAllowedInputMethodsChanged() { |
| 1620 if (focused_pod_account_id_) { | 1620 if (focused_pod_account_id_) { |
| 1621 std::string user_input_method = | 1621 std::string user_input_method = |
| 1622 GetUserLRUInputMethod(focused_pod_account_id_->GetUserEmail()); | 1622 GetUserLastInputMethod(focused_pod_account_id_->GetUserEmail()); |
| 1623 EnforcePolicyInputMethods(user_input_method); | 1623 EnforcePolicyInputMethods(user_input_method); |
| 1624 } else { | 1624 } else { |
| 1625 EnforcePolicyInputMethods(std::string()); | 1625 EnforcePolicyInputMethods(std::string()); |
| 1626 } | 1626 } |
| 1627 } | 1627 } |
| 1628 | 1628 |
| 1629 void SigninScreenHandler::SetKeyboardSettings(const AccountId& account_id) { | 1629 void SigninScreenHandler::SetKeyboardSettings(const AccountId& account_id) { |
| 1630 bool auto_repeat_enabled = language_prefs::kXkbAutoRepeatEnabled; | 1630 bool auto_repeat_enabled = language_prefs::kXkbAutoRepeatEnabled; |
| 1631 if (user_manager::known_user::GetBooleanPref( | 1631 if (user_manager::known_user::GetBooleanPref( |
| 1632 account_id, prefs::kLanguageXkbAutoRepeatEnabled, | 1632 account_id, prefs::kLanguageXkbAutoRepeatEnabled, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1648 rate.initial_delay_in_ms = auto_repeat_delay; | 1648 rate.initial_delay_in_ms = auto_repeat_delay; |
| 1649 rate.repeat_interval_in_ms = auto_repeat_interval; | 1649 rate.repeat_interval_in_ms = auto_repeat_interval; |
| 1650 input_method::InputMethodManager::Get() | 1650 input_method::InputMethodManager::Get() |
| 1651 ->GetImeKeyboard() | 1651 ->GetImeKeyboard() |
| 1652 ->SetAutoRepeatEnabled(true); | 1652 ->SetAutoRepeatEnabled(true); |
| 1653 input_method::InputMethodManager::Get()->GetImeKeyboard()->SetAutoRepeatRate( | 1653 input_method::InputMethodManager::Get()->GetImeKeyboard()->SetAutoRepeatRate( |
| 1654 rate); | 1654 rate); |
| 1655 } | 1655 } |
| 1656 | 1656 |
| 1657 } // namespace chromeos | 1657 } // namespace chromeos |
| OLD | NEW |