diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-12 03:02:09 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-12 03:02:09 +0000 |
commit | da83970eaf43d7b8e369cc1986571607b0e616bf (patch) | |
tree | 9629ced139affc64e067108d2b33e08f166e5a86 /remoting | |
parent | 08c3a7ab90c8dbf8d9c00a5d421a5f469844c93f (diff) | |
download | chromium_src-da83970eaf43d7b8e369cc1986571607b0e616bf.zip chromium_src-da83970eaf43d7b8e369cc1986571607b0e616bf.tar.gz chromium_src-da83970eaf43d7b8e369cc1986571607b0e616bf.tar.bz2 |
Remap the right Control key to Cmd when running on ChromeOS.
Requires the browser's Chromoting client plugin to support the remapKey API.
BUG=105736,121787
TEST=Client running on ChromeOS can copy text on Mac OS X host by pressing right-Ctrl + C.
Review URL: http://codereview.chromium.org/10052034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131914 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/webapp/client_plugin.js | 10 | ||||
-rw-r--r-- | remoting/webapp/client_plugin_async.js | 15 | ||||
-rw-r--r-- | remoting/webapp/client_plugin_v1.js | 11 | ||||
-rw-r--r-- | remoting/webapp/client_session.js | 9 | ||||
-rw-r--r-- | remoting/webapp/remoting.js | 11 |
5 files changed, 55 insertions, 1 deletions
diff --git a/remoting/webapp/client_plugin.js b/remoting/webapp/client_plugin.js index ed46537..24054a6 100644 --- a/remoting/webapp/client_plugin.js +++ b/remoting/webapp/client_plugin.js @@ -49,6 +49,7 @@ remoting.ClientPlugin.prototype.isSupportedVersion = function() {}; remoting.ClientPlugin.Feature = { HIGH_QUALITY_SCALING: 'highQualityScaling', INJECT_KEY_EVENT: 'injectKeyEvent', + REMAP_KEY: 'remapKey', SEND_CLIPBOARD_ITEM: 'sendClipboardItem' }; @@ -111,6 +112,15 @@ remoting.ClientPlugin.prototype.injectKeyEvent = function(usbKeycode, pressed) {}; /** + * Remap one USB keycode to another in all subsequent key events. + * + * @param {number} fromKeycode The USB-style code of the key to remap. + * @param {number} toKeycode The USB-style code to remap the key to. + */ +remoting.ClientPlugin.prototype.remapKey = + function(fromKeycode, toKeycode) {}; + +/** * 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 368eefa..183b836 100644 --- a/remoting/webapp/client_plugin_async.js +++ b/remoting/webapp/client_plugin_async.js @@ -319,6 +319,21 @@ remoting.ClientPluginAsync.prototype.injectKeyEvent = }; /** + * Remap one USB keycode to another in all subsequent key events. + * + * @param {number} fromKeycode The USB-style code of the key to remap. + * @param {number} toKeycode The USB-style code to remap the key to. + */ +remoting.ClientPluginAsync.prototype.remapKey = + function(fromKeycode, toKeycode) { + this.plugin.postMessage(JSON.stringify( + { method: 'remapKey', data: { + 'fromKeycode': fromKeycode, + 'toKeycode': toKeycode} + })); +}; + +/** * Returns an associative array with a set of stats for this connecton. * * @return {remoting.ClientSession.PerfStats} The connection statistics. diff --git a/remoting/webapp/client_plugin_v1.js b/remoting/webapp/client_plugin_v1.js index 396b320..e67887b 100644 --- a/remoting/webapp/client_plugin_v1.js +++ b/remoting/webapp/client_plugin_v1.js @@ -249,3 +249,14 @@ remoting.ClientPluginV1.prototype.injectKeyEvent = function(usbKeycode, pressed) { return; }; + +/** + * Remap one USB keycode to another in all subsequent key events. + * + * @param {number} fromKeycode The USB-style code of the key to remap. + * @param {number} toKeycode The USB-style code to remap the key to. + */ +remoting.ClientPluginV1.prototype.remapKey = + function(fromKeycode, toKeycode) { + return; +}; diff --git a/remoting/webapp/client_session.js b/remoting/webapp/client_session.js index 9531294..8fab461 100644 --- a/remoting/webapp/client_session.js +++ b/remoting/webapp/client_session.js @@ -277,6 +277,8 @@ remoting.ClientSession.prototype.onPluginInitialized_ = return; } + // Show the Send Keys menu and Ctrl-Alt-Del button only in Me2Me mode, and + // only if the plugin has the injectKeyEvent feature. if (!this.plugin.hasFeature(remoting.ClientPlugin.Feature.INJECT_KEY_EVENT) || this.mode != remoting.ClientSession.Mode.ME2ME) { var sendCadElement = document.getElementById('send-ctrl-alt-del'); @@ -285,6 +287,13 @@ remoting.ClientSession.prototype.onPluginInitialized_ = sendKeysElement.hidden = true; } + // Remap the right Control key to the right Win / Cmd key on ChromeOS + // platforms, if the plugin has the remapKey feature. + if (this.plugin.hasFeature(remoting.ClientPlugin.Feature.REMAP_KEY) && + remoting.runningOnChromeOS()) { + this.plugin.remapKey(0x0700e4, 0x0700e7); + } + // Enable scale-to-fit if and only if the plugin is new enough for // high-quality scaling. this.setScaleToFit(this.plugin.hasFeature( diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js index b2a08fa..e7836c8 100644 --- a/remoting/webapp/remoting.js +++ b/remoting/webapp/remoting.js @@ -165,6 +165,15 @@ remoting.signOut = function() { }; /** + * Returns whether the app is running on ChromeOS. + * + * @return {boolean} True if the app is running on ChromeOS. + */ +remoting.runningOnChromeOS = function() { + return !!navigator.userAgent.match(/\bCrOS\b/); +} + +/** * Callback function called when the browser window gets a paste operation. * * @param {Event} eventUncast @@ -252,7 +261,7 @@ function getAppStartupMode_() { */ function isHostModeSupported_() { // Currently, sharing on Chromebooks is not supported. - return !navigator.userAgent.match(/\bCrOS\b/); + return !remoting.runningOnChromeOS(); } /** |