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

Stop ArcImeService from interacting with ui::InputMethod while it's not focused.

ArcInputMethodService which is at the other side of the mojo channel can
call methods even when a text input on a non-ARC window is focused
because there is a dummy input view in Android side which is
synchronized with the text input on the non-ARC window.

Bug: 1063740, b:152792033
Change-Id: I8ea636aeb765500f0fbd12475a660ec104364114
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2137164Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Commit-Queue: Yuichiro Hanada <yhanada@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756582}
parent 8ba9ebda
...@@ -299,6 +299,13 @@ void ArcImeService::OnTextInputTypeChanged( ...@@ -299,6 +299,13 @@ void ArcImeService::OnTextInputTypeChanged(
ui::TextInputType type, ui::TextInputType type,
bool is_personalized_learning_allowed, bool is_personalized_learning_allowed,
int flags) { int flags) {
// The focus is on a non-ARC window. This method can be called even When a
// text input on a non-ARC window is focused because there is a dummy input
// view in Android side which is synchronized with the text input on the
// non-ARC window.
if (focused_arc_window_ == nullptr)
return;
if (ime_type_ == type && if (ime_type_ == type &&
is_personalized_learning_allowed_ == is_personalized_learning_allowed && is_personalized_learning_allowed_ == is_personalized_learning_allowed &&
ime_flags_ == flags) { ime_flags_ == flags) {
...@@ -325,6 +332,13 @@ void ArcImeService::OnTextInputTypeChanged( ...@@ -325,6 +332,13 @@ void ArcImeService::OnTextInputTypeChanged(
void ArcImeService::OnCursorRectChanged(const gfx::Rect& rect, void ArcImeService::OnCursorRectChanged(const gfx::Rect& rect,
bool is_screen_coordinates) { bool is_screen_coordinates) {
// The focus is on a non-ARC window. This method can be called even when a
// text input on a non-ARC window is focused because there is a dummy input
// view in Android side which is synchronized with the text input on the
// non-ARC window.
if (focused_arc_window_ == nullptr)
return;
InvalidateSurroundingTextAndSelectionRange(); InvalidateSurroundingTextAndSelectionRange();
if (!UpdateCursorRect(rect, is_screen_coordinates)) if (!UpdateCursorRect(rect, is_screen_coordinates))
return; return;
...@@ -335,6 +349,13 @@ void ArcImeService::OnCursorRectChanged(const gfx::Rect& rect, ...@@ -335,6 +349,13 @@ void ArcImeService::OnCursorRectChanged(const gfx::Rect& rect,
} }
void ArcImeService::OnCancelComposition() { void ArcImeService::OnCancelComposition() {
// The focus is on a non-ARC window. This method can be called even when a
// text input on a non-ARC window is focused because there is a dummy input
// view in Android side which is synchronized with the text input on the
// non-ARC window.
if (focused_arc_window_ == nullptr)
return;
InvalidateSurroundingTextAndSelectionRange(); InvalidateSurroundingTextAndSelectionRange();
ui::InputMethod* const input_method = GetInputMethod(); ui::InputMethod* const input_method = GetInputMethod();
if (input_method) if (input_method)
...@@ -342,6 +363,13 @@ void ArcImeService::OnCancelComposition() { ...@@ -342,6 +363,13 @@ void ArcImeService::OnCancelComposition() {
} }
void ArcImeService::ShowVirtualKeyboardIfEnabled() { void ArcImeService::ShowVirtualKeyboardIfEnabled() {
// The focus is on a non-ARC window. This method can be called even when a
// text input on a non-ARC window is focused because there is a dummy input
// view in Android side which is synchronized with the text input on the
// non-ARC window.
if (focused_arc_window_ == nullptr)
return;
ui::InputMethod* const input_method = GetInputMethod(); ui::InputMethod* const input_method = GetInputMethod();
if (input_method && input_method->GetTextInputClient() == this) { if (input_method && input_method->GetTextInputClient() == this) {
input_method->ShowVirtualKeyboardIfEnabled(); input_method->ShowVirtualKeyboardIfEnabled();
...@@ -354,6 +382,13 @@ void ArcImeService::OnCursorRectChangedWithSurroundingText( ...@@ -354,6 +382,13 @@ void ArcImeService::OnCursorRectChangedWithSurroundingText(
const base::string16& text_in_range, const base::string16& text_in_range,
const gfx::Range& selection_range, const gfx::Range& selection_range,
bool is_screen_coordinates) { bool is_screen_coordinates) {
// The focus is on a non-ARC window. This method can be called even when a
// text input on a non-ARC window is focused because there is a dummy input
// view in Android side which is synchronized with the text input on the
// non-ARC window.
if (focused_arc_window_ == nullptr)
return;
text_range_ = text_range; text_range_ = text_range;
text_in_range_ = text_in_range; text_in_range_ = text_in_range;
selection_range_ = selection_range; selection_range_ = selection_range;
......
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