Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * Class that wraps low-level details of interacting with the client plugin. | 7 * Class that wraps low-level details of interacting with the client plugin. |
| 8 * | 8 * |
| 9 * This abstracts a <embed> element and controls the plugin which does | 9 * This abstracts a <embed> element and controls the plugin which does |
| 10 * the actual remoting work. It also handles differences between | 10 * the actual remoting work. It also handles differences between |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 | 91 |
| 92 if (remoting.settings.CLIENT_PLUGIN_TYPE == 'native') { | 92 if (remoting.settings.CLIENT_PLUGIN_TYPE == 'native') { |
| 93 window.setTimeout(this.showPluginForClickToPlay_.bind(this), 500); | 93 window.setTimeout(this.showPluginForClickToPlay_.bind(this), 500); |
| 94 } | 94 } |
| 95 | 95 |
| 96 this.hostDesktop_ = new remoting.ClientPlugin.HostDesktopImpl( | 96 this.hostDesktop_ = new remoting.ClientPlugin.HostDesktopImpl( |
| 97 this, this.postMessage_.bind(this)); | 97 this, this.postMessage_.bind(this)); |
| 98 | 98 |
| 99 /** @private {remoting.CredentialsProvider} */ | 99 /** @private {remoting.CredentialsProvider} */ |
| 100 this.credentials_ = null; | 100 this.credentials_ = null; |
| 101 | |
| 102 /** @private {string} */ | |
| 103 this.keyRemappings_ = ''; | |
| 101 }; | 104 }; |
| 102 | 105 |
| 103 /** | 106 /** |
| 104 * Creates plugin element without adding it to a container. | 107 * Creates plugin element without adding it to a container. |
| 105 * | 108 * |
| 106 * @return {HTMLEmbedElement} Plugin element | 109 * @return {HTMLEmbedElement} Plugin element |
| 107 */ | 110 */ |
| 108 remoting.ClientPluginImpl.createPluginElement_ = function() { | 111 remoting.ClientPluginImpl.createPluginElement_ = function() { |
| 109 var plugin = | 112 var plugin = |
| 110 /** @type {HTMLEmbedElement} */ (document.createElement('embed')); | 113 /** @type {HTMLEmbedElement} */ (document.createElement('embed')); |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 | 491 |
| 489 /** | 492 /** |
| 490 * Release all currently pressed keys. | 493 * Release all currently pressed keys. |
| 491 */ | 494 */ |
| 492 remoting.ClientPluginImpl.prototype.releaseAllKeys = function() { | 495 remoting.ClientPluginImpl.prototype.releaseAllKeys = function() { |
| 493 this.plugin_.postMessage(JSON.stringify( | 496 this.plugin_.postMessage(JSON.stringify( |
| 494 { method: 'releaseAllKeys', data: {} })); | 497 { method: 'releaseAllKeys', data: {} })); |
| 495 }; | 498 }; |
| 496 | 499 |
| 497 /** | 500 /** |
| 501 * Sets and stores the key remapping setting for the current host. | |
| 502 * | |
| 503 * @param {string} remappings Comma separated list of key remappings. | |
| 504 */ | |
| 505 remoting.ClientPluginImpl.prototype.setRemapKeys = | |
|
kelvinp
2015/03/19 00:25:15
moved from desktop_connected_view.js
| |
| 506 function(remappings) { | |
| 507 // Cancel any existing remappings and apply the new ones. | |
| 508 this.applyRemapKeys_(this.keyRemappings_, false); | |
| 509 this.applyRemapKeys_(remappings, true); | |
| 510 this.keyRemappings_ = remappings; | |
| 511 }; | |
| 512 | |
| 513 /** | |
| 514 * Applies the configured key remappings to the session, or resets them. | |
| 515 * | |
| 516 * @param {string} remapKeys | |
| 517 * @param {boolean} apply True to apply remappings, false to cancel them. | |
| 518 */ | |
|
garykac
2015/03/19 01:20:57
nit: add @private
kelvinp
2015/03/19 17:28:20
Done.
| |
| 519 remoting.ClientPluginImpl.prototype.applyRemapKeys_ = | |
| 520 function(remapKeys, apply) { | |
| 521 if (remapKeys == '') { | |
| 522 return; | |
| 523 } | |
| 524 | |
| 525 var remappings = remapKeys.split(','); | |
| 526 for (var i = 0; i < remappings.length; ++i) { | |
| 527 var keyCodes = remappings[i].split('>'); | |
| 528 if (keyCodes.length != 2) { | |
| 529 console.log('bad remapKey: ' + remappings[i]); | |
| 530 continue; | |
| 531 } | |
| 532 var fromKey = parseInt(keyCodes[0], 0); | |
| 533 var toKey = parseInt(keyCodes[1], 0); | |
| 534 if (!fromKey || !toKey) { | |
| 535 console.log('bad remapKey code: ' + remappings[i]); | |
| 536 continue; | |
| 537 } | |
| 538 if (apply) { | |
| 539 console.log('remapKey 0x' + fromKey.toString(16) + | |
| 540 '>0x' + toKey.toString(16)); | |
| 541 this.remapKey(fromKey, toKey); | |
| 542 } else { | |
| 543 console.log('cancel remapKey 0x' + fromKey.toString(16)); | |
| 544 this.remapKey(fromKey, fromKey); | |
| 545 } | |
| 546 } | |
| 547 }; | |
| 548 | |
| 549 /** | |
| 550 * Sends a key combination to the remoting host, by sending down events for | |
| 551 * the given keys, followed by up events in reverse order. | |
| 552 * | |
| 553 * @param {Array<number>} keys Key codes to be sent. | |
| 554 * @return {void} Nothing. | |
| 555 * @private | |
| 556 */ | |
| 557 remoting.ClientPluginImpl.prototype.injectKeyCombination = | |
|
garykac
2015/03/19 01:20:57
nit: This is @private and should have an underscor
kelvinp
2015/03/19 17:28:20
This is not a private. Referenced in DestopConnect
garykac
2015/03/19 17:53:25
The comment blocks her says that it is @private.
| |
| 558 function(keys) { | |
| 559 for (var i = 0; i < keys.length; i++) { | |
| 560 this.injectKeyEvent(keys[i], true); | |
| 561 } | |
| 562 for (var i = 0; i < keys.length; i++) { | |
| 563 this.injectKeyEvent(keys[i], false); | |
| 564 } | |
| 565 }; | |
| 566 | |
| 567 /** | |
| 498 * Send a key event to the host. | 568 * Send a key event to the host. |
| 499 * | 569 * |
| 500 * @param {number} usbKeycode The USB-style code of the key to inject. | 570 * @param {number} usbKeycode The USB-style code of the key to inject. |
| 501 * @param {boolean} pressed True to inject a key press, False for a release. | 571 * @param {boolean} pressed True to inject a key press, False for a release. |
| 502 */ | 572 */ |
| 503 remoting.ClientPluginImpl.prototype.injectKeyEvent = | 573 remoting.ClientPluginImpl.prototype.injectKeyEvent = |
| 504 function(usbKeycode, pressed) { | 574 function(usbKeycode, pressed) { |
| 505 this.plugin_.postMessage(JSON.stringify( | 575 this.plugin_.postMessage(JSON.stringify( |
| 506 { method: 'injectKeyEvent', data: { | 576 { method: 'injectKeyEvent', data: { |
| 507 'usbKeycode': usbKeycode, | 577 'usbKeycode': usbKeycode, |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 784 remoting.DefaultClientPluginFactory.prototype.preloadPlugin = function() { | 854 remoting.DefaultClientPluginFactory.prototype.preloadPlugin = function() { |
| 785 if (remoting.settings.CLIENT_PLUGIN_TYPE != 'pnacl') { | 855 if (remoting.settings.CLIENT_PLUGIN_TYPE != 'pnacl') { |
| 786 return; | 856 return; |
| 787 } | 857 } |
| 788 | 858 |
| 789 var plugin = remoting.ClientPluginImpl.createPluginElement_(); | 859 var plugin = remoting.ClientPluginImpl.createPluginElement_(); |
| 790 plugin.addEventListener( | 860 plugin.addEventListener( |
| 791 'loadend', function() { document.body.removeChild(plugin); }, false); | 861 'loadend', function() { document.body.removeChild(plugin); }, false); |
| 792 document.body.appendChild(plugin); | 862 document.body.appendChild(plugin); |
| 793 }; | 863 }; |
| OLD | NEW |