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

Unified Diff: athena/virtual_keyboard/vk_message_handler.cc

Issue 335793005: athena: Add support for virtual keyboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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
Index: athena/virtual_keyboard/vk_message_handler.cc
diff --git a/athena/virtual_keyboard/vk_message_handler.cc b/athena/virtual_keyboard/vk_message_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fbd1e79495ac4db2802985d84c5ec5c2e010158b
--- /dev/null
+++ b/athena/virtual_keyboard/vk_message_handler.cc
@@ -0,0 +1,57 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "athena/virtual_keyboard/vk_message_handler.h"
+
+#include "athena/screen/public/screen_manager.h"
+#include "base/bind.h"
+#include "base/values.h"
+#include "content/public/browser/web_ui.h"
+#include "ui/keyboard/keyboard_controller.h"
+#include "ui/keyboard/keyboard_util.h"
+
+namespace athena {
+
+VKMessageHandler::VKMessageHandler() {
+}
+VKMessageHandler::~VKMessageHandler() {
+}
+
+void VKMessageHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "sendKeyEvent",
+ base::Bind(&VKMessageHandler::SendKeyEvent, base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "hideKeyboard",
+ base::Bind(&VKMessageHandler::HideKeyboard, base::Unretained(this)));
+}
+
+void VKMessageHandler::SendKeyEvent(const base::ListValue* params) {
+ std::string type;
+ int char_value;
+ int key_code;
+ std::string key_name;
+ int modifiers;
+ if (!params->GetString(0, &type))
+ return;
+ if (!params->GetInteger(1, &char_value))
+ return;
+ if (!params->GetInteger(2, &key_code))
+ return;
+ if (!params->GetString(3, &key_name))
+ return;
+ if (!params->GetInteger(4, &modifiers))
+ return;
+
+ aura::Window* window = ScreenManager::Get()->GetContext();
+ keyboard::SendKeyEvent(
+ type, char_value, key_code, key_name, modifiers, window->GetHost());
+}
+
+void VKMessageHandler::HideKeyboard(const base::ListValue* params) {
+ keyboard::KeyboardController::GetInstance()->HideKeyboard(
+ keyboard::KeyboardController::HIDE_REASON_MANUAL);
+}
+
+} // namespace athena

Powered by Google App Engine
This is Rietveld 408576698