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

Unified Diff: ui/keyboard/keyboard_ui_handler.cc

Issue 20145004: Switch from text insertion to key press and release events on the virtual k… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Formatting. Created 7 years, 5 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
Index: ui/keyboard/keyboard_ui_handler.cc
diff --git a/ui/keyboard/keyboard_ui_handler.cc b/ui/keyboard/keyboard_ui_handler.cc
index 0c412675d3e8d1b8fd12231f6335d858db5945a3..456fffb6d7d90a2d9245d61e834c20d00df52029 100644
--- a/ui/keyboard/keyboard_ui_handler.cc
+++ b/ui/keyboard/keyboard_ui_handler.cc
@@ -28,6 +28,10 @@ void KeyboardUIHandler::RegisterMessages() {
"insertText",
base::Bind(&KeyboardUIHandler::HandleInsertTextMessage,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "dispatchKeyEvent",
+ base::Bind(&KeyboardUIHandler::HandleDispatchKeyEventMessage,
+ base::Unretained(this)));
}
void KeyboardUIHandler::HandleInsertTextMessage(const base::ListValue* args) {
@@ -48,4 +52,29 @@ void KeyboardUIHandler::HandleInsertTextMessage(const base::ListValue* args) {
LOG(ERROR) << "insertText failed";
}
+void KeyboardUIHandler::HandleDispatchKeyEventMessage(
+ const base::ListValue* args) {
+ std::string type;
+ if (!args->GetString(0, &type)) {
+ LOG(ERROR) << "dispatchKeyEvent failed: bad argument";
+ return;
+ }
+
+ int char_code;
+ if (!args->GetInteger(1, &char_code)) {
+ LOG(ERROR) << "dispatchKeyEvent failed: bad argument";
+ return;
+ }
+
+ aura::RootWindow* root_window =
+ web_ui()->GetWebContents()->GetView()->GetNativeView()->GetRootWindow();
+ if (!root_window) {
+ LOG(ERROR) << "dispatchKeyEvent failed: no root window";
+ return;
+ }
+
+ if (!keyboard::DispatchKeyEvent(type, char_code, root_window))
+ LOG(ERROR) << "dispatchKeyEvent failed";
+}
+
} // namespace keyboard

Powered by Google App Engine
This is Rietveld 408576698