Chromium Code Reviews| 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_manager_impl.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> // std::find | 7 #include <algorithm> // std::find |
| 8 | 8 |
| 9 #include <sstream> | |
| 10 | |
| 9 #include "ash/ime/input_method_menu_item.h" | 11 #include "ash/ime/input_method_menu_item.h" |
| 10 #include "ash/ime/input_method_menu_manager.h" | 12 #include "ash/ime/input_method_menu_manager.h" |
| 11 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 12 #include "base/bind.h" | 14 #include "base/bind.h" |
| 13 #include "base/location.h" | 15 #include "base/location.h" |
| 14 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
| 16 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
| 17 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 18 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 49 bool InputMethodManagerImpl::IsLoginKeyboard( | 51 bool InputMethodManagerImpl::IsLoginKeyboard( |
| 50 const std::string& layout) const { | 52 const std::string& layout) const { |
| 51 return util_.IsLoginKeyboard(layout); | 53 return util_.IsLoginKeyboard(layout); |
| 52 } | 54 } |
| 53 | 55 |
| 54 bool InputMethodManagerImpl::MigrateInputMethods( | 56 bool InputMethodManagerImpl::MigrateInputMethods( |
| 55 std::vector<std::string>* input_method_ids) { | 57 std::vector<std::string>* input_method_ids) { |
| 56 return util_.MigrateInputMethods(input_method_ids); | 58 return util_.MigrateInputMethods(input_method_ids); |
| 57 } | 59 } |
| 58 | 60 |
| 61 InputMethodManagerImpl::State::State() { | |
| 62 } | |
| 63 | |
| 64 InputMethodManagerImpl::State::~State() { | |
| 65 } | |
| 66 | |
| 67 void InputMethodManagerImpl::State::InitFrom(const State& other) { | |
| 68 // debug_name is not copied. | |
| 69 | |
| 70 previous_input_method_ = other.previous_input_method_; | |
| 71 current_input_method_ = other.current_input_method_; | |
| 72 | |
| 73 active_input_method_ids_ = other.active_input_method_ids_; | |
| 74 | |
| 75 saved_previous_input_method_ = other.saved_previous_input_method_; | |
| 76 saved_current_input_method_ = other.saved_current_input_method_; | |
| 77 saved_active_input_method_ids_ = other.saved_active_input_method_ids_; | |
| 78 | |
| 79 pending_input_method_ = other.pending_input_method_; | |
| 80 | |
| 81 // TODO: recreate all input engines? | |
| 82 // typedef std::map<std::string, InputMethodEngineInterface*> EngineMap; | |
| 83 engine_map_ = other.engine_map_; | |
| 84 } | |
| 85 | |
| 86 std::string InputMethodManagerImpl::State::Dump() const { | |
| 87 std::ostringstream os; | |
| 88 | |
| 89 os << "################# " << state_name << " #################\n"; | |
| 90 | |
| 91 os << "previous_input_method_: '" | |
| 92 << previous_input_method_.GetPreferredKeyboardLayout() << "'\n"; | |
| 93 os << "current_input_method_: '" | |
| 94 << current_input_method_.GetPreferredKeyboardLayout() << "'\n"; | |
| 95 os << "active_input_method_ids_ (size=" << active_input_method_ids_.size() | |
| 96 << "):"; | |
| 97 for (size_t i = 0; i < active_input_method_ids_.size(); ++i) { | |
| 98 os << " '" << active_input_method_ids_[i] << "',"; | |
| 99 } | |
| 100 os << "\n"; | |
| 101 os << "saved_previous_input_method_: '" | |
| 102 << saved_previous_input_method_.GetPreferredKeyboardLayout() << "'\n"; | |
| 103 os << "saved_current_input_method_: '" | |
| 104 << saved_current_input_method_.GetPreferredKeyboardLayout() << "'\n"; | |
| 105 os << "saved_active_input_method_ids_ (size=" | |
| 106 << saved_active_input_method_ids_.size() << "):"; | |
| 107 for (size_t i = 0; i < saved_active_input_method_ids_.size(); ++i) { | |
| 108 os << " '" << saved_active_input_method_ids_[i] << "'\n"; | |
| 109 } | |
| 110 os << "pending_input_method_: '" << pending_input_method_ << "'\n"; | |
| 111 os << "engine_map_ (size=" << engine_map_.size() << "): ...\n "; | |
| 112 | |
| 113 return os.str(); | |
| 114 } | |
| 115 | |
| 116 scoped_refptr<InputMethodManager::State> InputMethodManagerImpl::CreateNewState( | |
| 117 const std::string& debug_name) const { | |
| 118 scoped_refptr<InputMethodManagerImpl::State> new_state( | |
| 119 new InputMethodManagerImpl::State); | |
| 120 new_state->state_name = debug_name; | |
| 121 | |
| 122 return scoped_refptr<InputMethodManager::State>(new_state.get()); | |
| 123 } | |
| 124 | |
| 125 void InputMethodManagerImpl::SetState( | |
|
Shu Chen
2014/08/04 14:55:23
I guess this is for fast user switching, correct?
Alexander Alekseev
2014/08/06 23:39:45
Yes, this was one of my concerns, when I've upload
Shu Chen
2014/08/07 15:40:19
I think enabled_extension_imes_ should not be shar
Alexander Alekseev
2014/08/07 17:26:19
But it is still shared. (I don't understand why.)
| |
| 126 scoped_refptr<InputMethodManager::State> state) { | |
| 127 LOG(ERROR) << "InputMethodManagerImpl::SetState(): Called."; | |
| 128 LOG(ERROR) << "InputMethodManagerImpl::SetState(): old state_: " | |
| 129 << (state_ ? state_->Dump() : std::string("NULL")); | |
| 130 state_ = static_cast<InputMethodManagerImpl::State*>(state.get()); | |
| 131 LOG(ERROR) << "InputMethodManagerImpl::SetState(): new state_: " | |
| 132 << (state_ ? state_->Dump() : std::string("NULL")); | |
| 133 if (state_->active_input_method_ids_.size()) { | |
| 134 ReconfigureIMFramework(); | |
| 135 ChangeInputMethodInternal(state_->current_input_method_, false); | |
|
Shu Chen
2014/08/04 14:55:23
Is there particular reason of calling ChangeInputM
Alexander Alekseev
2014/08/06 23:39:45
The idea is that SetState should be lightweight, b
Shu Chen
2014/08/07 15:40:19
I think ReconfigureIMEFramework() is not heavy, be
Alexander Alekseev
2014/08/07 17:26:18
Extensions are not unloaded. From the extensions p
| |
| 136 } | |
| 137 } | |
| 138 | |
| 59 InputMethodManagerImpl::InputMethodManagerImpl( | 139 InputMethodManagerImpl::InputMethodManagerImpl( |
| 60 scoped_ptr<InputMethodDelegate> delegate) | 140 scoped_ptr<InputMethodDelegate> delegate) |
| 61 : delegate_(delegate.Pass()), | 141 : delegate_(delegate.Pass()), |
| 62 state_(STATE_LOGIN_SCREEN), | 142 ui_state_(STATE_LOGIN_SCREEN), |
| 63 util_(delegate_.get(), whitelist_.GetSupportedInputMethods()), | 143 util_(delegate_.get(), whitelist_.GetSupportedInputMethods()), |
| 64 component_extension_ime_manager_(new ComponentExtensionIMEManager()), | 144 component_extension_ime_manager_(new ComponentExtensionIMEManager()), |
| 65 weak_ptr_factory_(this) { | 145 weak_ptr_factory_(this) { |
| 146 SetState(CreateNewState("default")); | |
| 66 } | 147 } |
| 67 | 148 |
| 68 InputMethodManagerImpl::~InputMethodManagerImpl() { | 149 InputMethodManagerImpl::~InputMethodManagerImpl() { |
| 69 if (candidate_window_controller_.get()) | 150 if (candidate_window_controller_.get()) |
| 70 candidate_window_controller_->RemoveObserver(this); | 151 candidate_window_controller_->RemoveObserver(this); |
| 71 } | 152 } |
| 72 | 153 |
| 73 void InputMethodManagerImpl::AddObserver( | 154 void InputMethodManagerImpl::AddObserver( |
| 74 InputMethodManager::Observer* observer) { | 155 InputMethodManager::Observer* observer) { |
| 75 observers_.AddObserver(observer); | 156 observers_.AddObserver(observer); |
| 76 } | 157 } |
| 77 | 158 |
| 78 void InputMethodManagerImpl::AddCandidateWindowObserver( | 159 void InputMethodManagerImpl::AddCandidateWindowObserver( |
| 79 InputMethodManager::CandidateWindowObserver* observer) { | 160 InputMethodManager::CandidateWindowObserver* observer) { |
| 80 candidate_window_observers_.AddObserver(observer); | 161 candidate_window_observers_.AddObserver(observer); |
| 81 } | 162 } |
| 82 | 163 |
| 83 void InputMethodManagerImpl::RemoveObserver( | 164 void InputMethodManagerImpl::RemoveObserver( |
| 84 InputMethodManager::Observer* observer) { | 165 InputMethodManager::Observer* observer) { |
| 85 observers_.RemoveObserver(observer); | 166 observers_.RemoveObserver(observer); |
| 86 } | 167 } |
| 87 | 168 |
| 88 void InputMethodManagerImpl::RemoveCandidateWindowObserver( | 169 void InputMethodManagerImpl::RemoveCandidateWindowObserver( |
| 89 InputMethodManager::CandidateWindowObserver* observer) { | 170 InputMethodManager::CandidateWindowObserver* observer) { |
| 90 candidate_window_observers_.RemoveObserver(observer); | 171 candidate_window_observers_.RemoveObserver(observer); |
| 91 } | 172 } |
| 92 | 173 |
| 93 void InputMethodManagerImpl::SetState(State new_state) { | 174 void InputMethodManagerImpl::SetUIState(UIState new_ui_state) { |
| 94 const State old_state = state_; | 175 const UIState old_ui_state = ui_state_; |
| 95 state_ = new_state; | 176 ui_state_ = new_ui_state; |
| 96 switch (state_) { | 177 switch (ui_state_) { |
| 97 case STATE_LOGIN_SCREEN: | 178 case STATE_LOGIN_SCREEN: |
| 98 break; | 179 break; |
| 99 case STATE_BROWSER_SCREEN: | 180 case STATE_BROWSER_SCREEN: |
| 100 if (old_state == STATE_LOCK_SCREEN) | 181 if (old_ui_state == STATE_LOCK_SCREEN) |
| 101 OnScreenUnlocked(); | 182 OnScreenUnlocked(); |
| 102 break; | 183 break; |
| 103 case STATE_LOCK_SCREEN: | 184 case STATE_LOCK_SCREEN: |
| 104 OnScreenLocked(); | 185 OnScreenLocked(); |
| 105 break; | 186 break; |
| 106 case STATE_TERMINATING: { | 187 case STATE_TERMINATING: { |
| 107 if (candidate_window_controller_.get()) | 188 if (candidate_window_controller_.get()) |
| 108 candidate_window_controller_.reset(); | 189 candidate_window_controller_.reset(); |
| 109 break; | 190 break; |
| 110 } | 191 } |
| 111 } | 192 } |
| 112 } | 193 } |
| 113 | 194 |
| 114 scoped_ptr<InputMethodDescriptors> | 195 scoped_ptr<InputMethodDescriptors> |
| 115 InputMethodManagerImpl::GetSupportedInputMethods() const { | 196 InputMethodManagerImpl::GetSupportedInputMethods() const { |
| 116 if (!IsXkbComponentExtensionAvailable()) | 197 if (!IsXkbComponentExtensionAvailable()) |
| 117 return whitelist_.GetSupportedInputMethods().Pass(); | 198 return whitelist_.GetSupportedInputMethods().Pass(); |
| 118 return scoped_ptr<InputMethodDescriptors>(new InputMethodDescriptors).Pass(); | 199 return scoped_ptr<InputMethodDescriptors>(new InputMethodDescriptors).Pass(); |
| 119 } | 200 } |
| 120 | 201 |
| 121 scoped_ptr<InputMethodDescriptors> | 202 scoped_ptr<InputMethodDescriptors> |
| 122 InputMethodManagerImpl::GetActiveInputMethods() const { | 203 InputMethodManagerImpl::GetActiveInputMethods() const { |
| 123 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors); | 204 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors); |
| 124 // Build the active input method descriptors from the active input | 205 // Build the active input method descriptors from the active input |
| 125 // methods cache |active_input_method_ids_|. | 206 // methods cache |active_input_method_ids_|. |
| 126 for (size_t i = 0; i < active_input_method_ids_.size(); ++i) { | 207 DCHECK(state_); |
| 127 const std::string& input_method_id = active_input_method_ids_[i]; | 208 for (size_t i = 0; i < state_->active_input_method_ids_.size(); ++i) { |
| 209 const std::string& input_method_id = state_->active_input_method_ids_[i]; | |
| 128 const InputMethodDescriptor* descriptor = | 210 const InputMethodDescriptor* descriptor = |
| 129 util_.GetInputMethodDescriptorFromId(input_method_id); | 211 util_.GetInputMethodDescriptorFromId(input_method_id); |
| 130 if (descriptor) { | 212 if (descriptor) { |
| 131 result->push_back(*descriptor); | 213 result->push_back(*descriptor); |
| 132 } else { | 214 } else { |
| 133 std::map<std::string, InputMethodDescriptor>::const_iterator ix = | 215 std::map<std::string, InputMethodDescriptor>::const_iterator ix = |
| 134 extra_input_methods_.find(input_method_id); | 216 extra_input_methods_.find(input_method_id); |
| 135 if (ix != extra_input_methods_.end()) | 217 if (ix != extra_input_methods_.end()) |
| 136 result->push_back(ix->second); | 218 result->push_back(ix->second); |
| 137 else | 219 else |
| 138 DVLOG(1) << "Descriptor is not found for: " << input_method_id; | 220 DVLOG(1) << "Descriptor is not found for: " << input_method_id; |
| 139 } | 221 } |
| 140 } | 222 } |
| 141 if (result->empty()) { | 223 if (result->empty()) { |
| 142 // Initially |active_input_method_ids_| is empty. browser_tests might take | 224 // Initially |active_input_method_ids_| is empty. browser_tests might take |
| 143 // this path. | 225 // this path. |
| 144 result->push_back( | 226 result->push_back( |
| 145 InputMethodUtil::GetFallbackInputMethodDescriptor()); | 227 InputMethodUtil::GetFallbackInputMethodDescriptor()); |
| 146 } | 228 } |
| 147 return result.Pass(); | 229 return result.Pass(); |
| 148 } | 230 } |
| 149 | 231 |
| 150 const std::vector<std::string>& | 232 const std::vector<std::string>& |
| 151 InputMethodManagerImpl::GetActiveInputMethodIds() const { | 233 InputMethodManagerImpl::GetActiveInputMethodIds() const { |
| 152 return active_input_method_ids_; | 234 DCHECK(state_); |
| 235 return state_->active_input_method_ids_; | |
| 153 } | 236 } |
| 154 | 237 |
| 155 size_t InputMethodManagerImpl::GetNumActiveInputMethods() const { | 238 size_t InputMethodManagerImpl::GetNumActiveInputMethods() const { |
| 156 return active_input_method_ids_.size(); | 239 DCHECK(state_); |
| 240 return state_->active_input_method_ids_.size(); | |
| 157 } | 241 } |
| 158 | 242 |
| 159 const InputMethodDescriptor* InputMethodManagerImpl::GetInputMethodFromId( | 243 const InputMethodDescriptor* InputMethodManagerImpl::GetInputMethodFromId( |
| 160 const std::string& input_method_id) const { | 244 const std::string& input_method_id) const { |
| 161 const InputMethodDescriptor* ime = util_.GetInputMethodDescriptorFromId( | 245 const InputMethodDescriptor* ime = util_.GetInputMethodDescriptorFromId( |
| 162 input_method_id); | 246 input_method_id); |
| 163 if (!ime) { | 247 if (!ime) { |
| 164 std::map<std::string, InputMethodDescriptor>::const_iterator ix = | 248 std::map<std::string, InputMethodDescriptor>::const_iterator ix = |
| 165 extra_input_methods_.find(input_method_id); | 249 extra_input_methods_.find(input_method_id); |
| 166 if (ix != extra_input_methods_.end()) | 250 if (ix != extra_input_methods_.end()) |
| 167 ime = &ix->second; | 251 ime = &ix->second; |
| 168 } | 252 } |
| 169 return ime; | 253 return ime; |
| 170 } | 254 } |
| 171 | 255 |
| 172 void InputMethodManagerImpl::EnableLoginLayouts( | 256 void InputMethodManagerImpl::EnableLoginLayouts( |
| 173 const std::string& language_code, | 257 const std::string& language_code, |
| 174 const std::vector<std::string>& initial_layouts) { | 258 const std::vector<std::string>& initial_layouts) { |
| 175 if (state_ == STATE_TERMINATING) | 259 if (ui_state_ == STATE_TERMINATING) |
| 176 return; | 260 return; |
| 261 LOG(ERROR) << "InputMethodManagerImpl::EnableLoginLayouts(): old state_: " | |
| 262 << state_->Dump(); | |
| 177 | 263 |
| 178 // First, hardware keyboard layout should be shown. | 264 // First, hardware keyboard layout should be shown. |
| 179 std::vector<std::string> candidates = | 265 std::vector<std::string> candidates = |
| 180 util_.GetHardwareLoginInputMethodIds(); | 266 util_.GetHardwareLoginInputMethodIds(); |
| 181 | 267 |
| 182 // Seocnd, locale based input method should be shown. | 268 // Seocnd, locale based input method should be shown. |
| 183 // Add input methods associated with the language. | 269 // Add input methods associated with the language. |
| 184 std::vector<std::string> layouts_from_locale; | 270 std::vector<std::string> layouts_from_locale; |
| 185 util_.GetInputMethodIdsFromLanguageCode(language_code, | 271 util_.GetInputMethodIdsFromLanguageCode(language_code, |
| 186 kKeyboardLayoutsOnly, | 272 kKeyboardLayoutsOnly, |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 210 // Add candidates to layouts, while skipping duplicates. | 296 // Add candidates to layouts, while skipping duplicates. |
| 211 for (size_t i = 0; i < candidates.size(); ++i) { | 297 for (size_t i = 0; i < candidates.size(); ++i) { |
| 212 const std::string& candidate = candidates[i]; | 298 const std::string& candidate = candidates[i]; |
| 213 // Not efficient, but should be fine, as the two vectors are very | 299 // Not efficient, but should be fine, as the two vectors are very |
| 214 // short (2-5 items). | 300 // short (2-5 items). |
| 215 if (!Contains(layouts, candidate) && IsLoginKeyboard(candidate)) | 301 if (!Contains(layouts, candidate) && IsLoginKeyboard(candidate)) |
| 216 layouts.push_back(candidate); | 302 layouts.push_back(candidate); |
| 217 } | 303 } |
| 218 | 304 |
| 219 MigrateInputMethods(&layouts); | 305 MigrateInputMethods(&layouts); |
| 220 active_input_method_ids_.swap(layouts); | 306 DCHECK(state_); |
| 307 state_->active_input_method_ids_.swap(layouts); | |
| 308 LOG(ERROR) << "InputMethodManagerImpl::EnableLoginLayouts(): new state_: " | |
| 309 << state_->Dump(); | |
| 221 | 310 |
| 222 // Initialize candidate window controller and widgets such as | 311 // Initialize candidate window controller and widgets such as |
| 223 // candidate window, infolist and mode indicator. Note, mode | 312 // candidate window, infolist and mode indicator. Note, mode |
| 224 // indicator is used by only keyboard layout input methods. | 313 // indicator is used by only keyboard layout input methods. |
| 225 if (active_input_method_ids_.size() > 1) | 314 if (state_->active_input_method_ids_.size() > 1) |
| 226 MaybeInitializeCandidateWindowController(); | 315 MaybeInitializeCandidateWindowController(); |
| 227 | 316 |
| 228 // you can pass empty |initial_layout|. | 317 // you can pass empty |initial_layout|. |
| 229 ChangeInputMethod(initial_layouts.empty() ? "" : | 318 ChangeInputMethod(initial_layouts.empty() ? "" : |
| 230 extension_ime_util::GetInputMethodIDByEngineID(initial_layouts[0])); | 319 extension_ime_util::GetInputMethodIDByEngineID(initial_layouts[0])); |
| 231 } | 320 } |
| 232 | 321 |
| 233 // Adds new input method to given list. | 322 // Adds new input method to given list. |
| 234 bool InputMethodManagerImpl::EnableInputMethodImpl( | 323 bool InputMethodManagerImpl::EnableInputMethodImpl( |
| 235 const std::string& input_method_id, | 324 const std::string& input_method_id, |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 251 LoadNecessaryComponentExtensions(); | 340 LoadNecessaryComponentExtensions(); |
| 252 | 341 |
| 253 // Initialize candidate window controller and widgets such as | 342 // Initialize candidate window controller and widgets such as |
| 254 // candidate window, infolist and mode indicator. Note, mode | 343 // candidate window, infolist and mode indicator. Note, mode |
| 255 // indicator is used by only keyboard layout input methods. | 344 // indicator is used by only keyboard layout input methods. |
| 256 MaybeInitializeCandidateWindowController(); | 345 MaybeInitializeCandidateWindowController(); |
| 257 } | 346 } |
| 258 | 347 |
| 259 bool InputMethodManagerImpl::EnableInputMethod( | 348 bool InputMethodManagerImpl::EnableInputMethod( |
| 260 const std::string& input_method_id) { | 349 const std::string& input_method_id) { |
| 261 if (!EnableInputMethodImpl(input_method_id, &active_input_method_ids_)) | 350 DCHECK(state_); |
| 351 if (!EnableInputMethodImpl(input_method_id, | |
| 352 &(state_->active_input_method_ids_))) | |
| 262 return false; | 353 return false; |
| 263 | 354 |
| 264 ReconfigureIMFramework(); | 355 ReconfigureIMFramework(); |
| 265 return true; | 356 return true; |
| 266 } | 357 } |
| 267 | 358 |
| 268 bool InputMethodManagerImpl::ReplaceEnabledInputMethods( | 359 bool InputMethodManagerImpl::ReplaceEnabledInputMethods( |
| 269 const std::vector<std::string>& new_active_input_method_ids) { | 360 const std::vector<std::string>& new_active_input_method_ids) { |
| 270 if (state_ == STATE_TERMINATING) | 361 if (ui_state_ == STATE_TERMINATING) |
| 271 return false; | 362 return false; |
| 363 LOG(ERROR) | |
| 364 << "InputMethodManagerImpl::ReplaceEnabledInputMethods(): old state_: " | |
| 365 << state_->Dump(); | |
| 272 | 366 |
| 273 // Filter unknown or obsolete IDs. | 367 // Filter unknown or obsolete IDs. |
| 274 std::vector<std::string> new_active_input_method_ids_filtered; | 368 std::vector<std::string> new_active_input_method_ids_filtered; |
| 275 | 369 |
| 276 for (size_t i = 0; i < new_active_input_method_ids.size(); ++i) | 370 for (size_t i = 0; i < new_active_input_method_ids.size(); ++i) |
| 277 EnableInputMethodImpl(new_active_input_method_ids[i], | 371 EnableInputMethodImpl(new_active_input_method_ids[i], |
| 278 &new_active_input_method_ids_filtered); | 372 &new_active_input_method_ids_filtered); |
| 279 | 373 |
| 280 if (new_active_input_method_ids_filtered.empty()) { | 374 if (new_active_input_method_ids_filtered.empty()) { |
| 281 DVLOG(1) << "ReplaceEnabledInputMethods: No valid input method ID"; | 375 DVLOG(1) << "ReplaceEnabledInputMethods: No valid input method ID"; |
| 282 return false; | 376 return false; |
| 283 } | 377 } |
| 284 | 378 |
| 285 // Copy extension IDs to |new_active_input_method_ids_filtered|. We have to | 379 // Copy extension IDs to |new_active_input_method_ids_filtered|. We have to |
| 286 // keep relative order of the extension input method IDs. | 380 // keep relative order of the extension input method IDs. |
| 287 for (size_t i = 0; i < active_input_method_ids_.size(); ++i) { | 381 DCHECK(state_); |
| 288 const std::string& input_method_id = active_input_method_ids_[i]; | 382 for (size_t i = 0; i < state_->active_input_method_ids_.size(); ++i) { |
| 383 const std::string& input_method_id = state_->active_input_method_ids_[i]; | |
| 289 if (extension_ime_util::IsExtensionIME(input_method_id)) | 384 if (extension_ime_util::IsExtensionIME(input_method_id)) |
| 290 new_active_input_method_ids_filtered.push_back(input_method_id); | 385 new_active_input_method_ids_filtered.push_back(input_method_id); |
| 291 } | 386 } |
| 292 active_input_method_ids_.swap(new_active_input_method_ids_filtered); | 387 state_->active_input_method_ids_.swap(new_active_input_method_ids_filtered); |
| 293 MigrateInputMethods(&active_input_method_ids_); | 388 MigrateInputMethods(&(state_->active_input_method_ids_)); |
| 294 | 389 |
| 390 LOG(ERROR) | |
| 391 << "InputMethodManagerImpl::ReplaceEnabledInputMethods(): new state_: " | |
| 392 << state_->Dump(); | |
| 295 ReconfigureIMFramework(); | 393 ReconfigureIMFramework(); |
| 296 | 394 |
| 297 // If |current_input_method| is no longer in |active_input_method_ids_|, | 395 // If |current_input_method| is no longer in |active_input_method_ids_|, |
| 298 // ChangeInputMethod() picks the first one in |active_input_method_ids_|. | 396 // ChangeInputMethod() picks the first one in |active_input_method_ids_|. |
| 299 ChangeInputMethod(current_input_method_.id()); | 397 ChangeInputMethod(state_->current_input_method_.id()); |
| 300 return true; | 398 return true; |
| 301 } | 399 } |
| 302 | 400 |
| 303 void InputMethodManagerImpl::ChangeInputMethod( | 401 void InputMethodManagerImpl::ChangeInputMethod( |
| 304 const std::string& input_method_id) { | 402 const std::string& input_method_id) { |
| 305 ChangeInputMethodInternal(input_method_id, false); | 403 LookupAndChangeInputMethodInternal(input_method_id, false); |
| 306 } | 404 } |
| 307 | 405 |
| 308 bool InputMethodManagerImpl::ChangeInputMethodInternal( | 406 void InputMethodManagerImpl::ChangeInputMethodInternal( |
| 407 const InputMethodDescriptor& descriptor, | |
| 408 bool show_message) { | |
| 409 // Change the keyboard layout to a preferred layout for the input method. | |
| 410 if (!keyboard_->SetCurrentKeyboardLayoutByName( | |
| 411 descriptor.GetPreferredKeyboardLayout())) { | |
| 412 LOG(ERROR) << "Failed to change keyboard layout to " | |
| 413 << descriptor.GetPreferredKeyboardLayout(); | |
| 414 } | |
| 415 | |
| 416 // Update input method indicators (e.g. "US", "DV") in Chrome windows. | |
| 417 FOR_EACH_OBSERVER(InputMethodManager::Observer, | |
| 418 observers_, | |
| 419 InputMethodChanged(this, show_message)); | |
| 420 } | |
| 421 | |
| 422 bool InputMethodManagerImpl::LookupAndChangeInputMethodInternal( | |
|
Shu Chen
2014/08/04 14:55:23
looks like the bool return value never gets used.
Alexander Alekseev
2014/08/06 23:39:45
Done.
| |
| 309 const std::string& input_method_id, | 423 const std::string& input_method_id, |
| 310 bool show_message) { | 424 bool show_message) { |
| 311 if (state_ == STATE_TERMINATING) | 425 if (ui_state_ == STATE_TERMINATING) |
| 312 return false; | 426 return false; |
| 313 | 427 |
| 314 std::string input_method_id_to_switch = input_method_id; | 428 std::string input_method_id_to_switch = input_method_id; |
| 315 | 429 |
| 316 // Sanity check. | 430 // Sanity check. |
| 317 if (!InputMethodIsActivated(input_method_id)) { | 431 if (!InputMethodIsActivated(input_method_id)) { |
| 318 scoped_ptr<InputMethodDescriptors> input_methods(GetActiveInputMethods()); | 432 scoped_ptr<InputMethodDescriptors> input_methods(GetActiveInputMethods()); |
| 319 DCHECK(!input_methods->empty()); | 433 DCHECK(!input_methods->empty()); |
| 320 input_method_id_to_switch = input_methods->at(0).id(); | 434 input_method_id_to_switch = input_methods->at(0).id(); |
| 321 if (!input_method_id.empty()) { | 435 if (!input_method_id.empty()) { |
| 322 DVLOG(1) << "Can't change the current input method to " | 436 DVLOG(1) << "Can't change the current input method to " |
| 323 << input_method_id << " since the engine is not enabled. " | 437 << input_method_id << " since the engine is not enabled. " |
| 324 << "Switch to " << input_method_id_to_switch << " instead."; | 438 << "Switch to " << input_method_id_to_switch << " instead."; |
| 325 } | 439 } |
| 326 } | 440 } |
| 327 | 441 |
| 328 if (!component_extension_ime_manager_->IsInitialized() && | 442 if (!component_extension_ime_manager_->IsInitialized() && |
| 329 !InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch)) { | 443 !InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch)) { |
| 330 // We can't change input method before the initialization of | 444 // We can't change input method before the initialization of |
| 331 // component extension ime manager. ChangeInputMethod will be | 445 // component extension ime manager. ChangeInputMethod will be |
| 332 // called with |pending_input_method_| when the initialization is | 446 // called with |pending_input_method_| when the initialization is |
| 333 // done. | 447 // done. |
| 334 pending_input_method_ = input_method_id_to_switch; | 448 state_->pending_input_method_ = input_method_id_to_switch; |
| 335 return false; | 449 return false; |
| 336 } | 450 } |
| 337 pending_input_method_.clear(); | 451 state_->pending_input_method_.clear(); |
| 338 | 452 |
| 339 // Hide candidate window and info list. | 453 // Hide candidate window and info list. |
| 340 if (candidate_window_controller_.get()) | 454 if (candidate_window_controller_.get()) |
| 341 candidate_window_controller_->Hide(); | 455 candidate_window_controller_->Hide(); |
| 342 | 456 |
| 343 // Disable the current engine handler. | 457 // Disable the current engine handler. |
| 344 IMEEngineHandlerInterface* engine = | 458 IMEEngineHandlerInterface* engine = |
| 345 IMEBridge::Get()->GetCurrentEngineHandler(); | 459 IMEBridge::Get()->GetCurrentEngineHandler(); |
| 346 if (engine) | 460 if (engine) |
| 347 engine->Disable(); | 461 engine->Disable(); |
| 348 | 462 |
| 349 // Configure the next engine handler. | 463 // Configure the next engine handler. |
| 350 if (InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch) && | 464 if (InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch) && |
| 351 !extension_ime_util::IsKeyboardLayoutExtension( | 465 !extension_ime_util::IsKeyboardLayoutExtension( |
| 352 input_method_id_to_switch)) { | 466 input_method_id_to_switch)) { |
| 353 IMEBridge::Get()->SetCurrentEngineHandler(NULL); | 467 IMEBridge::Get()->SetCurrentEngineHandler(NULL); |
| 354 } else { | 468 } else { |
| 355 IMEEngineHandlerInterface* next_engine = | 469 IMEEngineHandlerInterface* next_engine = |
| 356 profile_engine_map_[GetProfile()][input_method_id_to_switch]; | 470 state_->engine_map_[input_method_id_to_switch]; |
| 357 if (next_engine) { | 471 if (next_engine) { |
| 358 IMEBridge::Get()->SetCurrentEngineHandler(next_engine); | 472 IMEBridge::Get()->SetCurrentEngineHandler(next_engine); |
| 359 next_engine->Enable(); | 473 next_engine->Enable(); |
| 360 } | 474 } |
| 361 } | 475 } |
| 362 | 476 |
| 363 // TODO(komatsu): Check if it is necessary to perform the above routine | 477 // TODO(komatsu): Check if it is necessary to perform the above routine |
| 364 // when the current input method is equal to |input_method_id_to_swich|. | 478 // when the current input method is equal to |input_method_id_to_swich|. |
| 365 if (current_input_method_.id() != input_method_id_to_switch) { | 479 if (state_->current_input_method_.id() != input_method_id_to_switch) { |
| 366 // Clear property list. Property list would be updated by | 480 // Clear property list. Property list would be updated by |
| 367 // extension IMEs via InputMethodEngine::(Set|Update)MenuItems. | 481 // extension IMEs via InputMethodEngine::(Set|Update)MenuItems. |
| 368 // If the current input method is a keyboard layout, empty | 482 // If the current input method is a keyboard layout, empty |
| 369 // properties are sufficient. | 483 // properties are sufficient. |
| 370 const ash::ime::InputMethodMenuItemList empty_menu_item_list; | 484 const ash::ime::InputMethodMenuItemList empty_menu_item_list; |
| 371 ash::ime::InputMethodMenuManager* input_method_menu_manager = | 485 ash::ime::InputMethodMenuManager* input_method_menu_manager = |
| 372 ash::ime::InputMethodMenuManager::GetInstance(); | 486 ash::ime::InputMethodMenuManager::GetInstance(); |
| 373 input_method_menu_manager->SetCurrentInputMethodMenuItemList( | 487 input_method_menu_manager->SetCurrentInputMethodMenuItemList( |
| 374 empty_menu_item_list); | 488 empty_menu_item_list); |
| 375 | 489 |
| 376 const InputMethodDescriptor* descriptor = NULL; | 490 const InputMethodDescriptor* descriptor = NULL; |
| 377 if (extension_ime_util::IsExtensionIME(input_method_id_to_switch)) { | 491 if (extension_ime_util::IsExtensionIME(input_method_id_to_switch)) { |
| 378 DCHECK(extra_input_methods_.find(input_method_id_to_switch) != | 492 DCHECK(extra_input_methods_.find(input_method_id_to_switch) != |
| 379 extra_input_methods_.end()); | 493 extra_input_methods_.end()); |
| 380 descriptor = &(extra_input_methods_[input_method_id_to_switch]); | 494 descriptor = &(extra_input_methods_[input_method_id_to_switch]); |
| 381 } else { | 495 } else { |
| 382 descriptor = | 496 descriptor = |
| 383 util_.GetInputMethodDescriptorFromId(input_method_id_to_switch); | 497 util_.GetInputMethodDescriptorFromId(input_method_id_to_switch); |
| 384 if (!descriptor) | 498 if (!descriptor) |
| 385 LOG(ERROR) << "Unknown input method id: " << input_method_id_to_switch; | 499 LOG(ERROR) << "Unknown input method id: " << input_method_id_to_switch; |
| 386 } | 500 } |
| 387 DCHECK(descriptor); | 501 DCHECK(descriptor); |
| 388 | 502 |
| 389 previous_input_method_ = current_input_method_; | 503 state_->previous_input_method_ = state_->current_input_method_; |
| 390 current_input_method_ = *descriptor; | 504 state_->current_input_method_ = *descriptor; |
| 391 } | 505 } |
| 392 | 506 |
| 393 // Change the keyboard layout to a preferred layout for the input method. | 507 ChangeInputMethodInternal(state_->current_input_method_, show_message); |
| 394 if (!keyboard_->SetCurrentKeyboardLayoutByName( | |
| 395 current_input_method_.GetPreferredKeyboardLayout())) { | |
| 396 LOG(ERROR) << "Failed to change keyboard layout to " | |
| 397 << current_input_method_.GetPreferredKeyboardLayout(); | |
| 398 } | |
| 399 | |
| 400 // Update input method indicators (e.g. "US", "DV") in Chrome windows. | |
| 401 FOR_EACH_OBSERVER(InputMethodManager::Observer, | |
| 402 observers_, | |
| 403 InputMethodChanged(this, show_message)); | |
| 404 return true; | 508 return true; |
| 405 } | 509 } |
| 406 | 510 |
| 407 bool InputMethodManagerImpl::IsXkbComponentExtensionAvailable() const { | 511 bool InputMethodManagerImpl::IsXkbComponentExtensionAvailable() const { |
| 408 if (!component_extension_ime_manager_->IsInitialized()) | 512 if (!component_extension_ime_manager_->IsInitialized()) |
| 409 return false; | 513 return false; |
| 410 InputMethodDescriptors imes = | 514 InputMethodDescriptors imes = |
| 411 component_extension_ime_manager_->GetAllIMEAsInputMethodDescriptor(); | 515 component_extension_ime_manager_->GetAllIMEAsInputMethodDescriptor(); |
| 412 for (size_t i = 0; i < imes.size(); ++i) { | 516 for (size_t i = 0; i < imes.size(); ++i) { |
| 413 if (StartsWithASCII(extension_ime_util::MaybeGetLegacyXkbId( | 517 if (StartsWithASCII(extension_ime_util::MaybeGetLegacyXkbId( |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 425 component_extension_ime_manager_->GetAllIMEAsInputMethodDescriptor(); | 529 component_extension_ime_manager_->GetAllIMEAsInputMethodDescriptor(); |
| 426 // In case of XKB extension is not available (e.g. linux_chromeos), don't | 530 // In case of XKB extension is not available (e.g. linux_chromeos), don't |
| 427 // reset the input methods in InputMethodUtil, Instead append input methods. | 531 // reset the input methods in InputMethodUtil, Instead append input methods. |
| 428 if (IsXkbComponentExtensionAvailable()) | 532 if (IsXkbComponentExtensionAvailable()) |
| 429 util_.ResetInputMethods(imes); | 533 util_.ResetInputMethods(imes); |
| 430 else | 534 else |
| 431 util_.AppendInputMethods(imes); | 535 util_.AppendInputMethods(imes); |
| 432 | 536 |
| 433 LoadNecessaryComponentExtensions(); | 537 LoadNecessaryComponentExtensions(); |
| 434 | 538 |
| 435 if (!pending_input_method_.empty()) | 539 DCHECK(state_); |
| 436 ChangeInputMethodInternal(pending_input_method_, false); | 540 if (!state_->pending_input_method_.empty()) |
| 541 LookupAndChangeInputMethodInternal(state_->pending_input_method_, false); | |
| 437 } | 542 } |
| 438 | 543 |
| 439 void InputMethodManagerImpl::LoadNecessaryComponentExtensions() { | 544 void InputMethodManagerImpl::LoadNecessaryComponentExtensions() { |
| 440 if (!component_extension_ime_manager_->IsInitialized()) | 545 if (!component_extension_ime_manager_->IsInitialized()) |
| 441 return; | 546 return; |
| 547 LOG(ERROR) << "InputMethodManagerImpl::LoadNecessaryComponentExtensions(): " | |
| 548 "old state_: " << state_->Dump(); | |
| 442 // Load component extensions but also update |active_input_method_ids_| as | 549 // Load component extensions but also update |active_input_method_ids_| as |
| 443 // some component extension IMEs may have been removed from the Chrome OS | 550 // some component extension IMEs may have been removed from the Chrome OS |
| 444 // image. If specified component extension IME no longer exists, falling back | 551 // image. If specified component extension IME no longer exists, falling back |
| 445 // to an existing IME. | 552 // to an existing IME. |
| 553 DCHECK(state_); | |
| 446 std::vector<std::string> unfiltered_input_method_ids; | 554 std::vector<std::string> unfiltered_input_method_ids; |
| 447 unfiltered_input_method_ids.swap(active_input_method_ids_); | 555 unfiltered_input_method_ids.swap(state_->active_input_method_ids_); |
| 448 for (size_t i = 0; i < unfiltered_input_method_ids.size(); ++i) { | 556 for (size_t i = 0; i < unfiltered_input_method_ids.size(); ++i) { |
| 449 if (!extension_ime_util::IsComponentExtensionIME( | 557 if (!extension_ime_util::IsComponentExtensionIME( |
| 450 unfiltered_input_method_ids[i])) { | 558 unfiltered_input_method_ids[i])) { |
| 451 // Legacy IMEs or xkb layouts are alwayes active. | 559 // Legacy IMEs or xkb layouts are alwayes active. |
| 452 active_input_method_ids_.push_back(unfiltered_input_method_ids[i]); | 560 state_->active_input_method_ids_.push_back( |
| 561 unfiltered_input_method_ids[i]); | |
| 453 } else if (component_extension_ime_manager_->IsWhitelisted( | 562 } else if (component_extension_ime_manager_->IsWhitelisted( |
| 454 unfiltered_input_method_ids[i])) { | 563 unfiltered_input_method_ids[i])) { |
| 455 component_extension_ime_manager_->LoadComponentExtensionIME( | 564 component_extension_ime_manager_->LoadComponentExtensionIME( |
| 456 unfiltered_input_method_ids[i]); | 565 unfiltered_input_method_ids[i]); |
| 457 active_input_method_ids_.push_back(unfiltered_input_method_ids[i]); | 566 state_->active_input_method_ids_.push_back( |
| 567 unfiltered_input_method_ids[i]); | |
| 458 } | 568 } |
| 459 } | 569 } |
| 570 LOG(ERROR) << "InputMethodManagerImpl::LoadNecessaryComponentExtensions(): " | |
| 571 "new state_: " << state_->Dump(); | |
| 460 // TODO(shuchen): move this call in ComponentExtensionIMEManager. | 572 // TODO(shuchen): move this call in ComponentExtensionIMEManager. |
| 461 component_extension_ime_manager_->NotifyInitialized(); | 573 component_extension_ime_manager_->NotifyInitialized(); |
| 462 } | 574 } |
| 463 | 575 |
| 464 void InputMethodManagerImpl::ActivateInputMethodMenuItem( | 576 void InputMethodManagerImpl::ActivateInputMethodMenuItem( |
| 465 const std::string& key) { | 577 const std::string& key) { |
| 466 DCHECK(!key.empty()); | 578 DCHECK(!key.empty()); |
| 467 | 579 |
| 468 if (ash::ime::InputMethodMenuManager::GetInstance()-> | 580 if (ash::ime::InputMethodMenuManager::GetInstance()-> |
| 469 HasInputMethodMenuItemForKey(key)) { | 581 HasInputMethodMenuItemForKey(key)) { |
| 470 IMEEngineHandlerInterface* engine = | 582 IMEEngineHandlerInterface* engine = |
| 471 IMEBridge::Get()->GetCurrentEngineHandler(); | 583 IMEBridge::Get()->GetCurrentEngineHandler(); |
| 472 if (engine) | 584 if (engine) |
| 473 engine->PropertyActivate(key); | 585 engine->PropertyActivate(key); |
| 474 return; | 586 return; |
| 475 } | 587 } |
| 476 | 588 |
| 477 DVLOG(1) << "ActivateInputMethodMenuItem: unknown key: " << key; | 589 DVLOG(1) << "ActivateInputMethodMenuItem: unknown key: " << key; |
| 478 } | 590 } |
| 479 | 591 |
| 480 void InputMethodManagerImpl::AddInputMethodExtension( | 592 void InputMethodManagerImpl::AddInputMethodExtension( |
| 481 const std::string& id, | 593 const std::string& id, |
| 482 InputMethodEngineInterface* engine) { | 594 InputMethodEngineInterface* engine) { |
| 483 if (state_ == STATE_TERMINATING) | 595 if (ui_state_ == STATE_TERMINATING) |
| 484 return; | 596 return; |
| 597 LOG(ERROR) | |
| 598 << "InputMethodManagerImpl::AddInputMethodExtension(): old state_: " | |
| 599 << state_->Dump(); | |
| 485 | 600 |
| 486 DCHECK(engine); | 601 DCHECK(engine); |
| 602 DCHECK(state_); | |
| 487 | 603 |
| 488 profile_engine_map_[GetProfile()][id] = engine; | 604 state_->engine_map_[id] = engine; |
|
Shu Chen
2014/08/04 14:55:23
I think this will break something. GetProfile() is
Alexander Alekseev
2014/08/06 23:39:45
state_ is per-user, so this would never happen.
I
| |
| 489 | 605 |
| 490 if (id == current_input_method_.id()) { | 606 if (id == state_->current_input_method_.id()) { |
| 491 IMEBridge::Get()->SetCurrentEngineHandler(engine); | 607 IMEBridge::Get()->SetCurrentEngineHandler(engine); |
| 492 engine->Enable(); | 608 engine->Enable(); |
| 493 } | 609 } |
| 494 | 610 |
| 495 if (extension_ime_util::IsComponentExtensionIME(id)) | 611 if (extension_ime_util::IsComponentExtensionIME(id)) |
| 496 return; | 612 return; |
| 497 | 613 |
| 498 CHECK(extension_ime_util::IsExtensionIME(id)) | 614 CHECK(extension_ime_util::IsExtensionIME(id)) |
| 499 << id << "is not a valid extension input method ID"; | 615 << id << "is not a valid extension input method ID"; |
| 500 | 616 |
| 501 const InputMethodDescriptor& descriptor = engine->GetDescriptor(); | 617 const InputMethodDescriptor& descriptor = engine->GetDescriptor(); |
| 502 extra_input_methods_[id] = descriptor; | 618 extra_input_methods_[id] = descriptor; |
| 503 | 619 |
| 504 if (Contains(enabled_extension_imes_, id)) { | 620 if (Contains(enabled_extension_imes_, id)) { |
| 505 if (!Contains(active_input_method_ids_, id)) { | 621 if (!Contains(state_->active_input_method_ids_, id)) { |
| 506 active_input_method_ids_.push_back(id); | 622 state_->active_input_method_ids_.push_back(id); |
| 623 LOG(ERROR) | |
| 624 << "InputMethodManagerImpl::AddInputMethodExtension(): new state_: " | |
| 625 << state_->Dump(); | |
| 507 } else { | 626 } else { |
| 508 DVLOG(1) << "AddInputMethodExtension: alread added: " | 627 DVLOG(1) << "AddInputMethodExtension: alread added: " |
| 509 << id << ", " << descriptor.name(); | 628 << id << ", " << descriptor.name(); |
| 510 } | 629 } |
| 511 | 630 |
| 512 // Ensure that the input method daemon is running. | 631 // Ensure that the input method daemon is running. |
| 513 MaybeInitializeCandidateWindowController(); | 632 MaybeInitializeCandidateWindowController(); |
| 514 } | 633 } |
| 515 } | 634 } |
| 516 | 635 |
| 517 void InputMethodManagerImpl::RemoveInputMethodExtension(const std::string& id) { | 636 void InputMethodManagerImpl::RemoveInputMethodExtension(const std::string& id) { |
| 518 if (!extension_ime_util::IsExtensionIME(id)) | 637 if (!extension_ime_util::IsExtensionIME(id)) |
| 519 DVLOG(1) << id << " is not a valid extension input method ID."; | 638 DVLOG(1) << id << " is not a valid extension input method ID."; |
| 639 LOG(ERROR) << "InputMethodManagerImpl::RemoveInputMethodExtension('" << id | |
| 640 << "'): old state_: " << state_->Dump(); | |
| 520 | 641 |
| 521 std::vector<std::string>::iterator i = std::find( | 642 DCHECK(state_); |
| 522 active_input_method_ids_.begin(), active_input_method_ids_.end(), id); | 643 std::vector<std::string>::iterator i = |
| 523 if (i != active_input_method_ids_.end()) | 644 std::find(state_->active_input_method_ids_.begin(), |
| 524 active_input_method_ids_.erase(i); | 645 state_->active_input_method_ids_.end(), |
| 646 id); | |
| 647 if (i != state_->active_input_method_ids_.end()) | |
| 648 state_->active_input_method_ids_.erase(i); | |
| 525 extra_input_methods_.erase(id); | 649 extra_input_methods_.erase(id); |
| 526 | 650 |
| 527 EngineMap& engine_map = profile_engine_map_[GetProfile()]; | 651 if (IMEBridge::Get()->GetCurrentEngineHandler() == state_->engine_map_[id]) |
| 528 if (IMEBridge::Get()->GetCurrentEngineHandler() == engine_map[id]) | |
| 529 IMEBridge::Get()->SetCurrentEngineHandler(NULL); | 652 IMEBridge::Get()->SetCurrentEngineHandler(NULL); |
| 530 engine_map.erase(id); | 653 state_->engine_map_.erase(id); |
| 654 LOG(ERROR) << "InputMethodManagerImpl::RemoveInputMethodExtension('" << id | |
| 655 << "'): new state_: " << state_->Dump(); | |
| 531 | 656 |
| 532 // No need to switch input method when terminating. | 657 // No need to switch input method when terminating. |
| 533 if (state_ != STATE_TERMINATING) { | 658 if (ui_state_ != STATE_TERMINATING) { |
| 534 // If |current_input_method| is no longer in |active_input_method_ids_|, | 659 // If |current_input_method| is no longer in |active_input_method_ids_|, |
| 535 // switch to the first one in |active_input_method_ids_|. | 660 // switch to the first one in |active_input_method_ids_|. |
| 536 ChangeInputMethod(current_input_method_.id()); | 661 ChangeInputMethod(state_->current_input_method_.id()); |
| 537 } | 662 } |
| 538 } | 663 } |
| 539 | 664 |
| 540 void InputMethodManagerImpl::GetInputMethodExtensions( | 665 void InputMethodManagerImpl::GetInputMethodExtensions( |
| 541 InputMethodDescriptors* result) { | 666 InputMethodDescriptors* result) { |
| 542 // Build the extension input method descriptors from the extra input | 667 // Build the extension input method descriptors from the extra input |
| 543 // methods cache |extra_input_methods_|. | 668 // methods cache |extra_input_methods_|. |
| 544 std::map<std::string, InputMethodDescriptor>::iterator iter; | 669 std::map<std::string, InputMethodDescriptor>::iterator iter; |
| 545 for (iter = extra_input_methods_.begin(); iter != extra_input_methods_.end(); | 670 for (iter = extra_input_methods_.begin(); iter != extra_input_methods_.end(); |
| 546 ++iter) { | 671 ++iter) { |
| 547 if (extension_ime_util::IsExtensionIME(iter->first)) | 672 if (extension_ime_util::IsExtensionIME(iter->first)) |
| 548 result->push_back(iter->second); | 673 result->push_back(iter->second); |
| 549 } | 674 } |
| 550 } | 675 } |
| 551 | 676 |
| 552 void InputMethodManagerImpl::SetEnabledExtensionImes( | 677 void InputMethodManagerImpl::SetEnabledExtensionImes( |
| 553 std::vector<std::string>* ids) { | 678 std::vector<std::string>* ids) { |
| 554 enabled_extension_imes_.clear(); | 679 enabled_extension_imes_.clear(); |
| 555 enabled_extension_imes_.insert(enabled_extension_imes_.end(), | 680 enabled_extension_imes_.insert(enabled_extension_imes_.end(), |
| 556 ids->begin(), | 681 ids->begin(), |
| 557 ids->end()); | 682 ids->end()); |
| 683 LOG(ERROR) | |
| 684 << "InputMethodManagerImpl::SetEnabledExtensionImes(): old state_: " | |
| 685 << state_->Dump(); | |
| 558 | 686 |
| 559 bool active_imes_changed = false; | 687 bool active_imes_changed = false; |
| 560 | 688 |
| 561 for (std::map<std::string, InputMethodDescriptor>::iterator extra_iter = | 689 for (std::map<std::string, InputMethodDescriptor>::iterator extra_iter = |
| 562 extra_input_methods_.begin(); extra_iter != extra_input_methods_.end(); | 690 extra_input_methods_.begin(); extra_iter != extra_input_methods_.end(); |
| 563 ++extra_iter) { | 691 ++extra_iter) { |
| 564 if (extension_ime_util::IsComponentExtensionIME( | 692 if (extension_ime_util::IsComponentExtensionIME( |
| 565 extra_iter->first)) | 693 extra_iter->first)) |
| 566 continue; // Do not filter component extension. | 694 continue; // Do not filter component extension. |
| 567 std::vector<std::string>::iterator active_iter = std::find( | 695 DCHECK(state_); |
| 568 active_input_method_ids_.begin(), active_input_method_ids_.end(), | 696 std::vector<std::string>::iterator active_iter = |
| 569 extra_iter->first); | 697 std::find(state_->active_input_method_ids_.begin(), |
| 698 state_->active_input_method_ids_.end(), | |
| 699 extra_iter->first); | |
| 570 | 700 |
| 571 bool active = active_iter != active_input_method_ids_.end(); | 701 bool active = active_iter != state_->active_input_method_ids_.end(); |
| 572 bool enabled = Contains(enabled_extension_imes_, extra_iter->first); | 702 bool enabled = Contains(enabled_extension_imes_, extra_iter->first); |
| 573 | 703 |
| 574 if (active && !enabled) | 704 if (active && !enabled) |
| 575 active_input_method_ids_.erase(active_iter); | 705 state_->active_input_method_ids_.erase(active_iter); |
| 576 | 706 |
| 577 if (!active && enabled) | 707 if (!active && enabled) |
| 578 active_input_method_ids_.push_back(extra_iter->first); | 708 state_->active_input_method_ids_.push_back(extra_iter->first); |
| 579 | 709 |
| 580 if (active == !enabled) | 710 if (active == !enabled) |
| 581 active_imes_changed = true; | 711 active_imes_changed = true; |
| 582 } | 712 } |
| 713 LOG(ERROR) | |
| 714 << "InputMethodManagerImpl::SetEnabledExtensionImes(): new state_: " | |
| 715 << state_->Dump(); | |
| 583 | 716 |
| 584 if (active_imes_changed) { | 717 if (active_imes_changed) { |
| 585 MaybeInitializeCandidateWindowController(); | 718 MaybeInitializeCandidateWindowController(); |
| 586 | 719 |
| 587 // If |current_input_method| is no longer in |active_input_method_ids_|, | 720 // If |current_input_method| is no longer in |active_input_method_ids_|, |
| 588 // switch to the first one in |active_input_method_ids_|. | 721 // switch to the first one in |active_input_method_ids_|. |
| 589 ChangeInputMethod(current_input_method_.id()); | 722 ChangeInputMethod(state_->current_input_method_.id()); |
| 590 } | 723 } |
| 591 } | 724 } |
| 592 | 725 |
| 593 void InputMethodManagerImpl::SetInputMethodLoginDefaultFromVPD( | 726 void InputMethodManagerImpl::SetInputMethodLoginDefaultFromVPD( |
| 594 const std::string& locale, const std::string& oem_layout) { | 727 const std::string& locale, const std::string& oem_layout) { |
| 595 std::string layout; | 728 std::string layout; |
| 596 if (!oem_layout.empty()) { | 729 if (!oem_layout.empty()) { |
| 597 // If the OEM layout information is provided, use it. | 730 // If the OEM layout information is provided, use it. |
| 598 layout = oem_layout; | 731 layout = oem_layout; |
| 599 } else { | 732 } else { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 646 // If kPreferredKeyboardLayout is not specified, use the hardware layout. | 779 // If kPreferredKeyboardLayout is not specified, use the hardware layout. |
| 647 input_methods_to_be_enabled = util_.GetHardwareLoginInputMethodIds(); | 780 input_methods_to_be_enabled = util_.GetHardwareLoginInputMethodIds(); |
| 648 } else { | 781 } else { |
| 649 input_methods_to_be_enabled.push_back(initial_input_method_id); | 782 input_methods_to_be_enabled.push_back(initial_input_method_id); |
| 650 } | 783 } |
| 651 EnableLoginLayouts(locale, input_methods_to_be_enabled); | 784 EnableLoginLayouts(locale, input_methods_to_be_enabled); |
| 652 } | 785 } |
| 653 } | 786 } |
| 654 | 787 |
| 655 bool InputMethodManagerImpl::SwitchToNextInputMethod() { | 788 bool InputMethodManagerImpl::SwitchToNextInputMethod() { |
| 789 DCHECK(state_); | |
| 656 // Sanity checks. | 790 // Sanity checks. |
| 657 if (active_input_method_ids_.empty()) { | 791 if (state_->active_input_method_ids_.empty()) { |
| 658 DVLOG(1) << "active input method is empty"; | 792 DVLOG(1) << "active input method is empty"; |
| 659 return false; | 793 return false; |
| 660 } | 794 } |
| 661 | 795 |
| 662 if (current_input_method_.id().empty()) { | 796 if (state_->current_input_method_.id().empty()) { |
| 663 DVLOG(1) << "current_input_method_ is unknown"; | 797 DVLOG(1) << "current_input_method_ is unknown"; |
| 664 return false; | 798 return false; |
| 665 } | 799 } |
| 666 | 800 |
| 667 // Do not consume key event if there is only one input method is enabled. | 801 // Do not consume key event if there is only one input method is enabled. |
| 668 // Ctrl+Space or Alt+Shift may be used by other application. | 802 // Ctrl+Space or Alt+Shift may be used by other application. |
| 669 if (active_input_method_ids_.size() == 1) | 803 if (state_->active_input_method_ids_.size() == 1) |
| 670 return false; | 804 return false; |
| 671 | 805 |
| 672 // Find the next input method and switch to it. | 806 // Find the next input method and switch to it. |
| 673 SwitchToNextInputMethodInternal(active_input_method_ids_, | 807 SwitchToNextInputMethodInternal(state_->active_input_method_ids_, |
| 674 current_input_method_.id()); | 808 state_->current_input_method_.id()); |
| 675 return true; | 809 return true; |
| 676 } | 810 } |
| 677 | 811 |
| 678 bool InputMethodManagerImpl::SwitchToPreviousInputMethod( | 812 bool InputMethodManagerImpl::SwitchToPreviousInputMethod( |
| 679 const ui::Accelerator& accelerator) { | 813 const ui::Accelerator& accelerator) { |
| 814 DCHECK(state_); | |
| 680 // Sanity check. | 815 // Sanity check. |
| 681 if (active_input_method_ids_.empty()) { | 816 if (state_->active_input_method_ids_.empty()) { |
| 682 DVLOG(1) << "active input method is empty"; | 817 DVLOG(1) << "active input method is empty"; |
| 683 return false; | 818 return false; |
| 684 } | 819 } |
| 685 | 820 |
| 686 // Do not consume key event if there is only one input method is enabled. | 821 // Do not consume key event if there is only one input method is enabled. |
| 687 // Ctrl+Space or Alt+Shift may be used by other application. | 822 // Ctrl+Space or Alt+Shift may be used by other application. |
| 688 if (active_input_method_ids_.size() == 1) | 823 if (state_->active_input_method_ids_.size() == 1) |
| 689 return false; | 824 return false; |
| 690 | 825 |
| 691 if (accelerator.type() == ui::ET_KEY_RELEASED) | 826 if (accelerator.type() == ui::ET_KEY_RELEASED) |
| 692 return true; | 827 return true; |
| 693 | 828 |
| 694 if (previous_input_method_.id().empty() || | 829 if (state_->previous_input_method_.id().empty() || |
| 695 previous_input_method_.id() == current_input_method_.id()) { | 830 state_->previous_input_method_.id() == |
| 831 state_->current_input_method_.id()) { | |
| 696 return SwitchToNextInputMethod(); | 832 return SwitchToNextInputMethod(); |
| 697 } | 833 } |
| 698 | 834 |
| 699 std::vector<std::string>::const_iterator iter = | 835 std::vector<std::string>::const_iterator iter = |
| 700 std::find(active_input_method_ids_.begin(), | 836 std::find(state_->active_input_method_ids_.begin(), |
| 701 active_input_method_ids_.end(), | 837 state_->active_input_method_ids_.end(), |
| 702 previous_input_method_.id()); | 838 state_->previous_input_method_.id()); |
| 703 if (iter == active_input_method_ids_.end()) { | 839 if (iter == state_->active_input_method_ids_.end()) { |
| 704 // previous_input_method_ is not supported. | 840 // previous_input_method_ is not supported. |
| 705 return SwitchToNextInputMethod(); | 841 return SwitchToNextInputMethod(); |
| 706 } | 842 } |
| 707 ChangeInputMethodInternal(*iter, true); | 843 LookupAndChangeInputMethodInternal(*iter, true); |
| 708 return true; | 844 return true; |
| 709 } | 845 } |
| 710 | 846 |
| 711 bool InputMethodManagerImpl::SwitchInputMethod( | 847 bool InputMethodManagerImpl::SwitchInputMethod( |
| 712 const ui::Accelerator& accelerator) { | 848 const ui::Accelerator& accelerator) { |
| 849 DCHECK(state_); | |
| 713 // Sanity check. | 850 // Sanity check. |
| 714 if (active_input_method_ids_.empty()) { | 851 if (state_->active_input_method_ids_.empty()) { |
| 715 DVLOG(1) << "active input method is empty"; | 852 DVLOG(1) << "active input method is empty"; |
| 716 return false; | 853 return false; |
| 717 } | 854 } |
| 718 | 855 |
| 719 // Get the list of input method ids for the |accelerator|. For example, get | 856 // Get the list of input method ids for the |accelerator|. For example, get |
| 720 // { "mozc-hangul", "xkb:kr:kr104:kor" } for ui::VKEY_DBE_SBCSCHAR. | 857 // { "mozc-hangul", "xkb:kr:kr104:kor" } for ui::VKEY_DBE_SBCSCHAR. |
| 721 std::vector<std::string> input_method_ids_to_switch; | 858 std::vector<std::string> input_method_ids_to_switch; |
| 722 switch (accelerator.key_code()) { | 859 switch (accelerator.key_code()) { |
| 723 case ui::VKEY_CONVERT: // Henkan key on JP106 keyboard | 860 case ui::VKEY_CONVERT: // Henkan key on JP106 keyboard |
| 724 input_method_ids_to_switch.push_back( | 861 input_method_ids_to_switch.push_back( |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 743 DVLOG(1) << "Unexpected VKEY: " << accelerator.key_code(); | 880 DVLOG(1) << "Unexpected VKEY: " << accelerator.key_code(); |
| 744 return false; | 881 return false; |
| 745 } | 882 } |
| 746 | 883 |
| 747 // Obtain the intersection of input_method_ids_to_switch and | 884 // Obtain the intersection of input_method_ids_to_switch and |
| 748 // active_input_method_ids_. The order of IDs in active_input_method_ids_ is | 885 // active_input_method_ids_. The order of IDs in active_input_method_ids_ is |
| 749 // preserved. | 886 // preserved. |
| 750 std::vector<std::string> ids; | 887 std::vector<std::string> ids; |
| 751 for (size_t i = 0; i < input_method_ids_to_switch.size(); ++i) { | 888 for (size_t i = 0; i < input_method_ids_to_switch.size(); ++i) { |
| 752 const std::string& id = input_method_ids_to_switch[i]; | 889 const std::string& id = input_method_ids_to_switch[i]; |
| 753 if (Contains(active_input_method_ids_, id)) | 890 if (Contains(state_->active_input_method_ids_, id)) |
| 754 ids.push_back(id); | 891 ids.push_back(id); |
| 755 } | 892 } |
| 756 if (ids.empty()) { | 893 if (ids.empty()) { |
| 757 // No input method for the accelerator is active. For example, we should | 894 // No input method for the accelerator is active. For example, we should |
| 758 // just ignore VKEY_HANGUL when mozc-hangul is not active. | 895 // just ignore VKEY_HANGUL when mozc-hangul is not active. |
| 759 return false; | 896 return false; |
| 760 } | 897 } |
| 761 | 898 |
| 762 SwitchToNextInputMethodInternal(ids, current_input_method_.id()); | 899 SwitchToNextInputMethodInternal(ids, state_->current_input_method_.id()); |
| 763 return true; // consume the accelerator. | 900 return true; // consume the accelerator. |
| 764 } | 901 } |
| 765 | 902 |
| 766 void InputMethodManagerImpl::SwitchToNextInputMethodInternal( | 903 void InputMethodManagerImpl::SwitchToNextInputMethodInternal( |
| 767 const std::vector<std::string>& input_method_ids, | 904 const std::vector<std::string>& input_method_ids, |
| 768 const std::string& current_input_method_id) { | 905 const std::string& current_input_method_id) { |
| 769 std::vector<std::string>::const_iterator iter = | 906 std::vector<std::string>::const_iterator iter = |
| 770 std::find(input_method_ids.begin(), | 907 std::find(input_method_ids.begin(), |
| 771 input_method_ids.end(), | 908 input_method_ids.end(), |
| 772 current_input_method_id); | 909 current_input_method_id); |
| 773 if (iter != input_method_ids.end()) | 910 if (iter != input_method_ids.end()) |
| 774 ++iter; | 911 ++iter; |
| 775 if (iter == input_method_ids.end()) | 912 if (iter == input_method_ids.end()) |
| 776 iter = input_method_ids.begin(); | 913 iter = input_method_ids.begin(); |
| 777 ChangeInputMethodInternal(*iter, true); | 914 LookupAndChangeInputMethodInternal(*iter, true); |
| 778 } | 915 } |
| 779 | 916 |
| 780 InputMethodDescriptor InputMethodManagerImpl::GetCurrentInputMethod() const { | 917 InputMethodDescriptor InputMethodManagerImpl::GetCurrentInputMethod() const { |
| 781 if (current_input_method_.id().empty()) | 918 DCHECK(state_); |
| 919 if (state_->current_input_method_.id().empty()) | |
| 782 return InputMethodUtil::GetFallbackInputMethodDescriptor(); | 920 return InputMethodUtil::GetFallbackInputMethodDescriptor(); |
| 783 | 921 |
| 784 return current_input_method_; | 922 return state_->current_input_method_; |
| 785 } | 923 } |
| 786 | 924 |
| 787 bool InputMethodManagerImpl::IsISOLevel5ShiftUsedByCurrentInputMethod() const { | 925 bool InputMethodManagerImpl::IsISOLevel5ShiftUsedByCurrentInputMethod() const { |
| 788 return keyboard_->IsISOLevel5ShiftAvailable(); | 926 return keyboard_->IsISOLevel5ShiftAvailable(); |
| 789 } | 927 } |
| 790 | 928 |
| 791 bool InputMethodManagerImpl::IsAltGrUsedByCurrentInputMethod() const { | 929 bool InputMethodManagerImpl::IsAltGrUsedByCurrentInputMethod() const { |
| 792 return keyboard_->IsAltGrAvailable(); | 930 return keyboard_->IsAltGrAvailable(); |
| 793 } | 931 } |
| 794 | 932 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 860 CandidateWindowOpened(this)); | 998 CandidateWindowOpened(this)); |
| 861 } | 999 } |
| 862 | 1000 |
| 863 void InputMethodManagerImpl::CandidateWindowClosed() { | 1001 void InputMethodManagerImpl::CandidateWindowClosed() { |
| 864 FOR_EACH_OBSERVER(InputMethodManager::CandidateWindowObserver, | 1002 FOR_EACH_OBSERVER(InputMethodManager::CandidateWindowObserver, |
| 865 candidate_window_observers_, | 1003 candidate_window_observers_, |
| 866 CandidateWindowClosed(this)); | 1004 CandidateWindowClosed(this)); |
| 867 } | 1005 } |
| 868 | 1006 |
| 869 void InputMethodManagerImpl::OnScreenLocked() { | 1007 void InputMethodManagerImpl::OnScreenLocked() { |
| 870 saved_previous_input_method_ = previous_input_method_; | 1008 DCHECK(state_); |
| 871 saved_current_input_method_ = current_input_method_; | 1009 LOG(ERROR) << "InputMethodManagerImpl::OnScreenLocked(): old state_: " |
| 872 saved_active_input_method_ids_ = active_input_method_ids_; | 1010 << state_->Dump(); |
| 1011 state_->saved_previous_input_method_ = state_->previous_input_method_; | |
| 1012 state_->saved_current_input_method_ = state_->current_input_method_; | |
| 1013 state_->saved_active_input_method_ids_ = state_->active_input_method_ids_; | |
| 873 | 1014 |
| 874 std::set<std::string> added_ids_; | 1015 std::set<std::string> added_ids_; |
| 875 | 1016 |
| 876 const std::vector<std::string>& hardware_keyboard_ids = | 1017 const std::vector<std::string>& hardware_keyboard_ids = |
| 877 util_.GetHardwareLoginInputMethodIds(); | 1018 util_.GetHardwareLoginInputMethodIds(); |
| 878 | 1019 |
| 879 active_input_method_ids_.clear(); | 1020 state_->active_input_method_ids_.clear(); |
| 880 for (size_t i = 0; i < saved_active_input_method_ids_.size(); ++i) { | 1021 for (size_t i = 0; i < state_->saved_active_input_method_ids_.size(); ++i) { |
| 881 const std::string& input_method_id = saved_active_input_method_ids_[i]; | 1022 const std::string& input_method_id = |
| 1023 state_->saved_active_input_method_ids_[i]; | |
| 882 // Skip if it's not a keyboard layout. Drop input methods including | 1024 // Skip if it's not a keyboard layout. Drop input methods including |
| 883 // extension ones. | 1025 // extension ones. |
| 884 if (!IsLoginKeyboard(input_method_id) || | 1026 if (!IsLoginKeyboard(input_method_id) || |
| 885 added_ids_.find(input_method_id) != added_ids_.end()) | 1027 added_ids_.find(input_method_id) != added_ids_.end()) |
| 886 continue; | 1028 continue; |
| 887 active_input_method_ids_.push_back(input_method_id); | 1029 state_->active_input_method_ids_.push_back(input_method_id); |
| 888 added_ids_.insert(input_method_id); | 1030 added_ids_.insert(input_method_id); |
| 889 } | 1031 } |
| 890 | 1032 |
| 891 // We'll add the hardware keyboard if it's not included in | 1033 // We'll add the hardware keyboard if it's not included in |
| 892 // |active_input_method_ids_| so that the user can always use the hardware | 1034 // |active_input_method_ids_| so that the user can always use the hardware |
| 893 // keyboard on the screen locker. | 1035 // keyboard on the screen locker. |
| 894 for (size_t i = 0; i < hardware_keyboard_ids.size(); ++i) { | 1036 for (size_t i = 0; i < hardware_keyboard_ids.size(); ++i) { |
| 895 if (added_ids_.find(hardware_keyboard_ids[i]) == added_ids_.end()) { | 1037 if (added_ids_.find(hardware_keyboard_ids[i]) == added_ids_.end()) { |
| 896 active_input_method_ids_.push_back(hardware_keyboard_ids[i]); | 1038 state_->active_input_method_ids_.push_back(hardware_keyboard_ids[i]); |
| 897 added_ids_.insert(hardware_keyboard_ids[i]); | 1039 added_ids_.insert(hardware_keyboard_ids[i]); |
| 898 } | 1040 } |
| 899 } | 1041 } |
| 900 | 1042 |
| 901 ChangeInputMethod(current_input_method_.id()); | 1043 LOG(ERROR) << "InputMethodManagerImpl::OnScreenLocked(): new state_: " |
| 1044 << state_->Dump(); | |
| 1045 ChangeInputMethod(state_->current_input_method_.id()); | |
| 902 } | 1046 } |
| 903 | 1047 |
| 904 void InputMethodManagerImpl::OnScreenUnlocked() { | 1048 void InputMethodManagerImpl::OnScreenUnlocked() { |
| 905 previous_input_method_ = saved_previous_input_method_; | 1049 LOG(ERROR) << "InputMethodManagerImpl::OnScreenUnLocked(): old state_: " |
| 906 current_input_method_ = saved_current_input_method_; | 1050 << state_->Dump(); |
| 907 active_input_method_ids_ = saved_active_input_method_ids_; | 1051 state_->previous_input_method_ = state_->saved_previous_input_method_; |
| 1052 state_->current_input_method_ = state_->saved_current_input_method_; | |
| 1053 state_->active_input_method_ids_ = state_->saved_active_input_method_ids_; | |
| 908 | 1054 |
| 909 ChangeInputMethod(current_input_method_.id()); | 1055 LOG(ERROR) << "InputMethodManagerImpl::OnScreenUnLocked(): new state_: " |
| 1056 << state_->Dump(); | |
| 1057 ChangeInputMethod(state_->current_input_method_.id()); | |
| 910 } | 1058 } |
| 911 | 1059 |
| 912 bool InputMethodManagerImpl::InputMethodIsActivated( | 1060 bool InputMethodManagerImpl::InputMethodIsActivated( |
| 913 const std::string& input_method_id) { | 1061 const std::string& input_method_id) { |
| 914 return Contains(active_input_method_ids_, input_method_id); | 1062 DCHECK(state_); |
| 1063 return Contains(state_->active_input_method_ids_, input_method_id); | |
| 915 } | 1064 } |
| 916 | 1065 |
| 917 void InputMethodManagerImpl::MaybeInitializeCandidateWindowController() { | 1066 void InputMethodManagerImpl::MaybeInitializeCandidateWindowController() { |
| 918 if (candidate_window_controller_.get()) | 1067 if (candidate_window_controller_.get()) |
| 919 return; | 1068 return; |
| 920 | 1069 |
| 921 candidate_window_controller_.reset( | 1070 candidate_window_controller_.reset( |
| 922 CandidateWindowController::CreateCandidateWindowController()); | 1071 CandidateWindowController::CreateCandidateWindowController()); |
| 923 candidate_window_controller_->AddObserver(this); | 1072 candidate_window_controller_->AddObserver(this); |
| 924 } | 1073 } |
| 925 | 1074 |
| 926 Profile* InputMethodManagerImpl::GetProfile() const { | |
| 927 return ProfileManager::GetActiveUserProfile(); | |
| 928 } | |
| 929 | |
| 930 } // namespace input_method | 1075 } // namespace input_method |
| 931 } // namespace chromeos | 1076 } // namespace chromeos |
| OLD | NEW |