Chromium Code Reviews| Index: chrome/browser/chromeos/input_method/input_method_engine.cc |
| diff --git a/chrome/browser/chromeos/input_method/input_method_engine.cc b/chrome/browser/chromeos/input_method/input_method_engine.cc |
| index b9859db24ba612f3b8ff8ceced68b4a4a5083536..c47787677a38f3818bfd646ead917115695d165c 100644 |
| --- a/chrome/browser/chromeos/input_method/input_method_engine.cc |
| +++ b/chrome/browser/chromeos/input_method/input_method_engine.cc |
| @@ -53,6 +53,19 @@ const char kCandidateNotFound[] = "Candidate not found"; |
| // The default entry number of a page in CandidateWindowProperty. |
| const int kDefaultPageSize = 9; |
| +// Returns the length of characters of a UTF-8 string with unknown string |
| +// length. Cannot apply faster algorithm to count characters in an utf-8 |
| +// string without knowing the string length, so just does a full scan. |
| +size_t GetUtf8StringLength(const char* s) { |
|
Devlin
2016/02/04 00:09:17
Is this *really* that much faster than std::string
Azure Wei
2016/02/04 03:21:19
Abandoned these codes.
|
| + size_t ret = 0; |
| + while (*s) { |
| + if ((*s & 0xC0) != 0x80) |
| + ret++; |
| + ++s; |
| + } |
| + return ret; |
| +} |
| + |
| } // namespace |
| InputMethodEngine::MenuItem::MenuItem() {} |
| @@ -344,4 +357,27 @@ void InputMethodEngine::MenuItemToProperty( |
| // TODO(nona): Support item.children. |
| } |
| +void InputMethodEngine::UpdateComposition( |
| + const ui::CompositionText& composition_text, |
| + uint32_t cursor_pos, |
| + bool is_visible) { |
| + ui::IMEInputContextHandlerInterface* input_context = |
| + ui::IMEBridge::Get()->GetInputContextHandler(); |
| + if (input_context) |
| + input_context->UpdateCompositionText(composition_text, cursor_pos, |
| + is_visible); |
| +} |
| + |
| +void InputMethodEngine::CommitTextToInputContext(int context_id, |
| + const char* text) { |
| + ui::IMEBridge::Get()->GetInputContextHandler()->CommitText(text); |
| + |
| + // Records histograms for committed characters. |
| + if (!composition_text_->text.empty()) { |
| + size_t len = GetUtf8StringLength(text); |
| + UMA_HISTOGRAM_CUSTOM_COUNTS("InputMethod.CommitLength", len, 1, 25, 25); |
| + composition_text_.reset(new ui::CompositionText()); |
| + } |
| +} |
| + |
| } // namespace chromeos |