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

Side by Side Diff: chrome/browser/ui/input_method/input_method_engine.cc

Issue 1657593007: Implement chrome.input.ime.setComposition/commitText API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use Xxx::Results::Create(). 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 #include "chrome/browser/ui/input_method/input_method_engine.h" 5 #include "chrome/browser/ui/input_method/input_method_engine.h"
6 6
7 #include "ui/base/ime/composition_text.h"
8 #include "ui/base/ime/ime_bridge.h"
9 #include "ui/base/ime/ime_input_context_handler_interface.h"
10
7 namespace input_method { 11 namespace input_method {
8 12
9 InputMethodEngine::InputMethodEngine() {} 13 InputMethodEngine::InputMethodEngine() {}
10 14
11 InputMethodEngine::~InputMethodEngine() {} 15 InputMethodEngine::~InputMethodEngine() {}
12 16
13 bool InputMethodEngine::SendKeyEvents( 17 bool InputMethodEngine::SendKeyEvents(
14 int context_id, 18 int context_id,
15 const std::vector<KeyboardEvent>& events) { 19 const std::vector<KeyboardEvent>& events) {
16 // TODO(azurewei) Implement SendKeyEvents funciton 20 // TODO(azurewei) Implement SendKeyEvents funciton
17 return false; 21 return false;
18 } 22 }
19 23
20 bool InputMethodEngine::IsActive() const { 24 bool InputMethodEngine::IsActive() const {
21 return true; 25 return true;
22 } 26 }
23 27
24 std::string InputMethodEngine::GetExtensionId() const { 28 std::string InputMethodEngine::GetExtensionId() const {
25 return extension_id_; 29 return extension_id_;
26 } 30 }
27 31
32 void InputMethodEngine::UpdateComposition(
33 const ui::CompositionText& composition_text,
34 uint32_t cursor_pos,
35 bool is_visible) {
36 composition_.CopyFrom(composition_text);
37
38 // Use a black thin underline by default.
39 if (composition_.underlines.empty()) {
40 composition_.underlines.push_back(
41 ui::CompositionUnderline(0, composition_.text.length(), SK_ColorBLACK,
42 false /* thick */, SK_ColorTRANSPARENT));
43 }
44
45 ui::IMEInputContextHandlerInterface* input_context =
46 ui::IMEBridge::Get()->GetInputContextHandler();
47 // If the IME extension is handling key event, hold the composition text
48 // until the key event is handled.
49 if (input_context && !handling_key_event_) {
50 input_context->UpdateCompositionText(composition_text, cursor_pos,
51 is_visible);
52 composition_.Clear();
53 }
54 }
55
56 void InputMethodEngine::CommitTextToInputContext(int context_id,
57 const std::string& text) {
58 // Append the text to the buffer, as it allows committing text multiple times
59 // when processing a key event.
60 text_ += text;
61
62 ui::IMEInputContextHandlerInterface* input_context =
63 ui::IMEBridge::Get()->GetInputContextHandler();
64 // If the IME extension is handling key event, hold the text until the key
65 // event is handled.
66 if (input_context && !handling_key_event_) {
67 input_context->CommitText(text_);
68 text_ = "";
69 }
70 }
71
28 } // namespace input_method 72 } // namespace input_method
OLDNEW
« no previous file with comments | « chrome/browser/ui/input_method/input_method_engine.h ('k') | chrome/browser/ui/input_method/input_method_engine_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698