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

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: Merge with trunk. Created 7 years, 3 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
index 398d2f4c08d2e0008cbfee11c66dcfb3688743d4..9d3920f57799a285c07b1309221ec0a57ff31475 100644
--- a/ui/keyboard/keyboard_ui_handler.cc
+++ b/ui/keyboard/keyboard_ui_handler.cc
@@ -36,6 +36,11 @@ void KeyboardUIHandler::RegisterMessages() {
"getInputContext",
base::Bind(&KeyboardUIHandler::HandleGetInputContextMessage,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "sendKeyEvent",
+ base::Bind(&KeyboardUIHandler::HandleSendKeyEventMessage,
+ base::Unretained(this)));
+
}
void KeyboardUIHandler::HandleInsertTextMessage(const base::ListValue* args) {
@@ -87,4 +92,37 @@ void KeyboardUIHandler::HandleGetInputContextMessage(
results);
}
+void KeyboardUIHandler::HandleSendKeyEventMessage(
+ const base::ListValue* args) {
+ const base::DictionaryValue* params = NULL;
+ std::string type;
+ int char_value;
+ int key_code;
+ bool shift_modifier;
+
+ if (!args->GetDictionary(0, &params) ||
+ !params->GetString("type", &type) ||
+ !params->GetInteger("charValue", &char_value) ||
+ !params->GetInteger("keyCode", &key_code) ||
+ !params->GetBoolean("shiftKey", &shift_modifier)) {
+ LOG(ERROR) << "SendKeyEvent failed: bad argument";
+ return;
+ }
+
+ aura::RootWindow* root_window =
+ web_ui()->GetWebContents()->GetView()->GetNativeView()->GetRootWindow();
+ if (!root_window) {
+ LOG(ERROR) << "sendKeyEvent failed: no root window";
+ return;
+ }
+
+ if (!keyboard::SendKeyEvent(type,
+ char_value,
+ key_code,
+ shift_modifier,
+ root_window)) {
+ LOG(ERROR) << "sendKeyEvent failed";
+ }
+}
+
} // 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