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

Unified Diff: ui/views/mus/text_input_client_impl.cc

Issue 2230393002: IME for Mus: Make InputMethodMus use the IME Mojo API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update mash_browser_tests_manifest. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/mus/text_input_client_impl.h ('k') | ui/views/mus/window_tree_host_mus.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/text_input_client_impl.cc
diff --git a/ui/views/mus/text_input_client_impl.cc b/ui/views/mus/text_input_client_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..59b4b995c6633d4a1d1a5ab68d489f2f90bb50df
--- /dev/null
+++ b/ui/views/mus/text_input_client_impl.cc
@@ -0,0 +1,55 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/mus/text_input_client_impl.h"
+
+#include "ui/base/ime/text_input_client.h"
+#include "ui/views/mus/input_method_mus.h"
+
+namespace views {
+
+TextInputClientImpl::TextInputClientImpl(ui::TextInputClient* text_input_client,
+ InputMethodMus* input_method)
+ : text_input_client_(text_input_client),
+ input_method_(input_method),
+ binding_(this) {}
+
+TextInputClientImpl::~TextInputClientImpl() {}
+
+ui::mojom::TextInputClientPtr TextInputClientImpl::CreateInterfacePtrAndBind() {
+ return binding_.CreateInterfacePtrAndBind();
+}
+
+void TextInputClientImpl::OnCompositionEvent(
+ ui::mojom::CompositionEventPtr event) {
+ switch (event->type) {
+ case ui::mojom::CompositionEventType::INSERT_CHAR: {
+ DCHECK((*event->key_event)->IsKeyEvent());
+ ui::KeyEvent* key_event = (*event->key_event)->AsKeyEvent();
+ DCHECK(key_event->is_char());
+ text_input_client_->InsertChar(*key_event);
+ break;
+ }
+ case ui::mojom::CompositionEventType::CONFIRM:
+ text_input_client_->ConfirmCompositionText();
+ break;
+ case ui::mojom::CompositionEventType::CLEAR:
+ text_input_client_->ClearCompositionText();
+ break;
+ case ui::mojom::CompositionEventType::UPDATE:
+ case ui::mojom::CompositionEventType::INSERT_TEXT:
+ // TODO(moshayedi): crbug.com/631524. Implement these types of composition
+ // events once we have the necessary fields in ui.mojom.CompositionEvent.
+ NOTIMPLEMENTED();
+ break;
+ }
+}
+
+void TextInputClientImpl::OnUnhandledEvent(
+ std::unique_ptr<ui::Event> key_event) {
+ DCHECK(key_event && key_event->IsKeyEvent());
+ input_method_->DispatchKeyEventPostIME(key_event->AsKeyEvent());
+}
+
+} // namespace views
« no previous file with comments | « ui/views/mus/text_input_client_impl.h ('k') | ui/views/mus/window_tree_host_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698