Commit 2687587b authored by Yuichiro Hanada's avatar Yuichiro Hanada Committed by Commit Bot

Disable Android IMEs according to given ImeInfo.

Android IMEs can be disabled in Android side by using 'ime' command.
This CL ensures that disabled IMEs are also disabled in Chrome OS's
InputMethodManager.

Bug: b/119274469
Change-Id: I46c2996a41327221470d69b778da2b7270c73cd2
Reviewed-on: https://chromium-review.googlesource.com/c/1331294Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Commit-Queue: Yuichiro Hanada <yhanada@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607473}
parent 5f983318
......@@ -328,10 +328,12 @@ void ArcInputMethodManagerService::OnImeInfoChanged(
if (!base::FeatureList::IsEnabled(kEnableInputMethodFeature))
return;
is_removing_imm_entry_ = true;
scoped_refptr<InputMethodManager::State> state =
InputMethodManager::Get()->GetActiveIMEState();
// Remove the old registered entry.
state->RemoveInputMethodExtension(proxy_ime_extension_id_);
is_removing_imm_entry_ = false;
// Convert ime_info_array to InputMethodDescriptors.
InputMethodDescriptors descriptors;
......@@ -363,6 +365,11 @@ void ArcInputMethodManagerService::OnImeInfoChanged(
if (!base::ContainsValue(active_ime_list, input_method_id))
active_ime_list.push_back(input_method_id);
}
// Disable IMEs that are already disable in the container.
base::EraseIf(active_ime_list, [&enabled_input_method_ids](const auto& id) {
return chromeos::extension_ime_util::IsArcIME(id) &&
!base::ContainsValue(enabled_input_method_ids, id);
});
profile_->GetPrefs()->SetString(prefs::kLanguageEnabledImes,
base::JoinString(active_ime_list, ","));
......@@ -382,6 +389,11 @@ void ArcInputMethodManagerService::OnConnectionClosed() {
}
void ArcInputMethodManagerService::ImeMenuListChanged() {
// Ignore ime menu list change while removing the old entry in
// |OnImeInfoChanged| not to expose temporary state to ARC++ container.
if (is_removing_imm_entry_)
return;
auto* manager = chromeos::input_method::InputMethodManager::Get();
auto new_active_ime_ids =
manager->GetActiveIMEState()->GetActiveInputMethodIds();
......
......@@ -119,6 +119,7 @@ class ArcInputMethodManagerService
std::unique_ptr<ArcInputMethodManagerBridge> imm_bridge_;
std::set<std::string> active_arc_ime_ids_;
bool is_virtual_keyboard_shown_;
bool is_removing_imm_entry_;
// ArcInputMethodManager installs a proxy IME to redirect IME related events
// from/to ARC IMEs in the container. The below two variables are for the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment