Commit 820d766b authored by Yuichiro Hanada's avatar Yuichiro Hanada Committed by Commit Bot

Consume the back button press only when ARC IME shows.

Bug: 894362, 845079
Test: The back button works as history back when ARC IME doesn't show up.
Change-Id: Ibffbf39f02f9bc3c75c42b4091dce442046d48e2
Reviewed-on: https://chromium-review.googlesource.com/c/1278511
Commit-Queue: Yusuke Sato <yusukes@chromium.org>
Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599350}
parent 09ab59fc
...@@ -120,9 +120,10 @@ class ArcInputMethodManagerService::InputMethodEngineObserver ...@@ -120,9 +120,10 @@ class ArcInputMethodManagerService::InputMethodEngineObserver
const std::string& engine_id, const std::string& engine_id,
const input_method::InputMethodEngineBase::KeyboardEvent& event, const input_method::InputMethodEngineBase::KeyboardEvent& event,
ui::IMEEngineHandlerInterface::KeyEventDoneCallback key_data) override { ui::IMEEngineHandlerInterface::KeyEventDoneCallback key_data) override {
if (event.key == "HistoryBack") { if (event.key_code == ui::VKEY_BROWSER_BACK &&
owner_->IsVirtualKeyboardShown()) {
// Back button on the shelf is pressed. // Back button on the shelf is pressed.
owner_->imm_bridge_->SendHideVirtualKeyboard(); owner_->SendHideVirtualKeyboard();
std::move(key_data).Run(true); std::move(key_data).Run(true);
return; return;
} }
...@@ -185,7 +186,7 @@ class ArcInputMethodManagerService::InputMethodObserver ...@@ -185,7 +186,7 @@ class ArcInputMethodManagerService::InputMethodObserver
void OnTextInputStateChanged(const ui::TextInputClient* client) override {} void OnTextInputStateChanged(const ui::TextInputClient* client) override {}
void OnInputMethodDestroyed(const ui::InputMethod* input_method) override {} void OnInputMethodDestroyed(const ui::InputMethod* input_method) override {}
void OnShowVirtualKeyboardIfEnabled() override { void OnShowVirtualKeyboardIfEnabled() override {
owner_->imm_bridge_->SendShowVirtualKeyboard(); owner_->SendShowVirtualKeyboard();
} }
private: private:
...@@ -234,6 +235,7 @@ ArcInputMethodManagerService::ArcInputMethodManagerService( ...@@ -234,6 +235,7 @@ ArcInputMethodManagerService::ArcInputMethodManagerService(
imm_bridge_( imm_bridge_(
std::make_unique<ArcInputMethodManagerBridgeImpl>(this, std::make_unique<ArcInputMethodManagerBridgeImpl>(this,
bridge_service)), bridge_service)),
is_virtual_keyboard_shown_(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>()),
...@@ -472,6 +474,7 @@ void ArcInputMethodManagerService::Focus(int context_id) { ...@@ -472,6 +474,7 @@ void ArcInputMethodManagerService::Focus(int context_id) {
void ArcInputMethodManagerService::Blur() { void ArcInputMethodManagerService::Blur() {
active_connection_.reset(); active_connection_.reset();
is_virtual_keyboard_shown_ = false;
} }
void ArcInputMethodManagerService::UpdateTextInputState() { void ArcInputMethodManagerService::UpdateTextInputState() {
...@@ -635,4 +638,20 @@ void ArcInputMethodManagerService::OnArcImeDeactivated() { ...@@ -635,4 +638,20 @@ void ArcInputMethodManagerService::OnArcImeDeactivated() {
input_method->RemoveObserver(input_method_observer_.get()); input_method->RemoveObserver(input_method_observer_.get());
} }
bool ArcInputMethodManagerService::IsVirtualKeyboardShown() const {
return is_virtual_keyboard_shown_;
}
void ArcInputMethodManagerService::SendShowVirtualKeyboard() {
imm_bridge_->SendShowVirtualKeyboard();
// TODO(yhanada): Should observe IME window size changes.
is_virtual_keyboard_shown_ = true;
}
void ArcInputMethodManagerService::SendHideVirtualKeyboard() {
imm_bridge_->SendHideVirtualKeyboard();
// TODO(yhanada): Should observe IME window size changes.
is_virtual_keyboard_shown_ = false;
}
} // namespace arc } // namespace arc
...@@ -100,10 +100,15 @@ class ArcInputMethodManagerService ...@@ -100,10 +100,15 @@ class ArcInputMethodManagerService
void OnArcImeActivated(); void OnArcImeActivated();
void OnArcImeDeactivated(); void OnArcImeDeactivated();
bool IsVirtualKeyboardShown() const;
void SendShowVirtualKeyboard();
void SendHideVirtualKeyboard();
Profile* const profile_; Profile* const profile_;
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_;
// 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