| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_BASE_IME_IME_ENGINE_OBSERVER_H_ | 5 #ifndef UI_BASE_IME_IME_ENGINE_OBSERVER_H_ |
| 6 #define UI_BASE_IME_IME_ENGINE_OBSERVER_H_ | 6 #define UI_BASE_IME_IME_ENGINE_OBSERVER_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "ui/base/ime/ime_engine_handler_interface.h" | 9 #include "ui/base/ime/ime_engine_handler_interface.h" |
| 10 | 10 |
| 11 namespace ui { | 11 namespace ui { |
| 12 | 12 |
| 13 class IMEEngineObserver { | 13 class IMEEngineObserver { |
| 14 public: | 14 public: |
| 15 virtual ~IMEEngineObserver() {} | 15 virtual ~IMEEngineObserver() {} |
| 16 | 16 |
| 17 // Called when the IME becomes the active IME. |
| 18 virtual void OnActivate(const std::string& engine_id) = 0; |
| 19 |
| 17 // Called when a text field gains focus, and will be sending key events. | 20 // Called when a text field gains focus, and will be sending key events. |
| 18 virtual void OnFocus( | 21 virtual void OnFocus( |
| 19 const IMEEngineHandlerInterface::InputContext& context) = 0; | 22 const IMEEngineHandlerInterface::InputContext& context) = 0; |
| 20 | 23 |
| 21 // Called when a text field loses focus, and will no longer generate events. | 24 // Called when a text field loses focus, and will no longer generate events. |
| 22 virtual void OnBlur(int context_id) = 0; | 25 virtual void OnBlur(int context_id) = 0; |
| 23 | 26 |
| 24 // Called when the user pressed a key with a text field focused. | 27 // Called when the user pressed a key with a text field focused. |
| 25 virtual void OnKeyEvent( | 28 virtual void OnKeyEvent( |
| 26 const std::string& engine_id, | 29 const std::string& engine_id, |
| 27 const IMEEngineHandlerInterface::KeyboardEvent& event, | 30 const IMEEngineHandlerInterface::KeyboardEvent& event, |
| 28 IMEEngineHandlerInterface::KeyEventDoneCallback& key_data) = 0; | 31 IMEEngineHandlerInterface::KeyEventDoneCallback& key_data) = 0; |
| 29 | 32 |
| 30 // Called when Chrome terminates on-going text input session. | 33 // Called when Chrome terminates on-going text input session. |
| 31 virtual void OnReset(const std::string& engine_id) = 0; | 34 virtual void OnReset(const std::string& engine_id) = 0; |
| 32 | 35 |
| 33 // Called when the IME is no longer active. | 36 // Called when the IME is no longer active. |
| 34 virtual void OnDeactivated(const std::string& engine_id) = 0; | 37 virtual void OnDeactivated(const std::string& engine_id) = 0; |
| 35 | 38 |
| 36 // Called when composition bounds are changed. | 39 // Called when composition bounds are changed. |
| 37 virtual void OnCompositionBoundsChanged( | 40 virtual void OnCompositionBoundsChanged( |
| 38 const std::vector<gfx::Rect>& bounds) = 0; | 41 const std::vector<gfx::Rect>& bounds) = 0; |
| 39 | 42 |
| 43 // Returns whether the observer is interested in key events. |
| 44 virtual bool IsInterestedInKeyEvent() const = 0; |
| 45 |
| 46 // Called when a surrounding text is changed. |
| 47 virtual void OnSurroundingTextChanged(const std::string& engine_id, |
| 48 const std::string& text, |
| 49 int cursor_pos, |
| 50 int anchor_pos, |
| 51 int offset_pos) = 0; |
| 52 |
| 40 // ChromeOS only APIs. | 53 // ChromeOS only APIs. |
| 41 #if defined(OS_CHROMEOS) | 54 #if defined(OS_CHROMEOS) |
| 42 | 55 |
| 43 enum MouseButtonEvent { | 56 enum MouseButtonEvent { |
| 44 MOUSE_BUTTON_LEFT, | 57 MOUSE_BUTTON_LEFT, |
| 45 MOUSE_BUTTON_RIGHT, | 58 MOUSE_BUTTON_RIGHT, |
| 46 MOUSE_BUTTON_MIDDLE, | 59 MOUSE_BUTTON_MIDDLE, |
| 47 }; | 60 }; |
| 48 | 61 |
| 49 // Called when the IME becomes the active IME. | |
| 50 virtual void OnActivate(const std::string& engine_id) = 0; | |
| 51 | |
| 52 // Called when an InputContext's properties change while it is focused. | 62 // Called when an InputContext's properties change while it is focused. |
| 53 virtual void OnInputContextUpdate( | 63 virtual void OnInputContextUpdate( |
| 54 const IMEEngineHandlerInterface::InputContext& context) = 0; | 64 const IMEEngineHandlerInterface::InputContext& context) = 0; |
| 55 | 65 |
| 56 // Returns whether the observer is interested in key events. | 66 |
| 57 virtual bool IsInterestedInKeyEvent() const = 0; | |
| 58 | 67 |
| 59 // Called when the user clicks on an item in the candidate list. | 68 // Called when the user clicks on an item in the candidate list. |
| 60 virtual void OnCandidateClicked(const std::string& engine_id, | 69 virtual void OnCandidateClicked(const std::string& engine_id, |
| 61 int candidate_id, | 70 int candidate_id, |
| 62 MouseButtonEvent button) = 0; | 71 MouseButtonEvent button) = 0; |
| 63 | 72 |
| 64 // Called when a menu item for this IME is interacted with. | 73 // Called when a menu item for this IME is interacted with. |
| 65 virtual void OnMenuItemActivated(const std::string& engine_id, | 74 virtual void OnMenuItemActivated(const std::string& engine_id, |
| 66 const std::string& menu_id) = 0; | 75 const std::string& menu_id) = 0; |
| 67 | |
| 68 // Called when a surrounding text is changed. | |
| 69 virtual void OnSurroundingTextChanged(const std::string& engine_id, | |
| 70 const std::string& text, | |
| 71 int cursor_pos, | |
| 72 int anchor_pos, | |
| 73 int offset_pos) = 0; | |
| 74 #endif | 76 #endif |
| 75 }; | 77 }; |
| 76 | 78 |
| 77 } // namespace ui | 79 } // namespace ui |
| 78 | 80 |
| 79 #endif // UI_BASE_IME_IME_ENGINE_OBSERVER_H_ | 81 #endif // UI_BASE_IME_IME_ENGINE_OBSERVER_H_ |
| OLD | NEW |