diff options
Diffstat (limited to 'ui/base')
-rw-r--r-- | ui/base/ime/chromeos/ime_bridge.h | 4 | ||||
-rw-r--r-- | ui/base/ime/chromeos/mock_ime_engine_handler.cc | 4 | ||||
-rw-r--r-- | ui/base/ime/chromeos/mock_ime_engine_handler.h | 1 | ||||
-rw-r--r-- | ui/base/ime/input_method_chromeos.cc | 19 | ||||
-rw-r--r-- | ui/base/ime/input_method_chromeos.h | 2 |
5 files changed, 21 insertions, 9 deletions
diff --git a/ui/base/ime/chromeos/ime_bridge.h b/ui/base/ime/chromeos/ime_bridge.h index 3978ec4..09dd33f 100644 --- a/ui/base/ime/chromeos/ime_bridge.h +++ b/ui/base/ime/chromeos/ime_bridge.h @@ -106,6 +106,10 @@ class UI_BASE_IME_EXPORT IMEEngineHandlerInterface { // Called when the composition bounds changed. virtual void SetCompositionBounds(const std::vector<gfx::Rect>& bounds) = 0; + // Returns whether the engine is interested in key events. + // If not, InputMethodChromeOS won't feed it with key events. + virtual bool IsInterestedInKeyEvent() const = 0; + protected: IMEEngineHandlerInterface() {} }; diff --git a/ui/base/ime/chromeos/mock_ime_engine_handler.cc b/ui/base/ime/chromeos/mock_ime_engine_handler.cc index 5645494..867ef19 100644 --- a/ui/base/ime/chromeos/mock_ime_engine_handler.cc +++ b/ui/base/ime/chromeos/mock_ime_engine_handler.cc @@ -49,6 +49,10 @@ void MockIMEEngineHandler::Reset() { ++reset_call_count_; } +bool MockIMEEngineHandler::IsInterestedInKeyEvent() const { + return true; +} + void MockIMEEngineHandler::ProcessKeyEvent( const ui::KeyEvent& key_event, const KeyEventDoneCallback& callback) { diff --git a/ui/base/ime/chromeos/mock_ime_engine_handler.h b/ui/base/ime/chromeos/mock_ime_engine_handler.h index b37a62f..18d3d99 100644 --- a/ui/base/ime/chromeos/mock_ime_engine_handler.h +++ b/ui/base/ime/chromeos/mock_ime_engine_handler.h @@ -23,6 +23,7 @@ class UI_BASE_IME_EXPORT MockIMEEngineHandler void Disable() override; void PropertyActivate(const std::string& property_name) override; void Reset() override; + bool IsInterestedInKeyEvent() const override; void ProcessKeyEvent(const ui::KeyEvent& key_event, const KeyEventDoneCallback& callback) override; void CandidateClicked(uint32 index) override; diff --git a/ui/base/ime/input_method_chromeos.cc b/ui/base/ime/input_method_chromeos.cc index 0e29d8f..071a2df 100644 --- a/ui/base/ime/input_method_chromeos.cc +++ b/ui/base/ime/input_method_chromeos.cc @@ -69,7 +69,7 @@ bool InputMethodChromeOS::OnUntranslatedIMEMessage( return false; } -void InputMethodChromeOS::ProcessKeyEventDone(ui::KeyEvent* event, +void InputMethodChromeOS::ProcessKeyEventDone(const ui::KeyEvent* event, bool is_handled) { DCHECK(event); if (event->type() == ET_KEY_PRESSED) { @@ -129,13 +129,16 @@ bool InputMethodChromeOS::DispatchKeyEvent(const ui::KeyEvent& event) { return true; } - ui::KeyEvent* copied_event = new ui::KeyEvent(event); - GetEngine()->ProcessKeyEvent( - event, - base::Bind(&InputMethodChromeOS::ProcessKeyEventDone, - weak_ptr_factory_.GetWeakPtr(), - // Pass the ownership of |copied_event|. - base::Owned(copied_event))); + if (GetEngine()->IsInterestedInKeyEvent()) { + GetEngine()->ProcessKeyEvent( + event, + base::Bind(&InputMethodChromeOS::ProcessKeyEventDone, + weak_ptr_factory_.GetWeakPtr(), + // Pass the ownership of the new copied event. + base::Owned(new ui::KeyEvent(event)))); + } else { + ProcessKeyEventDone(&event, false); + } return true; } diff --git a/ui/base/ime/input_method_chromeos.h b/ui/base/ime/input_method_chromeos.h index c885e65..9879416 100644 --- a/ui/base/ime/input_method_chromeos.h +++ b/ui/base/ime/input_method_chromeos.h @@ -106,7 +106,7 @@ class UI_BASE_IME_EXPORT InputMethodChromeOS void HidePreeditText(); // Callback function for IMEEngineHandlerInterface::ProcessKeyEvent. - void ProcessKeyEventDone(ui::KeyEvent* event, bool is_handled); + void ProcessKeyEventDone(const ui::KeyEvent* event, bool is_handled); // Returns whether an non-password input field is focused. bool IsNonPasswordInputFieldFocused(); |