summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-01 20:22:54 +0000
committerwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-01 20:22:54 +0000
commitbfb7198e92a31260da72b55c6c22c3aa2e13b3b7 (patch)
treecb5e71dd681bcbc4aadc8bc4f89f3464922bc8d6 /remoting
parentb01a9b9bad2a7f403c67c0cc7d5dfe5d119a0dc8 (diff)
downloadchromium_src-bfb7198e92a31260da72b55c6c22c3aa2e13b3b7.zip
chromium_src-bfb7198e92a31260da72b55c6c22c3aa2e13b3b7.tar.gz
chromium_src-bfb7198e92a31260da72b55c6c22c3aa2e13b3b7.tar.bz2
Add an injectKeyEvent API to the Chromoting client plugin.
The API allows a key (identified by USB-style identifier) event to be injected into the host by the web-application, to allow it to provide UI to inject key sequences that would not otherwise be possible on the client system (e.g. injecting Ctrl-Alt-Del from Windows, WinKey from CrOS, etc). BUG=105736,120313 TEST=Will be manually testable by verifying that the Send Ctrl-Alt-Del button works, once implemented in a follow-up CL. Review URL: http://codereview.chromium.org/9968030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130082 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/client/plugin/chromoting_instance.cc23
-rw-r--r--remoting/client/plugin/chromoting_instance.h2
-rw-r--r--remoting/webapp/client_plugin.js8
-rw-r--r--remoting/webapp/client_plugin_async.js15
4 files changed, 46 insertions, 2 deletions
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index d357ce5..30e3c51 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -249,6 +249,21 @@ void ChromotingInstance::HandleMessage(const pp::Var& message) {
OnIncomingIq(iq);
} else if (method == "releaseAllKeys") {
ReleaseAllKeys();
+ } else if (method == "injectKeyEvent") {
+ int usb_keycode = 0;
+ bool is_pressed = false;
+ if (!data->GetInteger("usb_keycode", &usb_keycode) ||
+ !data->GetBoolean("pressed", &is_pressed)) {
+ LOG(ERROR) << "Invalid injectKeyEvent.";
+ return;
+ }
+
+ protocol::KeyEvent event;
+ event.set_usb_keycode(usb_keycode);
+ event.set_pressed(is_pressed);
+ // Even though new hosts will ignore keycode, it's a required field.
+ event.set_keycode(0);
+ InjectKeyEvent(event);
} else if (method == "sendClipboardItem") {
std::string mime_type;
std::string item;
@@ -400,9 +415,13 @@ void ChromotingInstance::OnIncomingIq(const std::string& iq) {
}
void ChromotingInstance::ReleaseAllKeys() {
- if (key_event_tracker_.get()) {
+ if (key_event_tracker_.get())
key_event_tracker_->ReleaseAllKeys();
- }
+}
+
+void ChromotingInstance::InjectKeyEvent(const protocol::KeyEvent& event) {
+ if (key_event_tracker_.get())
+ key_event_tracker_->InjectKeyEvent(event);
}
void ChromotingInstance::SendClipboardItem(const std::string& mime_type,
diff --git a/remoting/client/plugin/chromoting_instance.h b/remoting/client/plugin/chromoting_instance.h
index adc40e0..9fe3fdb 100644
--- a/remoting/client/plugin/chromoting_instance.h
+++ b/remoting/client/plugin/chromoting_instance.h
@@ -28,6 +28,7 @@
#include "remoting/base/scoped_thread_proxy.h"
#include "remoting/client/client_context.h"
#include "remoting/client/plugin/pepper_plugin_thread_delegate.h"
+#include "remoting/proto/event.pb.h"
#include "remoting/protocol/connection_to_host.h"
namespace base {
@@ -129,6 +130,7 @@ class ChromotingInstance :
void Disconnect();
void OnIncomingIq(const std::string& iq);
void ReleaseAllKeys();
+ void InjectKeyEvent(const protocol::KeyEvent& event);
void SendClipboardItem(const std::string& mime_type, const std::string& item);
// Return statistics record by ChromotingClient.
diff --git a/remoting/webapp/client_plugin.js b/remoting/webapp/client_plugin.js
index 336e17e..2ed6106 100644
--- a/remoting/webapp/client_plugin.js
+++ b/remoting/webapp/client_plugin.js
@@ -91,6 +91,14 @@ remoting.ClientPlugin.prototype.setScaleToFit =
remoting.ClientPlugin.prototype.releaseAllKeys = function() {};
/**
+ * Send a key event to the host.
+ *
+ * @param {number} usb_keycode The USB-style code of the key to inject.
+ * @param {boolean} pressed True to inject a key press, False for a release.
+ */
+remoting.ClientPlugin.prototype.injectKey = function() {};
+
+/**
* Returns an associative array with a set of stats for this connection.
*
* @return {remoting.ClientSession.PerfStats} The connection statistics.
diff --git a/remoting/webapp/client_plugin_async.js b/remoting/webapp/client_plugin_async.js
index e85faa4..29ba91f 100644
--- a/remoting/webapp/client_plugin_async.js
+++ b/remoting/webapp/client_plugin_async.js
@@ -267,6 +267,21 @@ remoting.ClientPluginAsync.prototype.releaseAllKeys = function() {
};
/**
+ * Send a key event to the host.
+ *
+ * @param {number} usb_keycode The USB-style code of the key to inject.
+ * @param {boolean} pressed True to inject a key press, False for a release.
+ */
+remoting.ClientPluginAsync.prototype.injectKey =
+ function(usb_keycode, pressed) {
+ this.plugin.postMessage(JSON.stringify(
+ { method: 'injectKeyEvent', data: {
+ 'usb_keycode': usb_keycode,
+ 'pressed': pressed}
+ }));
+};
+
+/**
* Returns an associative array with a set of stats for this connecton.
*
* @return {remoting.ClientSession.PerfStats} The connection statistics.