| 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
|
|
|