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