Commit e3199eeb authored by Yuichiro Hanada's avatar Yuichiro Hanada Committed by Commit Bot

Reland: Disable Android IMEs according to given ImeInfo.

The original CL is crrev.com/c/1331294 and it was reverted due to
MSan failure. The failure should be fixed by adding initialization for
|is_removing_imm_entry_|.

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: I4f9067cabf96fcb28d594a72856df1e34d469114
Reviewed-on: https://chromium-review.googlesource.com/c/1334672Reviewed-by: default avatarKazuhiro Inaba <kinaba@chromium.org>
Commit-Queue: Yuichiro Hanada <yhanada@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607869}
parent 02d11389
...@@ -226,6 +226,7 @@ ArcInputMethodManagerService::ArcInputMethodManagerService( ...@@ -226,6 +226,7 @@ ArcInputMethodManagerService::ArcInputMethodManagerService(
std::make_unique<ArcInputMethodManagerBridgeImpl>(this, std::make_unique<ArcInputMethodManagerBridgeImpl>(this,
bridge_service)), bridge_service)),
is_virtual_keyboard_shown_(false), is_virtual_keyboard_shown_(false),
is_removing_imm_entry_(false),
proxy_ime_extension_id_( proxy_ime_extension_id_(
crx_file::id_util::GenerateId(kArcIMEProxyExtensionName)), crx_file::id_util::GenerateId(kArcIMEProxyExtensionName)),
proxy_ime_engine_(std::make_unique<chromeos::InputMethodEngine>()), proxy_ime_engine_(std::make_unique<chromeos::InputMethodEngine>()),
...@@ -328,10 +329,12 @@ void ArcInputMethodManagerService::OnImeInfoChanged( ...@@ -328,10 +329,12 @@ void ArcInputMethodManagerService::OnImeInfoChanged(
if (!base::FeatureList::IsEnabled(kEnableInputMethodFeature)) if (!base::FeatureList::IsEnabled(kEnableInputMethodFeature))
return; return;
is_removing_imm_entry_ = true;
scoped_refptr<InputMethodManager::State> state = scoped_refptr<InputMethodManager::State> state =
InputMethodManager::Get()->GetActiveIMEState(); InputMethodManager::Get()->GetActiveIMEState();
// Remove the old registered entry. // Remove the old registered entry.
state->RemoveInputMethodExtension(proxy_ime_extension_id_); state->RemoveInputMethodExtension(proxy_ime_extension_id_);
is_removing_imm_entry_ = false;
// Convert ime_info_array to InputMethodDescriptors. // Convert ime_info_array to InputMethodDescriptors.
InputMethodDescriptors descriptors; InputMethodDescriptors descriptors;
...@@ -363,6 +366,11 @@ void ArcInputMethodManagerService::OnImeInfoChanged( ...@@ -363,6 +366,11 @@ void ArcInputMethodManagerService::OnImeInfoChanged(
if (!base::ContainsValue(active_ime_list, input_method_id)) if (!base::ContainsValue(active_ime_list, input_method_id))
active_ime_list.push_back(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, profile_->GetPrefs()->SetString(prefs::kLanguageEnabledImes,
base::JoinString(active_ime_list, ",")); base::JoinString(active_ime_list, ","));
...@@ -382,6 +390,11 @@ void ArcInputMethodManagerService::OnConnectionClosed() { ...@@ -382,6 +390,11 @@ void ArcInputMethodManagerService::OnConnectionClosed() {
} }
void ArcInputMethodManagerService::ImeMenuListChanged() { 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* manager = chromeos::input_method::InputMethodManager::Get();
auto new_active_ime_ids = auto new_active_ime_ids =
manager->GetActiveIMEState()->GetActiveInputMethodIds(); manager->GetActiveIMEState()->GetActiveInputMethodIds();
......
...@@ -119,6 +119,7 @@ class ArcInputMethodManagerService ...@@ -119,6 +119,7 @@ class ArcInputMethodManagerService
std::unique_ptr<ArcInputMethodManagerBridge> imm_bridge_; std::unique_ptr<ArcInputMethodManagerBridge> imm_bridge_;
std::set<std::string> active_arc_ime_ids_; std::set<std::string> active_arc_ime_ids_;
bool is_virtual_keyboard_shown_; bool is_virtual_keyboard_shown_;
bool is_removing_imm_entry_;
// ArcInputMethodManager installs a proxy IME to redirect IME related events // ArcInputMethodManager installs a proxy IME to redirect IME related events
// from/to ARC IMEs in the container. The below two variables are for the // 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