| 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 5b21d4fbb74a18ca33a86a7999b0227725d228ef..f7f2aff53255ea32da7fcb53b61c91c54da66173 100644
|
| --- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
|
| +++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
|
| @@ -175,36 +175,16 @@ std::string GetNetworkName(const std::string& service_path) {
|
|
|
| static bool SetUserInputMethodImpl(
|
| const std::string& username,
|
| - chromeos::input_method::InputMethodManager* manager) {
|
| - PrefService* const local_state = g_browser_process->local_state();
|
| -
|
| - const base::DictionaryValue* users_lru_input_methods =
|
| - local_state->GetDictionary(prefs::kUsersLRUInputMethod);
|
| -
|
| - if (users_lru_input_methods == NULL) {
|
| - DLOG(WARNING) << "SetUserInputMethod('" << username
|
| - << "'): no kUsersLRUInputMethod";
|
| - return false;
|
| - }
|
| -
|
| - std::string input_method;
|
| -
|
| - if (!users_lru_input_methods->GetStringWithoutPathExpansion(username,
|
| - &input_method)) {
|
| - DVLOG(0) << "SetUserInputMethod('" << username
|
| - << "'): no input method for this user";
|
| - return false;
|
| - }
|
| -
|
| - if (input_method.empty())
|
| - return false;
|
| -
|
| - if (!manager->IsLoginKeyboard(input_method)) {
|
| + const std::string& user_input_method,
|
| + input_method::InputMethodManager::State* ime_state) {
|
| + if (!chromeos::input_method::InputMethodManager::Get()->IsLoginKeyboard(
|
| + user_input_method)) {
|
| LOG(WARNING) << "SetUserInputMethod('" << username
|
| - << "'): stored user LRU input method '" << input_method
|
| + << "'): stored user LRU input method '" << user_input_method
|
| << "' is no longer Full Latin Keyboard Language"
|
| << " (entry dropped). Use hardware default instead.";
|
|
|
| + PrefService* const local_state = g_browser_process->local_state();
|
| DictionaryPrefUpdate updater(local_state, prefs::kUsersLRUInputMethod);
|
|
|
| base::DictionaryValue* const users_lru_input_methods = updater.Get();
|
| @@ -214,16 +194,14 @@ static bool SetUserInputMethodImpl(
|
| return false;
|
| }
|
|
|
| - if (!Contains(manager->GetActiveIMEState()->GetActiveInputMethodIds(),
|
| - input_method)) {
|
| - if (!manager->GetActiveIMEState()->EnableInputMethod(input_method)) {
|
| + if (!Contains(ime_state->GetActiveInputMethodIds(), user_input_method)) {
|
| + if (!ime_state->EnableInputMethod(user_input_method)) {
|
| DLOG(ERROR) << "SigninScreenHandler::SetUserInputMethod('" << username
|
| - << "'): user input method '" << input_method
|
| + << "'): user input method '" << user_input_method
|
| << "' is not enabled and enabling failed (ignored!).";
|
| }
|
| }
|
| - manager->GetActiveIMEState()->ChangeInputMethod(input_method,
|
| - false /* show_message */);
|
| + ime_state->ChangeInputMethod(user_input_method, false /* show_message */);
|
|
|
| return true;
|
| }
|
| @@ -314,6 +292,9 @@ SigninScreenHandler::SigninScreenHandler(
|
| }
|
|
|
| SigninScreenHandler::~SigninScreenHandler() {
|
| + OobeUI* oobe_ui = GetOobeUI();
|
| + if (oobe_ui)
|
| + oobe_ui->RemoveObserver(this);
|
| chromeos::input_method::ImeKeyboard* keyboard =
|
| chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard();
|
| if (keyboard)
|
| @@ -477,6 +458,11 @@ void SigninScreenHandler::UpdateState(ErrorScreenActor::ErrorReason reason) {
|
| UpdateStateInternal(reason, false);
|
| }
|
|
|
| +void SigninScreenHandler::SetFocusPODCallbackForTesting(
|
| + base::Closure callback) {
|
| + test_focus_pod_callback_ = callback;
|
| +}
|
| +
|
| // SigninScreenHandler, private: -----------------------------------------------
|
|
|
| void SigninScreenHandler::ShowImpl() {
|
| @@ -485,6 +471,11 @@ void SigninScreenHandler::ShowImpl() {
|
| return;
|
| }
|
|
|
| + if (!ime_state_.get())
|
| + ime_state_ = input_method::InputMethodManager::Get()->GetActiveIMEState();
|
| +
|
| + GetOobeUI()->AddObserver(this);
|
| +
|
| if (oobe_ui_ || is_enrolling_consumer_management_) {
|
| // Shows new user sign-in for OOBE.
|
| OnShowAddUser();
|
| @@ -793,6 +784,38 @@ void SigninScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) {
|
| registry->RegisterDictionaryPref(prefs::kUsersLRUInputMethod);
|
| }
|
|
|
| +void SigninScreenHandler::OnCurrentScreenChanged(OobeUI::Screen current_screen,
|
| + OobeUI::Screen new_screen) {
|
| + if (new_screen == OobeUI::SCREEN_ACCOUNT_PICKER) {
|
| + // Restore active IME state if returning to user pod row screen.
|
| + input_method::InputMethodManager::Get()->SetState(ime_state_);
|
| + }
|
| +}
|
| +
|
| +std::string SigninScreenHandler::GetUserLRUInputMethod(
|
| + const std::string& username) const {
|
| + PrefService* const local_state = g_browser_process->local_state();
|
| + const base::DictionaryValue* users_lru_input_methods =
|
| + local_state->GetDictionary(prefs::kUsersLRUInputMethod);
|
| +
|
| + if (users_lru_input_methods == NULL) {
|
| + DLOG(WARNING) << "GetUserLRUInputMethod('" << username
|
| + << "'): no kUsersLRUInputMethod";
|
| + return std::string();
|
| + }
|
| +
|
| + std::string input_method;
|
| +
|
| + if (!users_lru_input_methods->GetStringWithoutPathExpansion(username,
|
| + &input_method)) {
|
| + DVLOG(0) << "GetUserLRUInputMethod('" << username
|
| + << "'): no input method for this user";
|
| + return std::string();
|
| + }
|
| +
|
| + return input_method;
|
| +}
|
| +
|
| void SigninScreenHandler::HandleGetUsers() {
|
| if (delegate_)
|
| delegate_->HandleGetUsers();
|
| @@ -999,7 +1022,9 @@ bool SigninScreenHandler::ShouldLoadGaia() const {
|
| }
|
|
|
| // Update keyboard layout to least recently used by the user.
|
| -void SigninScreenHandler::SetUserInputMethod(const std::string& username) {
|
| +void SigninScreenHandler::SetUserInputMethod(
|
| + const std::string& username,
|
| + input_method::InputMethodManager::State* ime_state) {
|
| user_manager::UserManager* user_manager = user_manager::UserManager::Get();
|
| if (user_manager->IsUserLoggedIn()) {
|
| // We are on sign-in screen inside user session (adding new user to
|
| @@ -1009,10 +1034,12 @@ void SigninScreenHandler::SetUserInputMethod(const std::string& username) {
|
| return;
|
| }
|
|
|
| - chromeos::input_method::InputMethodManager* const manager =
|
| - chromeos::input_method::InputMethodManager::Get();
|
| + bool succeed = false;
|
|
|
| - const bool succeed = SetUserInputMethodImpl(username, manager);
|
| + const std::string input_method = GetUserLRUInputMethod(username);
|
| +
|
| + if (!input_method.empty())
|
| + succeed = SetUserInputMethodImpl(username, input_method, ime_state);
|
|
|
| // This is also a case when LRU layout is set only for a few local users,
|
| // thus others need to be switched to default locale.
|
| @@ -1021,7 +1048,7 @@ void SigninScreenHandler::SetUserInputMethod(const std::string& username) {
|
| DVLOG(0) << "SetUserInputMethod('" << username
|
| << "'): failed to set user layout. Switching to default.";
|
|
|
| - manager->GetActiveIMEState()->SetInputMethodLoginDefault();
|
| + ime_state->SetInputMethodLoginDefault();
|
| }
|
| }
|
|
|
| @@ -1324,8 +1351,10 @@ void SigninScreenHandler::HandleUpdateOfflineLogin(bool offline_login_active) {
|
| }
|
|
|
| void SigninScreenHandler::HandleFocusPod(const std::string& user_id) {
|
| - SetUserInputMethod(user_id);
|
| + SetUserInputMethod(user_id, ime_state_.get());
|
| WallpaperManager::Get()->SetUserWallpaperDelayed(user_id);
|
| + if (!test_focus_pod_callback_.is_null())
|
| + test_focus_pod_callback_.Run();
|
| }
|
|
|
| void SigninScreenHandler::HandleHardlockPod(const std::string& user_id) {
|
| @@ -1426,9 +1455,13 @@ void SigninScreenHandler::CancelPasswordChangedFlowInternal() {
|
| }
|
| }
|
|
|
| +OobeUI* SigninScreenHandler::GetOobeUI() const {
|
| + return static_cast<OobeUI*>(web_ui()->GetController());
|
| +}
|
| +
|
| OobeUI::Screen SigninScreenHandler::GetCurrentScreen() const {
|
| OobeUI::Screen screen = OobeUI::SCREEN_UNKNOWN;
|
| - OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController());
|
| + OobeUI* oobe_ui = GetOobeUI();
|
| if (oobe_ui)
|
| screen = oobe_ui->current_screen();
|
| return screen;
|
|
|