| 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 handling creation and teardown of a remoting client session. | 7 * Class handling creation and teardown of a remoting client session. |
| 8 * | 8 * |
| 9 * The ClientSession class controls lifetime of the client plugin | 9 * The ClientSession class controls lifetime of the client plugin |
| 10 * object and provides the plugin with the functionality it needs to | 10 * object and provides the plugin with the functionality it needs to |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 * | 28 * |
| 29 * @const | 29 * @const |
| 30 * @type {number} | 30 * @type {number} |
| 31 */ | 31 */ |
| 32 remoting.ACCESS_TOKEN_RESEND_INTERVAL_MS = 15 * 60 * 1000; | 32 remoting.ACCESS_TOKEN_RESEND_INTERVAL_MS = 15 * 60 * 1000; |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * @param {remoting.ClientPlugin} plugin | 35 * @param {remoting.ClientPlugin} plugin |
| 36 * @param {remoting.Host} host The host to connect to. | 36 * @param {remoting.Host} host The host to connect to. |
| 37 * @param {remoting.SignalStrategy} signalStrategy Signal strategy. | 37 * @param {remoting.SignalStrategy} signalStrategy Signal strategy. |
| 38 * @param {function(string, string):boolean} onExtensionMessage The handler for | |
| 39 * protocol extension messages. Returns true if a message is recognized; | |
| 40 * false otherwise. | |
| 41 * | 38 * |
| 42 * @constructor | 39 * @constructor |
| 43 * @extends {base.EventSourceImpl} | 40 * @extends {base.EventSourceImpl} |
| 44 * @implements {base.Disposable} | 41 * @implements {base.Disposable} |
| 45 * @implements {remoting.ClientPlugin.ConnectionEventHandler} | 42 * @implements {remoting.ClientPlugin.ConnectionEventHandler} |
| 46 */ | 43 */ |
| 47 remoting.ClientSession = function(plugin, host, signalStrategy, | 44 remoting.ClientSession = function(plugin, host, signalStrategy) { |
| 48 onExtensionMessage) { | |
| 49 base.inherits(this, base.EventSourceImpl); | 45 base.inherits(this, base.EventSourceImpl); |
| 50 | 46 |
| 51 /** @private */ | 47 /** @private */ |
| 52 this.state_ = remoting.ClientSession.State.INITIALIZING; | 48 this.state_ = remoting.ClientSession.State.INITIALIZING; |
| 53 | 49 |
| 54 /** @private {!remoting.Error} */ | 50 /** @private {!remoting.Error} */ |
| 55 this.error_ = remoting.Error.none(); | 51 this.error_ = remoting.Error.none(); |
| 56 | 52 |
| 57 /** @private */ | 53 /** @private */ |
| 58 this.host_ = host; | 54 this.host_ = host; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 73 remoting.formatIq.setJids(this.signalStrategy_.getJid(), host.jabberId); | 69 remoting.formatIq.setJids(this.signalStrategy_.getJid(), host.jabberId); |
| 74 | 70 |
| 75 /** | 71 /** |
| 76 * Allow host-offline error reporting to be suppressed in situations where it | 72 * Allow host-offline error reporting to be suppressed in situations where it |
| 77 * would not be useful, for example, when using a cached host JID. | 73 * would not be useful, for example, when using a cached host JID. |
| 78 * | 74 * |
| 79 * @type {boolean} @private | 75 * @type {boolean} @private |
| 80 */ | 76 */ |
| 81 this.logHostOfflineErrors_ = true; | 77 this.logHostOfflineErrors_ = true; |
| 82 | 78 |
| 83 /** @private {function(string, string):boolean} */ | |
| 84 this.onExtensionMessageHandler_ = onExtensionMessage; | |
| 85 | |
| 86 /** @private {remoting.ClientPlugin} */ | 79 /** @private {remoting.ClientPlugin} */ |
| 87 this.plugin_ = plugin; | 80 this.plugin_ = plugin; |
| 88 plugin.setConnectionEventHandler(this); | 81 plugin.setConnectionEventHandler(this); |
| 89 | 82 |
| 90 this.defineEvents(Object.keys(remoting.ClientSession.Events)); | 83 this.defineEvents(Object.keys(remoting.ClientSession.Events)); |
| 91 }; | 84 }; |
| 92 | 85 |
| 93 /** @enum {string} */ | 86 /** @enum {string} */ |
| 94 remoting.ClientSession.Events = { | 87 remoting.ClientSession.Events = { |
| 95 stateChanged: 'stateChanged', | 88 stateChanged: 'stateChanged', |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 return; | 460 return; |
| 468 } | 461 } |
| 469 | 462 |
| 470 this.capabilities_ = capabilities; | 463 this.capabilities_ = capabilities; |
| 471 if (this.hasCapability(remoting.ClientSession.Capability.GOOGLE_DRIVE)) { | 464 if (this.hasCapability(remoting.ClientSession.Capability.GOOGLE_DRIVE)) { |
| 472 this.sendGoogleDriveAccessToken_(); | 465 this.sendGoogleDriveAccessToken_(); |
| 473 } | 466 } |
| 474 }; | 467 }; |
| 475 | 468 |
| 476 /** | 469 /** |
| 477 * @param {string} type | |
| 478 * @param {string} data | |
| 479 */ | |
| 480 remoting.ClientSession.prototype.onExtensionMessage = function(type, data) { | |
| 481 this.onExtensionMessageHandler_(type, data); | |
| 482 }; | |
| 483 | |
| 484 /** | |
| 485 * @param {remoting.ClientSession.State} newState The new state for the session. | 470 * @param {remoting.ClientSession.State} newState The new state for the session. |
| 486 * @return {void} Nothing. | 471 * @return {void} Nothing. |
| 487 * @private | 472 * @private |
| 488 */ | 473 */ |
| 489 remoting.ClientSession.prototype.setState_ = function(newState) { | 474 remoting.ClientSession.prototype.setState_ = function(newState) { |
| 490 var oldState = this.state_; | 475 var oldState = this.state_; |
| 491 this.state_ = newState; | 476 this.state_ = newState; |
| 492 var state = this.state_; | 477 var state = this.state_; |
| 493 if (oldState == remoting.ClientSession.State.CONNECTING || | 478 if (oldState == remoting.ClientSession.State.CONNECTING || |
| 494 oldState == remoting.ClientSession.State.AUTHENTICATED) { | 479 oldState == remoting.ClientSession.State.AUTHENTICATED) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 'https://docs.google.com/feeds/', | 588 'https://docs.google.com/feeds/', |
| 604 'https://www.googleapis.com/auth/drive' | 589 'https://www.googleapis.com/auth/drive' |
| 605 ]; | 590 ]; |
| 606 remoting.identity.getNewToken(googleDriveScopes). | 591 remoting.identity.getNewToken(googleDriveScopes). |
| 607 then(sendToken). | 592 then(sendToken). |
| 608 catch(remoting.Error.handler(sendError)); | 593 catch(remoting.Error.handler(sendError)); |
| 609 window.setTimeout(this.sendGoogleDriveAccessToken_.bind(this), | 594 window.setTimeout(this.sendGoogleDriveAccessToken_.bind(this), |
| 610 remoting.ACCESS_TOKEN_RESEND_INTERVAL_MS); | 595 remoting.ACCESS_TOKEN_RESEND_INTERVAL_MS); |
| 611 }; | 596 }; |
| 612 | 597 |
| OLD | NEW |