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_H_ | 5 #ifndef UI_BASE_IME_INPUT_METHOD_H_ |
6 #define UI_BASE_IME_INPUT_METHOD_H_ | 6 #define UI_BASE_IME_INPUT_METHOD_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
| 11 #include <vector> |
11 | 12 |
12 #include "base/event_types.h" | 13 #include "base/event_types.h" |
| 14 #include "base/memory/scoped_vector.h" |
13 #include "build/build_config.h" | 15 #include "build/build_config.h" |
14 #include "ui/base/ime/text_input_mode.h" | 16 #include "ui/base/ime/text_input_mode.h" |
15 #include "ui/base/ime/text_input_type.h" | 17 #include "ui/base/ime/text_input_type.h" |
16 | 18 |
| 19 namespace extensions { |
| 20 class InputImeApiTest; |
| 21 } // namespace extensions |
| 22 |
17 namespace ui { | 23 namespace ui { |
18 | 24 |
19 namespace internal { | 25 namespace internal { |
20 class InputMethodDelegate; | 26 class InputMethodDelegate; |
21 } // namespace internal | 27 } // namespace internal |
22 | 28 |
23 class InputMethodObserver; | 29 class InputMethodObserver; |
24 class KeyEvent; | 30 class KeyEvent; |
25 class TextInputClient; | 31 class TextInputClient; |
26 | 32 |
(...skipping 14 matching lines...) Expand all Loading... |
41 // 2) Send VKEY_PROCESSKEY event to the window using the DispatchKeyEvent API, | 47 // 2) Send VKEY_PROCESSKEY event to the window using the DispatchKeyEvent API, |
42 // then update IME status (e.g. composition text) using TextInputClient, | 48 // then update IME status (e.g. composition text) using TextInputClient, |
43 // and then send the original key up event to the window. | 49 // and then send the original key up event to the window. |
44 // - Keeps track of the focused TextInputClient to see which client can call | 50 // - Keeps track of the focused TextInputClient to see which client can call |
45 // APIs, OnTextInputTypeChanged, OnCaretBoundsChanged, and CancelComposition, | 51 // APIs, OnTextInputTypeChanged, OnCaretBoundsChanged, and CancelComposition, |
46 // that change the state of the input method. | 52 // that change the state of the input method. |
47 // In Aura environment, aura::WindowTreeHost creates an instance of | 53 // In Aura environment, aura::WindowTreeHost creates an instance of |
48 // ui::InputMethod and owns it. | 54 // ui::InputMethod and owns it. |
49 class InputMethod { | 55 class InputMethod { |
50 public: | 56 public: |
| 57 InputMethod() : track_key_events_for_testing_(false) {} |
51 | 58 |
52 #if defined(OS_WIN) | 59 #if defined(OS_WIN) |
53 typedef LRESULT NativeEventResult; | 60 typedef LRESULT NativeEventResult; |
54 #else | 61 #else |
55 typedef int32_t NativeEventResult; | 62 typedef int32_t NativeEventResult; |
56 #endif | 63 #endif |
57 | 64 |
58 virtual ~InputMethod() {} | 65 virtual ~InputMethod() {} |
59 | 66 |
60 // Sets the delegate used by this InputMethod instance. It should only be | 67 // Sets the delegate used by this InputMethod instance. It should only be |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // etc.) is open. Returns false if no popup window is open or the detection | 152 // etc.) is open. Returns false if no popup window is open or the detection |
146 // of IME popups is not supported. | 153 // of IME popups is not supported. |
147 virtual bool IsCandidatePopupOpen() const = 0; | 154 virtual bool IsCandidatePopupOpen() const = 0; |
148 | 155 |
149 // Displays an on screen keyboard if enabled. | 156 // Displays an on screen keyboard if enabled. |
150 virtual void ShowImeIfNeeded() = 0; | 157 virtual void ShowImeIfNeeded() = 0; |
151 | 158 |
152 // Management of the observer list. | 159 // Management of the observer list. |
153 virtual void AddObserver(InputMethodObserver* observer) = 0; | 160 virtual void AddObserver(InputMethodObserver* observer) = 0; |
154 virtual void RemoveObserver(InputMethodObserver* observer) = 0; | 161 virtual void RemoveObserver(InputMethodObserver* observer) = 0; |
| 162 |
| 163 protected: |
| 164 friend class extensions::InputImeApiTest; |
| 165 |
| 166 // Gets the tracked key events of using input.ime.sendKeyEvents API. |
| 167 virtual const std::vector<std::unique_ptr<ui::KeyEvent>>& |
| 168 GetKeyEventsForTesting() = 0; |
| 169 |
| 170 // Whether the key events will be tracked. Only used for testing. |
| 171 bool track_key_events_for_testing_; |
155 }; | 172 }; |
156 | 173 |
157 } // namespace ui | 174 } // namespace ui |
158 | 175 |
159 #endif // UI_BASE_IME_INPUT_METHOD_H_ | 176 #endif // UI_BASE_IME_INPUT_METHOD_H_ |
OLD | NEW |