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

Unified Diff: ui/keyboard/keyboard_ui_handler.cc

Issue 14161009: WebUIHandler for chrome://keyboard (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 7 years, 8 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/keyboard/keyboard_ui_handler.h ('k') | ui/keyboard/keyboard_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/keyboard/keyboard_ui_handler.cc
diff --git a/ui/keyboard/keyboard_ui_handler.cc b/ui/keyboard/keyboard_ui_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..92a81852fccb1a765dc0d927dd52fdbd7c6db74a
--- /dev/null
+++ b/ui/keyboard/keyboard_ui_handler.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 2013 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/keyboard/keyboard_ui_handler.h"
+
+#include <string>
+
+#include "base/bind.h"
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/public/browser/web_ui.h"
+#include "ui/aura/root_window.h"
+#include "ui/base/events/event.h"
+#include "ui/keyboard/keyboard_util.h"
+
+namespace keyboard {
+
+KeyboardUIHandler::KeyboardUIHandler(aura::RootWindow* root_window)
+ : root_window_(root_window) {
+}
+
+KeyboardUIHandler::~KeyboardUIHandler() {
+}
+
+void KeyboardUIHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "sendKeyEvent",
+ base::Bind(&KeyboardUIHandler::HandleSendKeyEventMessage,
+ base::Unretained(this)));
+}
+
+void KeyboardUIHandler::HandleSendKeyEventMessage(const base::ListValue* args) {
+ std::string error;
+ scoped_ptr<ui::KeyEvent> event(keyboard::KeyEventFromArgs(args, &error));
+ if (!event) {
+ LOG(ERROR) << "sendKeyEvent failed: " << error;
+ return;
+ }
+
+ if (root_window_) {
+ root_window_->AsRootWindowHostDelegate()->OnHostKeyEvent(event.get());
sadrul 2013/04/18 02:58:28 Does it make sense to use web_ui()->GetWebContents
bryeung 2013/04/18 14:42:36 Clever! This is a great simplification. Done.
+ } else {
+ DLOG(INFO) << "KeyboardUIHandler handling sendKeyEvent: key_code="
+ << event->key_code();
+ }
+}
+
+} // namespace keyboard
« no previous file with comments | « ui/keyboard/keyboard_ui_handler.h ('k') | ui/keyboard/keyboard_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698