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 "ash/ime/input_method_menu_item.h" | 9 #include "ash/ime/input_method_menu_item.h" |
10 #include "ash/ime/input_method_menu_manager.h" | 10 #include "ash/ime/input_method_menu_manager.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 110 } |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 scoped_ptr<InputMethodDescriptors> | 114 scoped_ptr<InputMethodDescriptors> |
115 InputMethodManagerImpl::GetSupportedInputMethods() const { | 115 InputMethodManagerImpl::GetSupportedInputMethods() const { |
116 scoped_ptr<InputMethodDescriptors> whitelist_imes = | 116 scoped_ptr<InputMethodDescriptors> whitelist_imes = |
117 whitelist_.GetSupportedInputMethods(); | 117 whitelist_.GetSupportedInputMethods(); |
118 if (!extension_ime_util::UseWrappedExtensionKeyboardLayouts()) | 118 if (!extension_ime_util::UseWrappedExtensionKeyboardLayouts()) |
119 return whitelist_imes.Pass(); | 119 return whitelist_imes.Pass(); |
120 return scoped_ptr<InputMethodDescriptors>(new InputMethodDescriptors).Pass(); | 120 |
| 121 InputMethodDescriptors* input_methods = new InputMethodDescriptors; |
| 122 if (!component_extension_ime_manager_->IsInitialized()) { |
| 123 for (size_t i = 0; i < whitelist_imes->size(); ++i) { |
| 124 const InputMethodDescriptor& ime = (*whitelist_imes.get())[i]; |
| 125 input_methods->push_back(InputMethodDescriptor( |
| 126 extension_ime_util::GetInputMethodIDByKeyboardLayout( |
| 127 ime.id()), |
| 128 ime.name(), ime.indicator(), ime.keyboard_layouts(), |
| 129 ime.language_codes(), ime.is_login_keyboard(), |
| 130 ime.options_page_url(), ime.input_view_url())); |
| 131 } |
| 132 } |
| 133 return scoped_ptr<InputMethodDescriptors>(input_methods).Pass(); |
121 } | 134 } |
122 | 135 |
123 scoped_ptr<InputMethodDescriptors> | 136 scoped_ptr<InputMethodDescriptors> |
124 InputMethodManagerImpl::GetActiveInputMethods() const { | 137 InputMethodManagerImpl::GetActiveInputMethods() const { |
125 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors); | 138 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors); |
126 // Build the active input method descriptors from the active input | 139 // Build the active input method descriptors from the active input |
127 // methods cache |active_input_method_ids_|. | 140 // methods cache |active_input_method_ids_|. |
128 for (size_t i = 0; i < active_input_method_ids_.size(); ++i) { | 141 for (size_t i = 0; i < active_input_method_ids_.size(); ++i) { |
129 const std::string& input_method_id = active_input_method_ids_[i]; | 142 const std::string& input_method_id = active_input_method_ids_[i]; |
130 const InputMethodDescriptor* descriptor = | 143 const InputMethodDescriptor* descriptor = |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 DCHECK(!input_methods->empty()); | 335 DCHECK(!input_methods->empty()); |
323 input_method_id_to_switch = input_methods->at(0).id(); | 336 input_method_id_to_switch = input_methods->at(0).id(); |
324 if (!input_method_id.empty()) { | 337 if (!input_method_id.empty()) { |
325 DVLOG(1) << "Can't change the current input method to " | 338 DVLOG(1) << "Can't change the current input method to " |
326 << input_method_id << " since the engine is not enabled. " | 339 << input_method_id << " since the engine is not enabled. " |
327 << "Switch to " << input_method_id_to_switch << " instead."; | 340 << "Switch to " << input_method_id_to_switch << " instead."; |
328 } | 341 } |
329 } | 342 } |
330 | 343 |
331 if (!component_extension_ime_manager_->IsInitialized() && | 344 if (!component_extension_ime_manager_->IsInitialized() && |
332 (!InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch) || | 345 !InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch)) { |
333 extension_ime_util::IsKeyboardLayoutExtension( | |
334 input_method_id_to_switch))) { | |
335 // We can't change input method before the initialization of | 346 // We can't change input method before the initialization of |
336 // component extension ime manager. ChangeInputMethod will be | 347 // component extension ime manager. ChangeInputMethod will be |
337 // called with |pending_input_method_| when the initialization is | 348 // called with |pending_input_method_| when the initialization is |
338 // done. | 349 // done. |
339 pending_input_method_ = input_method_id_to_switch; | 350 pending_input_method_ = input_method_id_to_switch; |
340 return false; | 351 return false; |
341 } | 352 } |
342 pending_input_method_.clear(); | 353 pending_input_method_.clear(); |
343 | 354 |
344 // Hide candidate window and info list. | 355 // Hide candidate window and info list. |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 CandidateWindowController::CreateCandidateWindowController()); | 865 CandidateWindowController::CreateCandidateWindowController()); |
855 candidate_window_controller_->AddObserver(this); | 866 candidate_window_controller_->AddObserver(this); |
856 } | 867 } |
857 | 868 |
858 Profile* InputMethodManagerImpl::GetProfile() const { | 869 Profile* InputMethodManagerImpl::GetProfile() const { |
859 return ProfileManager::GetActiveUserProfile(); | 870 return ProfileManager::GetActiveUserProfile(); |
860 } | 871 } |
861 | 872 |
862 } // namespace input_method | 873 } // namespace input_method |
863 } // namespace chromeos | 874 } // namespace chromeos |
OLD | NEW |