summaryrefslogtreecommitdiffstats
path: root/remoting/webapp/crd/js/desktop_connected_view.js
diff options
context:
space:
mode:
authorkelvinp <kelvinp@chromium.org>2015-03-19 13:21:35 -0700
committerCommit bot <commit-bot@chromium.org>2015-03-19 20:22:05 +0000
commit06408c1d57d6521cc1acebccbdb4972d2a26ae41 (patch)
tree38e67e4a0af7544866df6b2d358be57f944fd748 /remoting/webapp/crd/js/desktop_connected_view.js
parenta8190bfa85ddd4a2f86b5dde62ccdad80b631fd9 (diff)
downloadchromium_src-06408c1d57d6521cc1acebccbdb4972d2a26ae41.zip
chromium_src-06408c1d57d6521cc1acebccbdb4972d2a26ae41.tar.gz
chromium_src-06408c1d57d6521cc1acebccbdb4972d2a26ae41.tar.bz2
[Webapp Refactor] Move key injection related functionality into the plugin layer.
This CL moves key injection logic setRemapKey() and injectKeyCombination() into the plugin layer. With this change, we no longer need to pass the default remap keys from the ApplicationDelegate through the SessionConnector to the DesktopConnectedView in order to setup a key remapping. Instead, we can simply call plugin.setRemapKeys('a->b,b->c') on the delegate. BUG=465878 Review URL: https://codereview.chromium.org/1022473004 Cr-Commit-Position: refs/heads/master@{#321419}
Diffstat (limited to 'remoting/webapp/crd/js/desktop_connected_view.js')
-rw-r--r--remoting/webapp/crd/js/desktop_connected_view.js87
1 files changed, 3 insertions, 84 deletions
diff --git a/remoting/webapp/crd/js/desktop_connected_view.js b/remoting/webapp/crd/js/desktop_connected_view.js
index f1baf13..af4a3fb 100644
--- a/remoting/webapp/crd/js/desktop_connected_view.js
+++ b/remoting/webapp/crd/js/desktop_connected_view.js
@@ -15,14 +15,11 @@ var remoting = remoting || {};
/**
* @param {HTMLElement} container
* @param {remoting.ConnectionInfo} connectionInfo
- * @param {string} defaultRemapKeys The default set of remap keys, to use
- * when the client doesn't define any.
* @constructor
* @extends {base.EventSourceImpl}
* @implements {base.Disposable}
*/
-remoting.DesktopConnectedView = function(container, connectionInfo,
- defaultRemapKeys) {
+remoting.DesktopConnectedView = function(container, connectionInfo) {
/** @private {HTMLElement} */
this.container_ = container;
@@ -39,9 +36,6 @@ remoting.DesktopConnectedView = function(container, connectionInfo,
/** @private */
this.mode_ = connectionInfo.mode();
- /** @private {string} */
- this.defaultRemapKeys_ = defaultRemapKeys;
-
/** @private {remoting.DesktopViewport} */
this.viewport_ = null;
@@ -156,11 +150,6 @@ remoting.DesktopConnectedView.prototype.initPlugin_ = function() {
sendCadElement.hidden = true;
}
- // Apply customized key remappings if the plugin supports remapKeys.
- if (this.plugin_.hasFeature(remoting.ClientPlugin.Feature.REMAP_KEY)) {
- this.applyRemapKeys_(true);
- }
-
if (this.session_.hasCapability(
remoting.ClientSession.Capability.VIDEO_RECORDER)) {
this.videoFrameRecorder_ = new remoting.VideoFrameRecorder(this.plugin_);
@@ -254,83 +243,13 @@ remoting.DesktopConnectedView.prototype.onFullScreenChanged_ = function (
};
/**
- * Sets and stores the key remapping setting for the current host.
- *
- * @param {string} remappings Comma separated list of key remappings.
- */
-remoting.DesktopConnectedView.prototype.setRemapKeys = function(remappings) {
- // Cancel any existing remappings and apply the new ones.
- this.applyRemapKeys_(false);
- this.host_.options.remapKeys = remappings;
- this.applyRemapKeys_(true);
-
- // Save the new remapping setting.
- this.host_.options.save();
-};
-
-/**
- * Applies the configured key remappings to the session, or resets them.
- *
- * @param {boolean} apply True to apply remappings, false to cancel them.
- */
-remoting.DesktopConnectedView.prototype.applyRemapKeys_ = function(apply) {
- var remapKeys = this.host_.options.remapKeys;
- if (remapKeys == '') {
- remapKeys = this.defaultRemapKeys_;
- if (remapKeys == '') {
- return;
- }
- }
-
- var remappings = remapKeys.split(',');
- for (var i = 0; i < remappings.length; ++i) {
- var keyCodes = remappings[i].split('>');
- if (keyCodes.length != 2) {
- console.log('bad remapKey: ' + remappings[i]);
- continue;
- }
- var fromKey = parseInt(keyCodes[0], 0);
- var toKey = parseInt(keyCodes[1], 0);
- if (!fromKey || !toKey) {
- console.log('bad remapKey code: ' + remappings[i]);
- continue;
- }
- if (apply) {
- console.log('remapKey 0x' + fromKey.toString(16) +
- '>0x' + toKey.toString(16));
- this.plugin_.remapKey(fromKey, toKey);
- } else {
- console.log('cancel remapKey 0x' + fromKey.toString(16));
- this.plugin_.remapKey(fromKey, fromKey);
- }
- }
-};
-
-/**
- * Sends a key combination to the remoting client, by sending down events for
- * the given keys, followed by up events in reverse order.
- *
- * @param {Array<number>} keys Key codes to be sent.
- * @return {void} Nothing.
- * @private
- */
-remoting.DesktopConnectedView.prototype.sendKeyCombination_ = function(keys) {
- for (var i = 0; i < keys.length; i++) {
- this.plugin_.injectKeyEvent(keys[i], true);
- }
- for (var i = 0; i < keys.length; i++) {
- this.plugin_.injectKeyEvent(keys[i], false);
- }
-};
-
-/**
* Sends a Ctrl-Alt-Del sequence to the remoting client.
*
* @return {void} Nothing.
*/
remoting.DesktopConnectedView.prototype.sendCtrlAltDel = function() {
console.log('Sending Ctrl-Alt-Del.');
- this.sendKeyCombination_([0x0700e0, 0x0700e2, 0x07004c]);
+ this.plugin_.injectKeyCombination([0x0700e0, 0x0700e2, 0x07004c]);
};
/**
@@ -340,7 +259,7 @@ remoting.DesktopConnectedView.prototype.sendCtrlAltDel = function() {
*/
remoting.DesktopConnectedView.prototype.sendPrintScreen = function() {
console.log('Sending Print Screen.');
- this.sendKeyCombination_([0x070046]);
+ this.plugin_.injectKeyCombination([0x070046]);
};
/**