OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // TODO(nona): Rename this file to ime_bridge.h | 4 // TODO(nona): Rename this file to ime_bridge.h |
5 | 5 |
6 #ifndef UI_BASE_IME_CHROMEOS_IBUS_BRIDGE_H_ | 6 #ifndef UI_BASE_IME_CHROMEOS_IBUS_BRIDGE_H_ |
7 #define UI_BASE_IME_CHROMEOS_IBUS_BRIDGE_H_ | 7 #define UI_BASE_IME_CHROMEOS_IBUS_BRIDGE_H_ |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "ui/base/ime/text_input_mode.h" | 12 #include "ui/base/ime/text_input_mode.h" |
13 #include "ui/base/ime/text_input_type.h" | 13 #include "ui/base/ime/text_input_type.h" |
14 #include "ui/base/ui_export.h" | 14 #include "ui/base/ui_base_export.h" |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 class Rect; | 17 class Rect; |
18 } // namespace gfx | 18 } // namespace gfx |
19 | 19 |
20 namespace ui { | 20 namespace ui { |
21 class KeyEvent; | 21 class KeyEvent; |
22 } // namespace ui | 22 } // namespace ui |
23 | 23 |
24 namespace chromeos { | 24 namespace chromeos { |
25 namespace input_method { | 25 namespace input_method { |
26 class CandidateWindow; | 26 class CandidateWindow; |
27 } // namespace input_method | 27 } // namespace input_method |
28 | 28 |
29 class IBusText; | 29 class IBusText; |
30 | 30 |
31 class UI_EXPORT IBusInputContextHandlerInterface { | 31 class UI_BASE_EXPORT IBusInputContextHandlerInterface { |
32 public: | 32 public: |
33 // Called when the engine commit a text. | 33 // Called when the engine commit a text. |
34 virtual void CommitText(const std::string& text) = 0; | 34 virtual void CommitText(const std::string& text) = 0; |
35 | 35 |
36 // Called when the engine update preedit stroing. | 36 // Called when the engine update preedit stroing. |
37 virtual void UpdatePreeditText(const IBusText& text, | 37 virtual void UpdatePreeditText(const IBusText& text, |
38 uint32 cursor_pos, | 38 uint32 cursor_pos, |
39 bool visible) = 0; | 39 bool visible) = 0; |
40 | 40 |
41 // Called when the engine request deleting surrounding string. | 41 // Called when the engine request deleting surrounding string. |
42 virtual void DeleteSurroundingText(int32 offset, uint32 length) = 0; | 42 virtual void DeleteSurroundingText(int32 offset, uint32 length) = 0; |
43 }; | 43 }; |
44 | 44 |
45 | 45 |
46 // A interface to handle the engine handler method call. | 46 // A interface to handle the engine handler method call. |
47 class UI_EXPORT IBusEngineHandlerInterface { | 47 class UI_BASE_EXPORT IBusEngineHandlerInterface { |
48 public: | 48 public: |
49 typedef base::Callback<void (bool consumed)> KeyEventDoneCallback; | 49 typedef base::Callback<void (bool consumed)> KeyEventDoneCallback; |
50 | 50 |
51 // A information about a focused text input field. | 51 // A information about a focused text input field. |
52 // A type of each member is based on the html spec, but InputContext can be | 52 // A type of each member is based on the html spec, but InputContext can be |
53 // used to specify about a non html text field like Omnibox. | 53 // used to specify about a non html text field like Omnibox. |
54 struct InputContext { | 54 struct InputContext { |
55 InputContext(ui::TextInputType type_, ui::TextInputMode mode_) : | 55 InputContext(ui::TextInputType type_, ui::TextInputMode mode_) : |
56 type(type_), mode(mode_) {} | 56 type(type_), mode(mode_) {} |
57 | 57 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // selection range, |anchor_pos| represents opposite index from |cursor_pos|. | 99 // selection range, |anchor_pos| represents opposite index from |cursor_pos|. |
100 // Otherwise |anchor_pos| is equal to |cursor_pos|. | 100 // Otherwise |anchor_pos| is equal to |cursor_pos|. |
101 virtual void SetSurroundingText(const std::string& text, uint32 cursor_pos, | 101 virtual void SetSurroundingText(const std::string& text, uint32 cursor_pos, |
102 uint32 anchor_pos) = 0; | 102 uint32 anchor_pos) = 0; |
103 | 103 |
104 protected: | 104 protected: |
105 IBusEngineHandlerInterface() {} | 105 IBusEngineHandlerInterface() {} |
106 }; | 106 }; |
107 | 107 |
108 // A interface to handle the candidate window related method call. | 108 // A interface to handle the candidate window related method call. |
109 class UI_EXPORT IBusPanelCandidateWindowHandlerInterface { | 109 class UI_BASE_EXPORT IBusPanelCandidateWindowHandlerInterface { |
110 public: | 110 public: |
111 virtual ~IBusPanelCandidateWindowHandlerInterface() {} | 111 virtual ~IBusPanelCandidateWindowHandlerInterface() {} |
112 | 112 |
113 // Called when the IME updates the lookup table. | 113 // Called when the IME updates the lookup table. |
114 virtual void UpdateLookupTable( | 114 virtual void UpdateLookupTable( |
115 const input_method::CandidateWindow& candidate_window, | 115 const input_method::CandidateWindow& candidate_window, |
116 bool visible) = 0; | 116 bool visible) = 0; |
117 | 117 |
118 // Called when the IME updates the preedit text. The |text| is given in | 118 // Called when the IME updates the preedit text. The |text| is given in |
119 // UTF-8 encoding. | 119 // UTF-8 encoding. |
120 virtual void UpdatePreeditText(const std::string& text, uint32 cursor_pos, | 120 virtual void UpdatePreeditText(const std::string& text, uint32 cursor_pos, |
121 bool visible) = 0; | 121 bool visible) = 0; |
122 | 122 |
123 // Called when the application changes its caret bounds. | 123 // Called when the application changes its caret bounds. |
124 virtual void SetCursorBounds(const gfx::Rect& cursor_bounds, | 124 virtual void SetCursorBounds(const gfx::Rect& cursor_bounds, |
125 const gfx::Rect& composition_head) = 0; | 125 const gfx::Rect& composition_head) = 0; |
126 | 126 |
127 // Called when the text field's focus state is changed. | 127 // Called when the text field's focus state is changed. |
128 // |is_focused| is true when the text field gains the focus. | 128 // |is_focused| is true when the text field gains the focus. |
129 virtual void FocusStateChanged(bool is_focused) {} | 129 virtual void FocusStateChanged(bool is_focused) {} |
130 | 130 |
131 protected: | 131 protected: |
132 IBusPanelCandidateWindowHandlerInterface() {} | 132 IBusPanelCandidateWindowHandlerInterface() {} |
133 }; | 133 }; |
134 | 134 |
135 | 135 |
136 // IBusBridge provides access of each IME related handler. This class | 136 // IBusBridge provides access of each IME related handler. This class |
137 // is used for IME implementation. | 137 // is used for IME implementation. |
138 class UI_EXPORT IBusBridge { | 138 class UI_BASE_EXPORT IBusBridge { |
139 public: | 139 public: |
140 virtual ~IBusBridge(); | 140 virtual ~IBusBridge(); |
141 | 141 |
142 // Allocates the global instance. Must be called before any calls to Get(). | 142 // Allocates the global instance. Must be called before any calls to Get(). |
143 static void Initialize(); | 143 static void Initialize(); |
144 | 144 |
145 // Releases the global instance. | 145 // Releases the global instance. |
146 static void Shutdown(); | 146 static void Shutdown(); |
147 | 147 |
148 // Returns IBusBridge global instance. Initialize() must be called first. | 148 // Returns IBusBridge global instance. Initialize() must be called first. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 protected: | 195 protected: |
196 IBusBridge(); | 196 IBusBridge(); |
197 | 197 |
198 private: | 198 private: |
199 DISALLOW_COPY_AND_ASSIGN(IBusBridge); | 199 DISALLOW_COPY_AND_ASSIGN(IBusBridge); |
200 }; | 200 }; |
201 | 201 |
202 } // namespace chromeos | 202 } // namespace chromeos |
203 | 203 |
204 #endif // UI_BASE_IME_CHROMEOS_IBUS_BRIDGE_H_ | 204 #endif // UI_BASE_IME_CHROMEOS_IBUS_BRIDGE_H_ |
OLD | NEW |