| 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 22 matching lines...) Expand all Loading... |
| 33 this.onOutgoingIqHandler = function (iq) {}; | 33 this.onOutgoingIqHandler = function (iq) {}; |
| 34 /** @param {string} message Log message. */ | 34 /** @param {string} message Log message. */ |
| 35 this.onDebugMessageHandler = function (message) {}; | 35 this.onDebugMessageHandler = function (message) {}; |
| 36 /** | 36 /** |
| 37 * @param {number} state The connection state. | 37 * @param {number} state The connection state. |
| 38 * @param {number} error The error code, if any. | 38 * @param {number} error The error code, if any. |
| 39 */ | 39 */ |
| 40 this.onConnectionStatusUpdateHandler = function(state, error) {}; | 40 this.onConnectionStatusUpdateHandler = function(state, error) {}; |
| 41 /** @param {boolean} ready Connection ready state. */ | 41 /** @param {boolean} ready Connection ready state. */ |
| 42 this.onConnectionReadyHandler = function(ready) {}; | 42 this.onConnectionReadyHandler = function(ready) {}; |
| 43 /** |
| 44 * @param {string} tokenUrl Token request URL, received from the host. |
| 45 * @param {string} hostPublicKey Public key for the host. |
| 46 * @param {string} scope OAuth scope to request the token for. |
| 47 */ |
| 48 this.fetchThirdPartyTokenHandler = function( |
| 49 tokenUrl, hostPublicKey, scope) {}; |
| 43 this.onDesktopSizeUpdateHandler = function () {}; | 50 this.onDesktopSizeUpdateHandler = function () {}; |
| 44 this.fetchPinHandler = function () {}; | 51 this.fetchPinHandler = function () {}; |
| 45 | 52 |
| 46 /** @type {number} */ | 53 /** @type {number} */ |
| 47 this.pluginApiVersion_ = -1; | 54 this.pluginApiVersion_ = -1; |
| 48 /** @type {Array.<string>} */ | 55 /** @type {Array.<string>} */ |
| 49 this.pluginApiFeatures_ = []; | 56 this.pluginApiFeatures_ = []; |
| 50 /** @type {number} */ | 57 /** @type {number} */ |
| 51 this.pluginApiMinVersion_ = -1; | 58 this.pluginApiMinVersion_ = -1; |
| 52 /** @type {boolean} */ | 59 /** @type {boolean} */ |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 208 } |
| 202 } else if (message.method == 'onConnectionReady') { | 209 } else if (message.method == 'onConnectionReady') { |
| 203 if (typeof message.data['ready'] != 'boolean') { | 210 if (typeof message.data['ready'] != 'boolean') { |
| 204 console.error('Received incorrect onConnectionReady message.'); | 211 console.error('Received incorrect onConnectionReady message.'); |
| 205 return; | 212 return; |
| 206 } | 213 } |
| 207 var ready = /** @type {boolean} */ message.data['ready']; | 214 var ready = /** @type {boolean} */ message.data['ready']; |
| 208 this.onConnectionReadyHandler(ready); | 215 this.onConnectionReadyHandler(ready); |
| 209 } else if (message.method == 'fetchPin') { | 216 } else if (message.method == 'fetchPin') { |
| 210 this.fetchPinHandler(); | 217 this.fetchPinHandler(); |
| 218 } else if (message.method == 'fetchThirdPartyToken') { |
| 219 if (typeof message.data['tokenUrl'] != 'string' || |
| 220 typeof message.data['hostPublicKey'] != 'string' || |
| 221 typeof message.data['scope'] != 'string') { |
| 222 console.error('Received incorrect fetchThirdPartyToken message.'); |
| 223 return; |
| 224 } |
| 225 var tokenUrl = /** @type {string} */ message.data['tokenUrl']; |
| 226 var hostPublicKey = |
| 227 /** @type {string} */ message.data['hostPublicKey']; |
| 228 var scope = /** @type {string} */ message.data['scope']; |
| 229 this.fetchThirdPartyTokenHandler(tokenUrl, hostPublicKey, scope); |
| 211 } | 230 } |
| 212 }; | 231 }; |
| 213 | 232 |
| 214 /** | 233 /** |
| 215 * Deletes the plugin. | 234 * Deletes the plugin. |
| 216 */ | 235 */ |
| 217 remoting.ClientPluginAsync.prototype.cleanup = function() { | 236 remoting.ClientPluginAsync.prototype.cleanup = function() { |
| 218 this.plugin.parentNode.removeChild(this.plugin); | 237 this.plugin.parentNode.removeChild(this.plugin); |
| 219 }; | 238 }; |
| 220 | 239 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 remoting.ClientPluginAsync.prototype.useAsyncPinDialog = | 476 remoting.ClientPluginAsync.prototype.useAsyncPinDialog = |
| 458 function() { | 477 function() { |
| 459 if (!this.hasFeature(remoting.ClientPlugin.Feature.ASYNC_PIN)) { | 478 if (!this.hasFeature(remoting.ClientPlugin.Feature.ASYNC_PIN)) { |
| 460 return; | 479 return; |
| 461 } | 480 } |
| 462 this.plugin.postMessage(JSON.stringify( | 481 this.plugin.postMessage(JSON.stringify( |
| 463 { method: 'useAsyncPinDialog', data: {} })); | 482 { method: 'useAsyncPinDialog', data: {} })); |
| 464 }; | 483 }; |
| 465 | 484 |
| 466 /** | 485 /** |
| 486 * Sets the third party authentication token and shared secret. |
| 487 * |
| 488 * @param {string} token The token received from the token URL. |
| 489 * @param {string} sharedSecret Shared secret received from the token URL. |
| 490 */ |
| 491 remoting.ClientPluginAsync.prototype.onThirdPartyTokenFetched = function( |
| 492 token, sharedSecret) { |
| 493 this.plugin.postMessage(JSON.stringify( |
| 494 { method: 'onThirdPartyTokenFetched', |
| 495 data: { token: token, sharedSecret: sharedSecret}})); |
| 496 }; |
| 497 |
| 498 /** |
| 467 * If we haven't yet received a "hello" message from the plugin, change its | 499 * If we haven't yet received a "hello" message from the plugin, change its |
| 468 * size so that the user can confirm it if click-to-play is enabled, or can | 500 * size so that the user can confirm it if click-to-play is enabled, or can |
| 469 * see the "this plugin is disabled" message if it is actually disabled. | 501 * see the "this plugin is disabled" message if it is actually disabled. |
| 470 * @private | 502 * @private |
| 471 */ | 503 */ |
| 472 remoting.ClientPluginAsync.prototype.showPluginForClickToPlay_ = function() { | 504 remoting.ClientPluginAsync.prototype.showPluginForClickToPlay_ = function() { |
| 473 if (!this.helloReceived_) { | 505 if (!this.helloReceived_) { |
| 474 var width = 200; | 506 var width = 200; |
| 475 var height = 200; | 507 var height = 200; |
| 476 this.plugin.width = width; | 508 this.plugin.width = width; |
| 477 this.plugin.height = height; | 509 this.plugin.height = height; |
| 478 // Center the plugin just underneath the "Connnecting..." dialog. | 510 // Center the plugin just underneath the "Connnecting..." dialog. |
| 479 var parentNode = this.plugin.parentNode; | 511 var parentNode = this.plugin.parentNode; |
| 480 var dialog = document.getElementById('client-dialog'); | 512 var dialog = document.getElementById('client-dialog'); |
| 481 var dialogRect = dialog.getBoundingClientRect(); | 513 var dialogRect = dialog.getBoundingClientRect(); |
| 482 parentNode.style.top = (dialogRect.bottom + 16) + 'px'; | 514 parentNode.style.top = (dialogRect.bottom + 16) + 'px'; |
| 483 parentNode.style.left = (window.innerWidth - width) / 2 + 'px'; | 515 parentNode.style.left = (window.innerWidth - width) / 2 + 'px'; |
| 484 } | 516 } |
| 485 }; | 517 }; |
| OLD | NEW |