summaryrefslogtreecommitdiffstats
path: root/ui/keyboard/keyboard_ui_handler.cc
diff options
context:
space:
mode:
authorkevers@chromium.org <kevers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-05 13:04:09 +0000
committerkevers@chromium.org <kevers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-05 13:04:09 +0000
commitce5916aa7b8323c651af377941093c774077cce8 (patch)
tree55efddc4cb1e0bd705ae369d777861983a61dbb1 /ui/keyboard/keyboard_ui_handler.cc
parent6c2beac20246525310f2e85f5f0c33fcdbd2dff8 (diff)
downloadchromium_src-ce5916aa7b8323c651af377941093c774077cce8.zip
chromium_src-ce5916aa7b8323c651af377941093c774077cce8.tar.gz
chromium_src-ce5916aa7b8323c651af377941093c774077cce8.tar.bz2
Switch from text insertion to key press and release events on the virtual keyboard. First step in integration the virtual keyboard with IMEs.
BUG=257093, 257098 Review URL: https://chromiumcodereview.appspot.com/20145004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221393 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/keyboard/keyboard_ui_handler.cc')
-rw-r--r--ui/keyboard/keyboard_ui_handler.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/ui/keyboard/keyboard_ui_handler.cc b/ui/keyboard/keyboard_ui_handler.cc
index 398d2f4..9d3920f 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