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

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: Checkout InputImeEventRouter. 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
48 if (!handling_key_event_ && input_context) {
49 input_context->UpdateCompositionText(composition_text, cursor_pos,
50 is_visible);
51 composition_.Clear();
52 }
53 }
54
55 void InputMethodEngine::CommitTextToInputContext(int context_id,
56 const char* text) {
57 text_ += std::string(text);
58
59 ui::IMEInputContextHandlerInterface* input_context =
60 ui::IMEBridge::Get()->GetInputContextHandler();
61
62 if (!handling_key_event_ && input_context) {
63 input_context->CommitText(text_.c_str());
64 text_ = "";
65 }
66 }
67
28 } // namespace input_method 68 } // namespace input_method
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698