| 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 /** | 380 /** |
| 381 * Callback that the plugin invokes to indicate that the connection | 381 * Callback that the plugin invokes to indicate that the connection |
| 382 * status has changed. | 382 * status has changed. |
| 383 * | 383 * |
| 384 * @param {remoting.ClientSession.State} status The plugin's status. | 384 * @param {remoting.ClientSession.State} status The plugin's status. |
| 385 * @param {remoting.ClientSession.ConnectionError} error The plugin's error | 385 * @param {remoting.ClientSession.ConnectionError} error The plugin's error |
| 386 * state, if any. | 386 * state, if any. |
| 387 */ | 387 */ |
| 388 remoting.ClientSession.prototype.onConnectionStatusUpdate = | 388 remoting.ClientSession.prototype.onConnectionStatusUpdate = |
| 389 function(status, error) { | 389 function(status, error) { |
| 390 if (status == remoting.ClientSession.State.CONNECTED) { | 390 if (status == remoting.ClientSession.State.FAILED) { |
| 391 remoting.desktopConnectedView.onConnected(); | |
| 392 } else if (status == remoting.ClientSession.State.FAILED) { | |
| 393 switch (error) { | 391 switch (error) { |
| 394 case remoting.ClientSession.ConnectionError.HOST_IS_OFFLINE: | 392 case remoting.ClientSession.ConnectionError.HOST_IS_OFFLINE: |
| 395 this.error_ = new remoting.Error( | 393 this.error_ = new remoting.Error( |
| 396 remoting.Error.Tag.HOST_IS_OFFLINE); | 394 remoting.Error.Tag.HOST_IS_OFFLINE); |
| 397 break; | 395 break; |
| 398 case remoting.ClientSession.ConnectionError.SESSION_REJECTED: | 396 case remoting.ClientSession.ConnectionError.SESSION_REJECTED: |
| 399 this.error_ = new remoting.Error( | 397 this.error_ = new remoting.Error( |
| 400 remoting.Error.Tag.INVALID_ACCESS_CODE); | 398 remoting.Error.Tag.INVALID_ACCESS_CODE); |
| 401 break; | 399 break; |
| 402 case remoting.ClientSession.ConnectionError.INCOMPATIBLE_PROTOCOL: | 400 case remoting.ClientSession.ConnectionError.INCOMPATIBLE_PROTOCOL: |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 // TODO(jamiewalch): Currently, the logic for determining whether or not the | 441 // TODO(jamiewalch): Currently, the logic for determining whether or not the |
| 444 // connection is available is based solely on whether or not any video frames | 442 // connection is available is based solely on whether or not any video frames |
| 445 // have been received recently. which leads to poor UX on slow connections. | 443 // have been received recently. which leads to poor UX on slow connections. |
| 446 // Re-enable this once crbug.com/435315 has been fixed. | 444 // Re-enable this once crbug.com/435315 has been fixed. |
| 447 var ignoreVideoChannelState = true; | 445 var ignoreVideoChannelState = true; |
| 448 if (ignoreVideoChannelState) { | 446 if (ignoreVideoChannelState) { |
| 449 console.log('Video channel ' + (ready ? '' : 'not ') + 'ready.'); | 447 console.log('Video channel ' + (ready ? '' : 'not ') + 'ready.'); |
| 450 return; | 448 return; |
| 451 } | 449 } |
| 452 | 450 |
| 453 remoting.desktopConnectedView.onConnectionReady(ready); | |
| 454 | |
| 455 this.raiseEvent(remoting.ClientSession.Events.videoChannelStateChanged, | 451 this.raiseEvent(remoting.ClientSession.Events.videoChannelStateChanged, |
| 456 ready); | 452 ready); |
| 457 }; | 453 }; |
| 458 | 454 |
| 459 /** | 455 /** |
| 460 * Called when the client-host capabilities negotiation is complete. | 456 * Called when the client-host capabilities negotiation is complete. |
| 461 * TODO(kelvinp): Move this function out of ClientSession. | 457 * TODO(kelvinp): Move this function out of ClientSession. |
| 462 * | 458 * |
| 463 * @param {!Array<string>} capabilities The set of capabilities negotiated | 459 * @param {!Array<string>} capabilities The set of capabilities negotiated |
| 464 * between the client and host. | 460 * between the client and host. |
| 465 * @return {void} Nothing. | 461 * @return {void} Nothing. |
| 466 * @private | 462 * @private |
| 467 */ | 463 */ |
| 468 remoting.ClientSession.prototype.onSetCapabilities = function(capabilities) { | 464 remoting.ClientSession.prototype.onSetCapabilities = function(capabilities) { |
| 469 if (this.capabilities_ != null) { | 465 if (this.capabilities_ != null) { |
| 470 console.error('onSetCapabilities_() is called more than once'); | 466 console.error('onSetCapabilities_() is called more than once'); |
| 471 return; | 467 return; |
| 472 } | 468 } |
| 473 | 469 |
| 474 this.capabilities_ = capabilities; | 470 this.capabilities_ = capabilities; |
| 475 if (this.hasCapability(remoting.ClientSession.Capability.GOOGLE_DRIVE)) { | 471 if (this.hasCapability(remoting.ClientSession.Capability.GOOGLE_DRIVE)) { |
| 476 this.sendGoogleDriveAccessToken_(); | 472 this.sendGoogleDriveAccessToken_(); |
| 477 } | 473 } |
| 478 if (this.hasCapability( | |
| 479 remoting.ClientSession.Capability.VIDEO_RECORDER)) { | |
| 480 remoting.desktopConnectedView.initVideoFrameRecorder(); | |
| 481 } | |
| 482 }; | 474 }; |
| 483 | 475 |
| 484 /** | 476 /** |
| 485 * @param {string} type | 477 * @param {string} type |
| 486 * @param {string} data | 478 * @param {string} data |
| 487 */ | 479 */ |
| 488 remoting.ClientSession.prototype.onExtensionMessage = function(type, data) { | 480 remoting.ClientSession.prototype.onExtensionMessage = function(type, data) { |
| 489 this.onExtensionMessageHandler_(type, data); | 481 this.onExtensionMessageHandler_(type, data); |
| 490 }; | 482 }; |
| 491 | 483 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 var sendError = function(error) { | 598 var sendError = function(error) { |
| 607 console.log('Failed to refresh access token: ' + error.toString()); | 599 console.log('Failed to refresh access token: ' + error.toString()); |
| 608 }; | 600 }; |
| 609 remoting.identity.getNewToken(). | 601 remoting.identity.getNewToken(). |
| 610 then(sendToken). | 602 then(sendToken). |
| 611 catch(remoting.Error.handler(sendError)); | 603 catch(remoting.Error.handler(sendError)); |
| 612 window.setTimeout(this.sendGoogleDriveAccessToken_.bind(this), | 604 window.setTimeout(this.sendGoogleDriveAccessToken_.bind(this), |
| 613 remoting.ACCESS_TOKEN_RESEND_INTERVAL_MS); | 605 remoting.ACCESS_TOKEN_RESEND_INTERVAL_MS); |
| 614 }; | 606 }; |
| 615 | 607 |
| 616 /** | |
| 617 * Enables or disables rendering of dirty regions for debugging. | |
| 618 * @param {boolean} enable True to enable rendering. | |
| 619 */ | |
| 620 remoting.ClientSession.prototype.enableDebugRegion = function(enable) { | |
| 621 if (enable) { | |
| 622 this.plugin_.setDebugDirtyRegionHandler( | |
| 623 remoting.desktopConnectedView.handleDebugRegion.bind( | |
| 624 remoting.desktopConnectedView)); | |
| 625 } else { | |
| 626 this.plugin_.setDebugDirtyRegionHandler(null); | |
| 627 } | |
| 628 } | |
| OLD | NEW |