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

Unified Diff: ui/keyboard/keyboard_ui_handler.cc

Issue 16972006: Insert text directly from the virtual keyboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix include Created 7 years, 6 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 291f3a05f4cee02bf4feb7bbd6b99dd89e0b16dd..0c412675d3e8d1b8fd12231f6335d858db5945a3 100644
--- a/ui/keyboard/keyboard_ui_handler.cc
+++ b/ui/keyboard/keyboard_ui_handler.cc
@@ -8,12 +8,11 @@
#include "base/bind.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/values.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "content/public/browser/web_ui.h"
-#include "ui/aura/root_window.h"
-#include "ui/base/events/event.h"
+#include "ui/aura/window.h"
#include "ui/keyboard/keyboard_util.h"
namespace keyboard {
@@ -26,22 +25,27 @@ KeyboardUIHandler::~KeyboardUIHandler() {
void KeyboardUIHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
- "sendKeyEvent",
- base::Bind(&KeyboardUIHandler::HandleSendKeyEventMessage,
+ "insertText",
+ base::Bind(&KeyboardUIHandler::HandleInsertTextMessage,
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;
+void KeyboardUIHandler::HandleInsertTextMessage(const base::ListValue* args) {
+ string16 text;
+ if (!args->GetString(0, &text)) {
+ LOG(ERROR) << "insertText failed: bad argument";
return;
}
aura::RootWindow* root_window =
web_ui()->GetWebContents()->GetView()->GetNativeView()->GetRootWindow();
- root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(event.get());
+ if (!root_window) {
+ LOG(ERROR) << "insertText failed: no root window";
+ return;
+ }
+
+ if (!keyboard::InsertText(text, root_window))
+ LOG(ERROR) << "insertText 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