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

Unified Diff: extensions/shell/browser/input_method_event_handler.cc

Issue 2580733002: AppShell: Create input method and handle key events (Closed)
Patch Set: rebase Created 4 years 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
Index: extensions/shell/browser/input_method_event_handler.cc
diff --git a/extensions/shell/browser/input_method_event_handler.cc b/extensions/shell/browser/input_method_event_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..834920a9a87f6d95ffdcd92b285d61ad119b68f4
--- /dev/null
+++ b/extensions/shell/browser/input_method_event_handler.cc
@@ -0,0 +1,33 @@
+// 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 "extensions/shell/browser/input_method_event_handler.h"
+
+#include "ui/base/ime/input_method.h"
+#include "ui/events/event.h"
+
+namespace extensions {
+
+InputMethodEventHandler::InputMethodEventHandler(ui::InputMethod* input_method)
+ : input_method_(input_method), post_ime_(false) {}
James Cook 2016/12/16 19:00:50 nit: DCHECK(input_method_) so it's self documentin
michaelpg 2016/12/17 03:07:46 Done.
+
+InputMethodEventHandler::~InputMethodEventHandler() {}
+
+void InputMethodEventHandler::set_post_ime(bool post_ime) {
+ post_ime_ = post_ime;
+}
+
+void InputMethodEventHandler::OnKeyEvent(ui::KeyEvent* event) {
+ // Ignore events being dispatched back to the delegate from the input method.
+ if (post_ime_)
+ return;
+
+ if (event->flags() & ui::EF_IS_SYNTHESIZED)
+ return;
+
+ input_method_->DispatchKeyEvent(event);
+ event->StopPropagation();
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698