| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/input_method/input_method_persistence.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_persistence.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
| 10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 current_input_method_on_pref); | 100 current_input_method_on_pref); |
| 101 user_prefs->SetString(prefs::kLanguageCurrentInputMethod, | 101 user_prefs->SetString(prefs::kLanguageCurrentInputMethod, |
| 102 input_method); | 102 input_method); |
| 103 } | 103 } |
| 104 | 104 |
| 105 } // namespace | 105 } // namespace |
| 106 | 106 |
| 107 InputMethodPersistence::InputMethodPersistence( | 107 InputMethodPersistence::InputMethodPersistence( |
| 108 InputMethodManager* input_method_manager) | 108 InputMethodManager* input_method_manager) |
| 109 : input_method_manager_(input_method_manager), | 109 : input_method_manager_(input_method_manager), |
| 110 state_(InputMethodManager::STATE_LOGIN_SCREEN) { | 110 ui_state_(InputMethodManager::STATE_LOGIN_SCREEN) { |
| 111 input_method_manager_->AddObserver(this); | 111 input_method_manager_->AddObserver(this); |
| 112 } | 112 } |
| 113 | 113 |
| 114 InputMethodPersistence::~InputMethodPersistence() { | 114 InputMethodPersistence::~InputMethodPersistence() { |
| 115 input_method_manager_->RemoveObserver(this); | 115 input_method_manager_->RemoveObserver(this); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void InputMethodPersistence::InputMethodChanged( | 118 void InputMethodPersistence::InputMethodChanged( |
| 119 InputMethodManager* manager, bool show_message) { | 119 InputMethodManager* manager, bool show_message) { |
| 120 DCHECK_EQ(input_method_manager_, manager); | 120 DCHECK_EQ(input_method_manager_, manager); |
| 121 const std::string current_input_method = | 121 const std::string current_input_method = |
| 122 manager->GetCurrentInputMethod().id(); | 122 manager->GetCurrentInputMethod().id(); |
| 123 // Save the new input method id depending on the current browser state. | 123 // Save the new input method id depending on the current browser state. |
| 124 switch (state_) { | 124 switch (ui_state_) { |
| 125 case InputMethodManager::STATE_LOGIN_SCREEN: | 125 case InputMethodManager::STATE_LOGIN_SCREEN: |
| 126 if (!manager->IsLoginKeyboard(current_input_method)) { | 126 if (!manager->IsLoginKeyboard(current_input_method)) { |
| 127 DVLOG(1) << "Only keyboard layouts are supported: " | 127 DVLOG(1) << "Only keyboard layouts are supported: " |
| 128 << current_input_method; | 128 << current_input_method; |
| 129 return; | 129 return; |
| 130 } | 130 } |
| 131 PersistSystemInputMethod(current_input_method); | 131 PersistSystemInputMethod(current_input_method); |
| 132 return; | 132 return; |
| 133 case InputMethodManager::STATE_BROWSER_SCREEN: | 133 case InputMethodManager::STATE_BROWSER_SCREEN: |
| 134 PersistUserInputMethod(current_input_method, manager); | 134 PersistUserInputMethod(current_input_method, manager); |
| 135 return; | 135 return; |
| 136 case InputMethodManager::STATE_LOCK_SCREEN: | 136 case InputMethodManager::STATE_LOCK_SCREEN: |
| 137 // We use a special set of input methods on the screen. Do not update. | 137 // We use a special set of input methods on the screen. Do not update. |
| 138 return; | 138 return; |
| 139 case InputMethodManager::STATE_TERMINATING: | 139 case InputMethodManager::STATE_TERMINATING: |
| 140 return; | 140 return; |
| 141 } | 141 } |
| 142 NOTREACHED(); | 142 NOTREACHED(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void InputMethodPersistence::OnSessionStateChange( | 145 void InputMethodPersistence::OnSessionStateChange( |
| 146 InputMethodManager::State new_state) { | 146 InputMethodManager::UIState new_ui_state) { |
| 147 state_ = new_state; | 147 ui_state_ = new_ui_state; |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace input_method | 150 } // namespace input_method |
| 151 } // namespace chromeos | 151 } // namespace chromeos |
| OLD | NEW |