Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: chrome/browser/chromeos/input_method/input_method_engine_ibus.h

Issue 10834108: Replace InputMethodEngineIBus. (Closed) Base URL: http://git.chromium.org/chromium/src.git@input_method_engine_ibus
Patch Set: Fix wrong DCHECK and it's description Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_IBUS_H_
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_IBUS_H_
7
8 #include <string>
9 #include <vector>
10 #include <map>
11 #include "chrome/browser/chromeos/input_method/input_method_engine.h"
12 #include "chromeos/dbus/ibus/ibus_engine_factory_service.h"
13 #include "chromeos/dbus/ibus/ibus_engine_service.h"
14 #include "dbus/object_path.h"
15
16 namespace chromeos {
17
18 namespace ibus {
19 class IBusComponent;
20 class IBusLookupTable;
21 class IBusText;
22 }
23
24 class IBusEngineService;
25 namespace input_method {
26 struct KeyEventHandle;
27 } // namespace input_method
28
29 class InputMethodEngineIBus : public InputMethodEngine,
30 public IBusEngineHandlerInterface {
31 public:
32 InputMethodEngineIBus();
33
34 virtual ~InputMethodEngineIBus();
35
36 void Initialize(
37 InputMethodEngine::Observer* observer,
38 const char* engine_name,
39 const char* extension_id,
40 const char* engine_id,
41 const char* description,
42 const char* language,
43 const std::vector<std::string>& layouts,
44 std::string* error);
45
46 // InputMethodEngine override.
Zachary Kuznia 2012/08/07 06:41:04 You should only need this comment once for all the
Seigo Nonaka 2012/08/07 17:39:21 Done.
47 virtual bool SetComposition(int context_id,
48 const char* text,
49 int selection_start,
50 int selection_end,
51 int cursor,
52 const std::vector<SegmentInfo>& segments,
53 std::string* error) OVERRIDE;
54
55 // InputMethodEngine override.
56 virtual bool ClearComposition(int context_id, std::string* error) OVERRIDE;
57
58 // InputMethodEngine override.
59 virtual bool CommitText(int context_id, const char* text,
60 std::string* error) OVERRIDE;
61
62 // InputMethodEngine override.
63 virtual bool SetCandidateWindowVisible(bool visible,
64 std::string* error) OVERRIDE;
65
66 // InputMethodEngine override.
67 virtual void SetCandidateWindowCursorVisible(bool visible) OVERRIDE;
68
69 // InputMethodEngine override.
70 virtual void SetCandidateWindowVertical(bool vertical) OVERRIDE;
71
72 // InputMethodEngine override.
73 virtual void SetCandidateWindowPageSize(int size) OVERRIDE;
74
75 // InputMethodEngine override.
76 virtual void SetCandidateWindowAuxText(const char* text) OVERRIDE;
77
78 // InputMethodEngine override.
79 virtual void SetCandidateWindowAuxTextVisible(bool visible) OVERRIDE;
80
81 // InputMethodEngine override.
82 virtual bool SetCandidates(int context_id,
83 const std::vector<Candidate>& candidates,
84 std::string* error) OVERRIDE;
85
86 // InputMethodEngine override.
87 virtual bool SetCursorPosition(int context_id, int candidate_id,
88 std::string* error) OVERRIDE;
89
90 // InputMethodEngine override.
91 virtual bool SetMenuItems(const std::vector<MenuItem>& items) OVERRIDE;
92
93 // InputMethodEngine override.
94 virtual bool UpdateMenuItems(const std::vector<MenuItem>& items) OVERRIDE;
95
96 // InputMethodEngine override.
97 virtual bool IsActive() const OVERRIDE;
98
99 // InputMethodEngine override.
100 virtual void KeyEventDone(input_method::KeyEventHandle* key_data,
101 bool handled) OVERRIDE;
102
103 // IBusEngineHandlerInterface override.
Zachary Kuznia 2012/08/07 06:41:04 Ditto
Seigo Nonaka 2012/08/07 17:39:21 Done.
104 virtual void FocusIn() OVERRIDE;
105
106 // IBusEngineHandlerInterface override.
107 virtual void FocusOut() OVERRIDE;
108
109 // IBusEngineHandlerInterface override.
110 virtual void Enable() OVERRIDE;
111
112 // IBusEngineHandlerInterface override.
113 virtual void Disable() OVERRIDE;
114
115 // IBusEngineHandlerInterface override.
116 virtual void PropertyActivate(const std::string& property_name,
117 IBusPropertyState property_state) OVERRIDE;
118
119 // IBusEngineHandlerInterface override.
120 virtual void PropertyShow(const std::string& property_name) OVERRIDE;
121
122 // IBusEngineHandlerInterface override.
123 virtual void PropertyHide(const std::string& property_name) OVERRIDE;
124
125 // IBusEngineHandlerInterface override.
126 virtual void SetCapability(IBusCapability capability) OVERRIDE;
127
128 // IBusEngineHandlerInterface override.
129 virtual void Reset() OVERRIDE;
130
131 // IBusEngineHandlerInterface override.
132 virtual void ProcessKeyEvent(uint32 keysym, uint32 keycode, uint32 state,
133 const KeyEventDoneCallback& callback) OVERRIDE;
134
135 // IBusEngineHandlerInterface override.
136 virtual void CandidateClicked(uint32 index, IBusMouseButton button,
137 uint32 state) OVERRIDE;
138
139 // IBusEngineHandlerInterface override.
140 virtual void SetSurroundingText(const std::string& text, uint32 cursor_pos,
141 uint32 anchor_pos) OVERRIDE;
142
143 // Called when the connection with ibus-daemon is connected.
144 void OnConnected();
145
146 // Called whtn the connection with ibus-daemon is disconnected.
147 void OnDisconnected();
148
149 private:
150 // Returns true if the connection to ibus-daemon is avaiable.
151 bool IsConnected();
152
153 // Converts MenuItem to IBusProperty.
154 bool MenuItemToProperty(const MenuItem& item, ibus::IBusProperty* property);
155
156 // Registers the engine component.
157 void RegisterComponent();
158
159 // Called when the RegisterComponent is failed.
160 void OnComponentRegistrationFailed();
161
162 // Called when the RegisterComponent is succeeded.
163 void OnComponentRegistered();
164
165 // Called when the ibus-daemon sends CreateEngine message with corresponding
166 // engine id.
167 void CreateEngineHandler(
168 const IBusEngineFactoryService::CreateEngineResponseSender& sender);
169
170 // Returns current IBusEngineService, if there is no available service, this
171 // function returns NULL.
172 IBusEngineService* GetCurrentService();
173
174 // True if the current context has focus.
175 bool focused_;
176
177 // True if this engine is active.
178 bool active_;
179
180 // ID that is used for the current input context. False if there is no focus.
181 int context_id_;
182
183 // Next id that will be assigned to a context.
184 int next_context_id_;
185
186 // This IME ID in Chrome Extension.
187 std::string engine_id_;
188
189 // This IME ID in ibus.
190 std::string ibus_id_;
191
192 // The current object path and it's numerical id.
193 dbus::ObjectPath object_path_;
194 int current_object_path_;
195
196 // The current auxialy text and it's visiblity.
197 scoped_ptr<ibus::IBusText> aux_text_;
198 bool aux_text_visible_;
199
200 // Pointer to the object recieving events for this IME.
201 InputMethodEngine::Observer* observer_;
202
203 // The current preedit text, and it's cursor position.
204 scoped_ptr<ibus::IBusText> preedit_text_;
205 int preedit_cursor_;
206
207 // The current engine component.
208 scoped_ptr<ibus::IBusComponent> component_;
209
210 // The current lookup table and it's visiblity.
211 scoped_ptr<ibus::IBusLookupTable> table_;
212 bool table_visible_;
213
214 // Mapping of candidate index to candidate id.
215 std::vector<int> candidate_ids_;
216
217 // Mapping of candidate id to index.
218 std::map<int, int> candidate_indexes_;
219
220 // Used for making callbacks.
221 base::WeakPtrFactory<InputMethodEngineIBus> weak_ptr_factory_;
222 };
223
224 } // namespace chromeos
225
226 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_IBUS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698