Index: chrome/browser/chromeos/input_method/input_method_manager_impl.cc |
diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc |
index 8db20e0df9a396ec26bb20e81aab5b8a57aeb807..5865d1a04e666d2832bb8b6325d7bac6a24fb682 100644 |
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc |
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc |
@@ -338,18 +338,15 @@ bool InputMethodManagerImpl::ChangeInputMethodInternal( |
engine->Disable(); |
// Configure the next engine handler. |
- if (InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch) && |
- !extension_ime_util::IsKeyboardLayoutExtension( |
- input_method_id_to_switch)) { |
- IMEBridge::Get()->SetCurrentEngineHandler(NULL); |
- } else { |
- IMEEngineHandlerInterface* next_engine = |
- profile_engine_map_[GetProfile()][input_method_id_to_switch]; |
- if (next_engine) { |
- IMEBridge::Get()->SetCurrentEngineHandler(next_engine); |
- next_engine->Enable(); |
- } |
- } |
+ std::string extension_id = |
+ extension_ime_util::GetExtensionIDFromInputMethodID( |
+ input_method_id_to_switch); |
+ std::string engine_id = extension_ime_util::GetEngineIDByInputMethodID( |
+ input_method_id_to_switch); |
+ engine = engine_map_[extension_id]; |
+ IMEBridge::Get()->SetCurrentEngineHandler(engine); |
+ if (engine) |
+ engine->Enable(engine_id); |
// TODO(komatsu): Check if it is necessary to perform the above routine |
// when the current input method is equal to |input_method_id_to_swich|. |
@@ -433,56 +430,67 @@ void InputMethodManagerImpl::ActivateInputMethodMenuItem( |
} |
void InputMethodManagerImpl::AddInputMethodExtension( |
- const std::string& id, |
+ const std::string& extension_id, |
+ const InputMethodDescriptors& descriptors, |
InputMethodEngineInterface* engine) { |
if (state_ == STATE_TERMINATING) |
return; |
DCHECK(engine); |
- profile_engine_map_[GetProfile()][id] = engine; |
+ engine_map_[extension_id] = engine; |
- if (id == current_input_method_.id()) { |
+ if (extension_id == extension_ime_util::GetExtensionIDFromInputMethodID( |
+ current_input_method_.id())) { |
IMEBridge::Get()->SetCurrentEngineHandler(engine); |
- engine->Enable(); |
- } |
- |
- if (extension_ime_util::IsComponentExtensionIME(id)) |
- return; |
- |
- CHECK(extension_ime_util::IsExtensionIME(id)) |
- << id << "is not a valid extension input method ID"; |
- |
- const InputMethodDescriptor& descriptor = engine->GetDescriptor(); |
- extra_input_methods_[id] = descriptor; |
- |
- if (Contains(enabled_extension_imes_, id)) { |
- if (!Contains(active_input_method_ids_, id)) { |
- active_input_method_ids_.push_back(id); |
- } else { |
- DVLOG(1) << "AddInputMethodExtension: alread added: " |
- << id << ", " << descriptor.name(); |
+ engine->Enable(extension_ime_util::GetEngineIDByInputMethodID( |
+ current_input_method_.id())); |
+ } |
+ |
+ bool contain = false; |
+ for (size_t i = 0; i < descriptors.size(); i++) { |
+ const InputMethodDescriptor& descriptor = descriptors[i]; |
+ const std::string& id = descriptor.id(); |
+ extra_input_methods_[id] = descriptor; |
+ if (Contains(enabled_extension_imes_, id)) { |
+ if (!Contains(active_input_method_ids_, id)) { |
+ active_input_method_ids_.push_back(id); |
+ } else { |
+ DVLOG(1) << "AddInputMethodExtension: alread added: " |
Seigo Nonaka
2014/08/04 23:29:47
nit: /alread/already/ I'm sorry this is not your m
Shu Chen
2014/08/05 01:23:09
Done.
|
+ << id << ", " << descriptor.name(); |
+ } |
+ contain = true; |
} |
+ } |
- // Ensure that the input method daemon is running. |
+ // Ensure that the input method daemon is running. |
+ if (contain) |
MaybeInitializeCandidateWindowController(); |
- } |
} |
-void InputMethodManagerImpl::RemoveInputMethodExtension(const std::string& id) { |
- if (!extension_ime_util::IsExtensionIME(id)) |
- DVLOG(1) << id << " is not a valid extension input method ID."; |
- |
- std::vector<std::string>::iterator i = std::find( |
- active_input_method_ids_.begin(), active_input_method_ids_.end(), id); |
- if (i != active_input_method_ids_.end()) |
- active_input_method_ids_.erase(i); |
- extra_input_methods_.erase(id); |
+void InputMethodManagerImpl::RemoveInputMethodExtension( |
Shu Chen
2014/08/04 15:59:31
I'm not sure whether the below code to remove thin
Seigo Nonaka
2014/08/04 23:29:47
Maybe true. could you fix?
On 2014/08/04 15:59:3
Shu Chen
2014/08/05 01:23:09
Done.
|
+ const std::string& extension_id) { |
+ for (std::vector<std::string>::iterator i = active_input_method_ids_.begin(); |
+ i != active_input_method_ids_.end();) { |
+ if (extension_id == |
+ extension_ime_util::GetExtensionIDFromInputMethodID(*i)) |
+ active_input_method_ids_.erase(i); |
+ else |
+ ++i; |
+ } |
+ for (std::map<std::string, InputMethodDescriptor>::iterator i = |
+ extra_input_methods_.begin(); |
+ i != extra_input_methods_.end();) { |
+ if (extension_id == |
+ extension_ime_util::GetExtensionIDFromInputMethodID(i->first)) |
+ extra_input_methods_.erase(i++); |
+ else |
+ i++; |
+ } |
- EngineMap& engine_map = profile_engine_map_[GetProfile()]; |
- if (IMEBridge::Get()->GetCurrentEngineHandler() == engine_map[id]) |
+ if (IMEBridge::Get()->GetCurrentEngineHandler() == engine_map_[extension_id]) |
IMEBridge::Get()->SetCurrentEngineHandler(NULL); |
- engine_map.erase(id); |
+ engine_map_.erase(extension_id); |
// No need to switch input method when terminating. |
if (state_ != STATE_TERMINATING) { |