| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_INPUT_METHOD_BASE_H_ | 5 #ifndef UI_BASE_IME_INPUT_METHOD_BASE_H_ |
| 6 #define UI_BASE_IME_INPUT_METHOD_BASE_H_ | 6 #define UI_BASE_IME_INPUT_METHOD_BASE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "ui/base/ime/ime_input_context_handler_interface.h" |
| 14 #include "ui/base/ime/input_method.h" | 15 #include "ui/base/ime/input_method.h" |
| 15 #include "ui/base/ime/ui_base_ime_export.h" | 16 #include "ui/base/ime/ui_base_ime_export.h" |
| 16 #include "ui/events/event_dispatcher.h" | 17 #include "ui/events/event_dispatcher.h" |
| 17 | 18 |
| 18 namespace gfx { | 19 namespace gfx { |
| 19 class Rect; | 20 class Rect; |
| 20 } // namespace gfx | 21 } // namespace gfx |
| 21 | 22 |
| 22 namespace ui { | 23 namespace ui { |
| 23 | 24 |
| 24 class InputMethodObserver; | 25 class InputMethodObserver; |
| 25 class KeyEvent; | 26 class KeyEvent; |
| 26 class TextInputClient; | 27 class TextInputClient; |
| 27 | 28 |
| 28 // A helper class providing functionalities shared among ui::InputMethod | 29 // A helper class providing functionalities shared among ui::InputMethod |
| 29 // implementations. | 30 // implementations. |
| 30 class UI_BASE_IME_EXPORT InputMethodBase | 31 class UI_BASE_IME_EXPORT InputMethodBase |
| 31 : NON_EXPORTED_BASE(public InputMethod), | 32 : NON_EXPORTED_BASE(public InputMethod), |
| 32 public base::SupportsWeakPtr<InputMethodBase> { | 33 public base::SupportsWeakPtr<InputMethodBase>, |
| 34 public IMEInputContextHandlerInterface { |
| 33 public: | 35 public: |
| 34 InputMethodBase(); | 36 InputMethodBase(); |
| 35 ~InputMethodBase() override; | 37 ~InputMethodBase() override; |
| 36 | 38 |
| 37 // Overriden from InputMethod. | 39 // Overriden from InputMethod. |
| 38 void SetDelegate(internal::InputMethodDelegate* delegate) override; | 40 void SetDelegate(internal::InputMethodDelegate* delegate) override; |
| 39 void OnFocus() override; | 41 void OnFocus() override; |
| 40 void OnBlur() override; | 42 void OnBlur() override; |
| 41 void SetFocusedTextInputClient(TextInputClient* client) override; | 43 void SetFocusedTextInputClient(TextInputClient* client) override; |
| 42 void DetachTextInputClient(TextInputClient* client) override; | 44 void DetachTextInputClient(TextInputClient* client) override; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 54 | 56 |
| 55 void AddObserver(InputMethodObserver* observer) override; | 57 void AddObserver(InputMethodObserver* observer) override; |
| 56 void RemoveObserver(InputMethodObserver* observer) override; | 58 void RemoveObserver(InputMethodObserver* observer) override; |
| 57 | 59 |
| 58 protected: | 60 protected: |
| 59 virtual void OnWillChangeFocusedClient(TextInputClient* focused_before, | 61 virtual void OnWillChangeFocusedClient(TextInputClient* focused_before, |
| 60 TextInputClient* focused) {} | 62 TextInputClient* focused) {} |
| 61 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before, | 63 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before, |
| 62 TextInputClient* focused) {} | 64 TextInputClient* focused) {} |
| 63 | 65 |
| 66 // IMEInputContextHandlerInterface: |
| 67 void CommitText(const std::string& text) override; |
| 68 void UpdateCompositionText(const CompositionText& text, |
| 69 uint32_t cursor_pos, |
| 70 bool visible) override; |
| 71 void DeleteSurroundingText(int32_t offset, uint32_t length) override; |
| 72 |
| 73 // Sends a fake key event for IME composing without physical key events. |
| 74 // Returns true if the faked key event is stopped propagation. |
| 75 bool SendFakeProcessKeyEvent(bool pressed) const; |
| 76 |
| 64 // Returns true if |client| is currently focused. | 77 // Returns true if |client| is currently focused. |
| 65 bool IsTextInputClientFocused(const TextInputClient* client); | 78 bool IsTextInputClientFocused(const TextInputClient* client); |
| 66 | 79 |
| 67 // Checks if the focused text input client's text input type is | 80 // Checks if the focused text input client's text input type is |
| 68 // TEXT_INPUT_TYPE_NONE. Also returns true if there is no focused text | 81 // TEXT_INPUT_TYPE_NONE. Also returns true if there is no focused text |
| 69 // input client. | 82 // input client. |
| 70 bool IsTextInputTypeNone() const; | 83 bool IsTextInputTypeNone() const; |
| 71 | 84 |
| 72 // Convenience method to call the focused text input client's | 85 // Convenience method to call the focused text input client's |
| 73 // OnInputMethodChanged() method. It'll only take effect if the current text | 86 // OnInputMethodChanged() method. It'll only take effect if the current text |
| (...skipping 22 matching lines...) Expand all Loading... |
| 96 TextInputClient* text_input_client_; | 109 TextInputClient* text_input_client_; |
| 97 | 110 |
| 98 base::ObserverList<InputMethodObserver> observer_list_; | 111 base::ObserverList<InputMethodObserver> observer_list_; |
| 99 | 112 |
| 100 DISALLOW_COPY_AND_ASSIGN(InputMethodBase); | 113 DISALLOW_COPY_AND_ASSIGN(InputMethodBase); |
| 101 }; | 114 }; |
| 102 | 115 |
| 103 } // namespace ui | 116 } // namespace ui |
| 104 | 117 |
| 105 #endif // UI_BASE_IME_INPUT_METHOD_BASE_H_ | 118 #endif // UI_BASE_IME_INPUT_METHOD_BASE_H_ |
| OLD | NEW |