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

Side by Side Diff: chrome/browser/ui/input_method/input_method_engine_base.h

Issue 1657593007: Implement chrome.input.ime.setComposition/commitText API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Devlin's comments. Created 4 years, 10 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_ 5 #ifndef CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_
6 #define CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_ 6 #define CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "ui/base/ime/chromeos/input_method_descriptor.h" 12 #include "ui/base/ime/chromeos/input_method_descriptor.h"
13 #include "ui/base/ime/composition_text.h"
13 #include "ui/base/ime/ime_engine_handler_interface.h" 14 #include "ui/base/ime/ime_engine_handler_interface.h"
14 #include "url/gurl.h" 15 #include "url/gurl.h"
15 16
16 class Profile; 17 class Profile;
17 18
18 namespace ui { 19 namespace ui {
19 struct CompositionText; 20 struct CompositionText;
20 class IMEEngineHandlerInterface; 21 class IMEEngineHandlerInterface;
21 class KeyEvent; 22 class KeyEvent;
22 } // namespace ui 23 } // namespace ui
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 159
159 // Set the current composition and associated properties. 160 // Set the current composition and associated properties.
160 bool SetComposition(int context_id, 161 bool SetComposition(int context_id,
161 const char* text, 162 const char* text,
162 int selection_start, 163 int selection_start,
163 int selection_end, 164 int selection_end,
164 int cursor, 165 int cursor,
165 const std::vector<SegmentInfo>& segments, 166 const std::vector<SegmentInfo>& segments,
166 std::string* error); 167 std::string* error);
167 168
169 // Called when a key event is handled.
170 void KeyEventHandled();
171
168 protected: 172 protected:
173 // Notifies InputContextHandler that the composition is changed.
174 virtual void UpdateComposition(const ui::CompositionText& composition_text,
175 uint32_t cursor_pos,
176 bool is_visible) = 0;
177 // Notifies InputContextHanlder to commit |text|.
178 virtual void CommitTextToInputContext(int context_id,
179 const std::string& text) = 0;
180
169 ui::TextInputType current_input_type_; 181 ui::TextInputType current_input_type_;
170 182
171 // ID that is used for the current input context. False if there is no focus. 183 // ID that is used for the current input context. False if there is no focus.
172 int context_id_; 184 int context_id_;
173 185
174 // Next id that will be assigned to a context. 186 // Next id that will be assigned to a context.
175 int next_context_id_; 187 int next_context_id_;
176 188
177 // The input_component ID in IME extension's manifest. 189 // The input_component ID in IME extension's manifest.
178 std::string active_component_id_; 190 std::string active_component_id_;
179 191
180 // The IME extension ID. 192 // The IME extension ID.
181 std::string extension_id_; 193 std::string extension_id_;
182 194
183 // The observer object recieving events for this IME. 195 // The observer object recieving events for this IME.
184 scoped_ptr<InputMethodEngineBase::Observer> observer_; 196 scoped_ptr<InputMethodEngineBase::Observer> observer_;
185 197
186 // The current preedit text, and it's cursor position. 198 // The current preedit text, and it's cursor position.
187 scoped_ptr<ui::CompositionText> composition_text_; 199 scoped_ptr<ui::CompositionText> composition_text_;
188 int composition_cursor_; 200 int composition_cursor_;
189 201
190 // Used with SendKeyEvents and ProcessKeyEvent to check if the key event 202 // Used with SendKeyEvents and ProcessKeyEvent to check if the key event
191 // sent to ProcessKeyEvent is sent by SendKeyEvents. 203 // sent to ProcessKeyEvent is sent by SendKeyEvents.
192 const ui::KeyEvent* sent_key_event_; 204 const ui::KeyEvent* sent_key_event_;
193 205
194 Profile* profile_; 206 Profile* profile_;
207
208 // The composition text to be set from calling input.ime.setComposition API.
209 ui::CompositionText composition_;
210
211 // The text to be committed from calling input.ime.commitText API.
212 std::string text_;
213
214 // Indicates whether the IME extension is currently handling a physical key
215 // event. This is used in CommitText/UpdateCompositionText/etc.
216 bool handling_key_event_;
195 }; 217 };
196 218
197 } // namespace input_method 219 } // namespace input_method
198 220
199 #endif // CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_ 221 #endif // CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698