Index: chrome/browser/ui/input_method/input_method_engine.cc |
diff --git a/chrome/browser/ui/input_method/input_method_engine.cc b/chrome/browser/ui/input_method/input_method_engine.cc |
index a03580c9e03f21aaf2031c240011098ed4d96ef6..f1c5e8e017c137b53925cf0bd43bd0523cba56a6 100644 |
--- a/chrome/browser/ui/input_method/input_method_engine.cc |
+++ b/chrome/browser/ui/input_method/input_method_engine.cc |
@@ -4,6 +4,10 @@ |
#include "chrome/browser/ui/input_method/input_method_engine.h" |
+#include "ui/base/ime/composition_text.h" |
+#include "ui/base/ime/ime_bridge.h" |
+#include "ui/base/ime/ime_input_context_handler_interface.h" |
+ |
namespace input_method { |
InputMethodEngine::InputMethodEngine() {} |
@@ -25,4 +29,44 @@ std::string InputMethodEngine::GetExtensionId() const { |
return extension_id_; |
} |
+void InputMethodEngine::UpdateComposition( |
+ const ui::CompositionText& composition_text, |
+ uint32_t cursor_pos, |
+ bool is_visible) { |
+ composition_.CopyFrom(composition_text); |
+ |
+ // Use a black thin underline by default. |
+ if (composition_.underlines.empty()) { |
+ composition_.underlines.push_back( |
+ ui::CompositionUnderline(0, composition_.text.length(), SK_ColorBLACK, |
+ false /* thick */, SK_ColorTRANSPARENT)); |
+ } |
+ |
+ ui::IMEInputContextHandlerInterface* input_context = |
+ ui::IMEBridge::Get()->GetInputContextHandler(); |
+ // If the IME extension is handling key event, hold the composition text |
+ // until the key event is handled. |
+ if (input_context && !handling_key_event_) { |
+ input_context->UpdateCompositionText(composition_text, cursor_pos, |
+ is_visible); |
+ composition_.Clear(); |
+ } |
+} |
+ |
+void InputMethodEngine::CommitTextToInputContext(int context_id, |
+ const std::string& text) { |
+ // Append the text to the buffer, as it allows committing text multiple times |
+ // when processing a key event. |
+ text_ += text; |
+ |
+ ui::IMEInputContextHandlerInterface* input_context = |
+ ui::IMEBridge::Get()->GetInputContextHandler(); |
+ // If the IME extension is handling key event, hold the text until the key |
+ // event is handled. |
+ if (input_context && !handling_key_event_) { |
+ input_context->CommitText(text_); |
+ text_ = ""; |
+ } |
+} |
+ |
} // namespace input_method |