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 /** @param {!Array.<string>} capabilities The negotiated capabilities. */ | 51 /** @param {!Array.<string>} capabilities The negotiated capabilities. */ |
45 this.onSetCapabilitiesHandler = function (capabilities) {}; | 52 this.onSetCapabilitiesHandler = function (capabilities) {}; |
46 this.fetchPinHandler = function () {}; | 53 this.fetchPinHandler = function () {}; |
47 | 54 |
48 /** @type {number} */ | 55 /** @type {number} */ |
49 this.pluginApiVersion_ = -1; | 56 this.pluginApiVersion_ = -1; |
50 /** @type {Array.<string>} */ | 57 /** @type {Array.<string>} */ |
51 this.pluginApiFeatures_ = []; | 58 this.pluginApiFeatures_ = []; |
52 /** @type {number} */ | 59 /** @type {number} */ |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 this.fetchPinHandler(); | 266 this.fetchPinHandler(); |
260 } else if (message.method == 'setCapabilities') { | 267 } else if (message.method == 'setCapabilities') { |
261 if (typeof message.data['capabilities'] != 'string') { | 268 if (typeof message.data['capabilities'] != 'string') { |
262 console.error('Received incorrect setCapabilities message.'); | 269 console.error('Received incorrect setCapabilities message.'); |
263 return; | 270 return; |
264 } | 271 } |
265 | 272 |
266 /** @type {!Array.<string>} */ | 273 /** @type {!Array.<string>} */ |
267 var capabilities = tokenize(message.data['capabilities']); | 274 var capabilities = tokenize(message.data['capabilities']); |
268 this.onSetCapabilitiesHandler(capabilities); | 275 this.onSetCapabilitiesHandler(capabilities); |
| 276 } else if (message.method == 'fetchThirdPartyToken') { |
| 277 if (typeof message.data['tokenUrl'] != 'string' || |
| 278 typeof message.data['hostPublicKey'] != 'string' || |
| 279 typeof message.data['scope'] != 'string') { |
| 280 console.error('Received incorrect fetchThirdPartyToken message.'); |
| 281 return; |
| 282 } |
| 283 var tokenUrl = /** @type {string} */ message.data['tokenUrl']; |
| 284 var hostPublicKey = |
| 285 /** @type {string} */ message.data['hostPublicKey']; |
| 286 var scope = /** @type {string} */ message.data['scope']; |
| 287 this.fetchThirdPartyTokenHandler(tokenUrl, hostPublicKey, scope); |
269 } | 288 } |
270 }; | 289 }; |
271 | 290 |
272 /** | 291 /** |
273 * Deletes the plugin. | 292 * Deletes the plugin. |
274 */ | 293 */ |
275 remoting.ClientPluginAsync.prototype.cleanup = function() { | 294 remoting.ClientPluginAsync.prototype.cleanup = function() { |
276 this.plugin.parentNode.removeChild(this.plugin); | 295 this.plugin.parentNode.removeChild(this.plugin); |
277 }; | 296 }; |
278 | 297 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 remoting.ClientPluginAsync.prototype.useAsyncPinDialog = | 535 remoting.ClientPluginAsync.prototype.useAsyncPinDialog = |
517 function() { | 536 function() { |
518 if (!this.hasFeature(remoting.ClientPlugin.Feature.ASYNC_PIN)) { | 537 if (!this.hasFeature(remoting.ClientPlugin.Feature.ASYNC_PIN)) { |
519 return; | 538 return; |
520 } | 539 } |
521 this.plugin.postMessage(JSON.stringify( | 540 this.plugin.postMessage(JSON.stringify( |
522 { method: 'useAsyncPinDialog', data: {} })); | 541 { method: 'useAsyncPinDialog', data: {} })); |
523 }; | 542 }; |
524 | 543 |
525 /** | 544 /** |
| 545 * Sets the third party authentication token and shared secret. |
| 546 * |
| 547 * @param {string} token The token received from the token URL. |
| 548 * @param {string} sharedSecret Shared secret received from the token URL. |
| 549 */ |
| 550 remoting.ClientPluginAsync.prototype.onThirdPartyTokenFetched = function( |
| 551 token, sharedSecret) { |
| 552 this.plugin.postMessage(JSON.stringify( |
| 553 { method: 'onThirdPartyTokenFetched', |
| 554 data: { token: token, sharedSecret: sharedSecret}})); |
| 555 }; |
| 556 |
| 557 /** |
526 * If we haven't yet received a "hello" message from the plugin, change its | 558 * If we haven't yet received a "hello" message from the plugin, change its |
527 * size so that the user can confirm it if click-to-play is enabled, or can | 559 * size so that the user can confirm it if click-to-play is enabled, or can |
528 * see the "this plugin is disabled" message if it is actually disabled. | 560 * see the "this plugin is disabled" message if it is actually disabled. |
529 * @private | 561 * @private |
530 */ | 562 */ |
531 remoting.ClientPluginAsync.prototype.showPluginForClickToPlay_ = function() { | 563 remoting.ClientPluginAsync.prototype.showPluginForClickToPlay_ = function() { |
532 if (!this.helloReceived_) { | 564 if (!this.helloReceived_) { |
533 var width = 200; | 565 var width = 200; |
534 var height = 200; | 566 var height = 200; |
535 this.plugin.width = width; | 567 this.plugin.width = width; |
536 this.plugin.height = height; | 568 this.plugin.height = height; |
537 // Center the plugin just underneath the "Connnecting..." dialog. | 569 // Center the plugin just underneath the "Connnecting..." dialog. |
538 var parentNode = this.plugin.parentNode; | 570 var parentNode = this.plugin.parentNode; |
539 var dialog = document.getElementById('client-dialog'); | 571 var dialog = document.getElementById('client-dialog'); |
540 var dialogRect = dialog.getBoundingClientRect(); | 572 var dialogRect = dialog.getBoundingClientRect(); |
541 parentNode.style.top = (dialogRect.bottom + 16) + 'px'; | 573 parentNode.style.top = (dialogRect.bottom + 16) + 'px'; |
542 parentNode.style.left = (window.innerWidth - width) / 2 + 'px'; | 574 parentNode.style.left = (window.innerWidth - width) / 2 + 'px'; |
543 } | 575 } |
544 }; | 576 }; |
OLD | NEW |