Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2274)

Unified Diff: chrome/browser/chromeos/input_method/input_method_manager_impl.cc

Issue 10907196: Add the ability to filter out extension IMEs from the language settings page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 abd6a9ee2be1c72e409ef67f93b9adfcad568f8a..f396d475a5f90fbca394b369d8b0f04e470618a8 100644
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
@@ -316,19 +316,20 @@ void InputMethodManagerImpl::AddInputMethodExtension(
const std::string layout = layouts.empty() ? "" : layouts[0];
extra_input_methods_[id] =
InputMethodDescriptor(id, name, layout, language, true);
+ if (!Contains(filtered_extension_imes_, id)) {
+ if (!Contains(active_input_method_ids_, id)) {
+ active_input_method_ids_.push_back(id);
+ } else {
+ DVLOG(1) << "AddInputMethodExtension: alread added: "
+ << id << ", " << name;
+ // Call Start() anyway, just in case.
+ }
- if (!Contains(active_input_method_ids_, id)) {
- active_input_method_ids_.push_back(id);
- } else {
- DVLOG(1) << "AddInputMethodExtension: alread added: "
- << id << ", " << name;
- // Call Start() anyway, just in case.
+ // Ensure that the input method daemon is running.
+ MaybeInitializeCandidateWindowController();
+ ibus_controller_->Start();
}
- // Ensure that the input method daemon is running.
- MaybeInitializeCandidateWindowController();
- ibus_controller_->Start();
-
extra_input_method_instances_[id] =
static_cast<InputMethodEngineIBus*>(engine);
}
@@ -365,6 +366,57 @@ void InputMethodManagerImpl::RemoveInputMethodExtension(const std::string& id) {
}
}
+InputMethodDescriptors* InputMethodManagerImpl::GetInputMethodExtensions() {
+ InputMethodDescriptors* result = new InputMethodDescriptors;
Seigo Nonaka 2012/09/12 16:50:37 Caller takes ownership of returned value? Please l
Zachary Kuznia 2012/09/13 09:28:32 Done.
+ // Build the extension input method descriptors from the extra input
+ // methods cache |extra_input_methods_|.
+ std::map<std::string, InputMethodDescriptor>::iterator iter;
+ for (iter = extra_input_methods_.begin(); iter != extra_input_methods_.end();
+ ++iter) {
+ result->push_back(iter->second);
+ }
+ return result;
+}
+
+void InputMethodManagerImpl::SetFilteredExtensionImes(
+ std::vector<std::string>& ids) {
+
+ filtered_extension_imes_.insert(filtered_extension_imes_.end(),
+ ids.begin(),
+ ids.end());
+
+ bool active_imes_changed = false;
+
+ for (std::map<std::string, InputMethodDescriptor>::iterator extra_iter =
+ extra_input_methods_.begin(); extra_iter != extra_input_methods_.end();
+ ++extra_iter) {
+ std::vector<std::string>::iterator active_iter = std::find(
+ active_input_method_ids_.begin(), active_input_method_ids_.end(),
+ extra_iter->first);
+
+ bool active = active_iter != active_input_method_ids_.end();
+ bool filtered = Contains(filtered_extension_imes_, extra_iter->first);
+
+ if (active && filtered)
+ active_input_method_ids_.erase(active_iter);
+
+ if (!active && !filtered)
+ active_input_method_ids_.push_back(extra_iter->first);
+
+ if (active == filtered)
+ active_imes_changed = true;
+ }
+
+ if (active_imes_changed) {
+ MaybeInitializeCandidateWindowController();
+ ibus_controller_->Start();
+
+ // If |current_input_method| is no longer in |active_input_method_ids_|,
+ // switch to the first one in |active_input_method_ids_|.
+ ChangeInputMethod(current_input_method_.id());
+ }
+}
+
bool InputMethodManagerImpl::SwitchToNextInputMethod() {
// Sanity checks.
if (active_input_method_ids_.empty()) {
@@ -503,7 +555,8 @@ void InputMethodManagerImpl::OnConnected() {
extra_input_method_instances_.begin();
ite != extra_input_method_instances_.end();
ite++) {
- ite->second->OnConnected();
+ if (!Contains(filtered_extension_imes_, ite->first))
+ ite->second->OnConnected();
}
}
@@ -512,7 +565,8 @@ void InputMethodManagerImpl::OnDisconnected() {
extra_input_method_instances_.begin();
ite != extra_input_method_instances_.end();
ite++) {
- ite->second->OnDisconnected();
+ if (!Contains(filtered_extension_imes_, ite->first))
+ ite->second->OnDisconnected();
}
}

Powered by Google App Engine
This is Rietveld 408576698