| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 /** | 43 /** |
| 44 * @param {string} tokenUrl Token-request URL, received from the host. | 44 * @param {string} tokenUrl Token-request URL, received from the host. |
| 45 * @param {string} hostPublicKey Public key for the host. | 45 * @param {string} hostPublicKey Public key for the host. |
| 46 * @param {string} scope OAuth scope to request the token for. | 46 * @param {string} scope OAuth scope to request the token for. |
| 47 */ | 47 */ |
| 48 this.fetchThirdPartyTokenHandler = function( | 48 this.fetchThirdPartyTokenHandler = function( |
| 49 tokenUrl, hostPublicKey, scope) {}; | 49 tokenUrl, hostPublicKey, scope) {}; |
| 50 this.onDesktopSizeUpdateHandler = function () {}; | 50 this.onDesktopSizeUpdateHandler = function () {}; |
| 51 /** @param {!Array.<string>} capabilities The negotiated capabilities. */ | 51 /** @param {!Array.<string>} capabilities The negotiated capabilities. */ |
| 52 this.onSetCapabilitiesHandler = function (capabilities) {}; | 52 this.onSetCapabilitiesHandler = function (capabilities) {}; |
| 53 this.fetchPinHandler = function () {}; | 53 this.fetchPinHandler = function (supportsPairing) {}; |
| 54 | 54 |
| 55 /** @type {number} */ | 55 /** @type {number} */ |
| 56 this.pluginApiVersion_ = -1; | 56 this.pluginApiVersion_ = -1; |
| 57 /** @type {Array.<string>} */ | 57 /** @type {Array.<string>} */ |
| 58 this.pluginApiFeatures_ = []; | 58 this.pluginApiFeatures_ = []; |
| 59 /** @type {number} */ | 59 /** @type {number} */ |
| 60 this.pluginApiMinVersion_ = -1; | 60 this.pluginApiMinVersion_ = -1; |
| 61 /** @type {!Array.<string>} */ | 61 /** @type {!Array.<string>} */ |
| 62 this.capabilities_ = []; | 62 this.capabilities_ = []; |
| 63 /** @type {boolean} */ | 63 /** @type {boolean} */ |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 remoting.clientSession.onFirstFrameReceived(); | 256 remoting.clientSession.onFirstFrameReceived(); |
| 257 } | 257 } |
| 258 } else if (message.method == 'onConnectionReady') { | 258 } else if (message.method == 'onConnectionReady') { |
| 259 if (typeof message.data['ready'] != 'boolean') { | 259 if (typeof message.data['ready'] != 'boolean') { |
| 260 console.error('Received incorrect onConnectionReady message.'); | 260 console.error('Received incorrect onConnectionReady message.'); |
| 261 return; | 261 return; |
| 262 } | 262 } |
| 263 var ready = /** @type {boolean} */ message.data['ready']; | 263 var ready = /** @type {boolean} */ message.data['ready']; |
| 264 this.onConnectionReadyHandler(ready); | 264 this.onConnectionReadyHandler(ready); |
| 265 } else if (message.method == 'fetchPin') { | 265 } else if (message.method == 'fetchPin') { |
| 266 this.fetchPinHandler(); | 266 // The pairingSupported value in the dictionary indicates whether both |
| 267 // client and host support pairing. If the client doesn't support pairing, |
| 268 // then the value won't be there at all, so give it a default of false. |
| 269 /** @type {boolean} */ |
| 270 var pairingSupported = false; |
| 271 if ('pairingSupported' in message.data) { |
| 272 pairingSupported = |
| 273 /** @type {boolean} */ message.data['pairingSupported']; |
| 274 if (typeof pairingSupported != 'boolean') { |
| 275 console.error('Received incorrect fetchPin message.'); |
| 276 return; |
| 277 } |
| 278 } |
| 279 this.fetchPinHandler(pairingSupported); |
| 267 } else if (message.method == 'setCapabilities') { | 280 } else if (message.method == 'setCapabilities') { |
| 268 if (typeof message.data['capabilities'] != 'string') { | 281 if (typeof message.data['capabilities'] != 'string') { |
| 269 console.error('Received incorrect setCapabilities message.'); | 282 console.error('Received incorrect setCapabilities message.'); |
| 270 return; | 283 return; |
| 271 } | 284 } |
| 272 | 285 |
| 273 /** @type {!Array.<string>} */ | 286 /** @type {!Array.<string>} */ |
| 274 var capabilities = tokenize(message.data['capabilities']); | 287 var capabilities = tokenize(message.data['capabilities']); |
| 275 this.onSetCapabilitiesHandler(capabilities); | 288 this.onSetCapabilitiesHandler(capabilities); |
| 276 } else if (message.method == 'fetchThirdPartyToken') { | 289 } else if (message.method == 'fetchThirdPartyToken') { |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 this.plugin.width = width; | 580 this.plugin.width = width; |
| 568 this.plugin.height = height; | 581 this.plugin.height = height; |
| 569 // Center the plugin just underneath the "Connnecting..." dialog. | 582 // Center the plugin just underneath the "Connnecting..." dialog. |
| 570 var parentNode = this.plugin.parentNode; | 583 var parentNode = this.plugin.parentNode; |
| 571 var dialog = document.getElementById('client-dialog'); | 584 var dialog = document.getElementById('client-dialog'); |
| 572 var dialogRect = dialog.getBoundingClientRect(); | 585 var dialogRect = dialog.getBoundingClientRect(); |
| 573 parentNode.style.top = (dialogRect.bottom + 16) + 'px'; | 586 parentNode.style.top = (dialogRect.bottom + 16) + 'px'; |
| 574 parentNode.style.left = (window.innerWidth - width) / 2 + 'px'; | 587 parentNode.style.left = (window.innerWidth - width) / 2 + 'px'; |
| 575 } | 588 } |
| 576 }; | 589 }; |
| OLD | NEW |