| 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 remoting.ClientPlugin.Feature.HIGH_QUALITY_SCALING)); | 296 remoting.ClientPlugin.Feature.HIGH_QUALITY_SCALING)); |
| 297 | 297 |
| 298 /** @param {string} msg The IQ stanza to send. */ | 298 /** @param {string} msg The IQ stanza to send. */ |
| 299 this.plugin.onOutgoingIqHandler = this.sendIq_.bind(this); | 299 this.plugin.onOutgoingIqHandler = this.sendIq_.bind(this); |
| 300 /** @param {string} msg The message to log. */ | 300 /** @param {string} msg The message to log. */ |
| 301 this.plugin.onDebugMessageHandler = function(msg) { | 301 this.plugin.onDebugMessageHandler = function(msg) { |
| 302 console.log('plugin: ' + msg); | 302 console.log('plugin: ' + msg); |
| 303 }; | 303 }; |
| 304 | 304 |
| 305 this.plugin.onConnectionStatusUpdateHandler = | 305 this.plugin.onConnectionStatusUpdateHandler = |
| 306 this.connectionStatusUpdateCallback.bind(this); | 306 this.onConnectionStatusUpdate_.bind(this); |
| 307 this.plugin.onConnectionReadyHandler = |
| 308 this.onConnectionReady_.bind(this); |
| 307 this.plugin.onDesktopSizeUpdateHandler = | 309 this.plugin.onDesktopSizeUpdateHandler = |
| 308 this.onDesktopSizeChanged_.bind(this); | 310 this.onDesktopSizeChanged_.bind(this); |
| 309 | 311 |
| 310 this.connectPluginToWcs_(oauth2AccessToken); | 312 this.connectPluginToWcs_(oauth2AccessToken); |
| 311 }; | 313 }; |
| 312 | 314 |
| 313 /** | 315 /** |
| 314 * Deletes the <embed> element from the container, without sending a | 316 * Deletes the <embed> element from the container, without sending a |
| 315 * session_terminate request. This is to be called when the session was | 317 * session_terminate request. This is to be called when the session was |
| 316 * disconnected by the Host. | 318 * disconnected by the Host. |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 remoting.wcs.setOnIq(onIncomingIq); | 474 remoting.wcs.setOnIq(onIncomingIq); |
| 473 this.plugin.connect(this.hostJid, this.hostPublicKey, this.clientJid, | 475 this.plugin.connect(this.hostJid, this.hostPublicKey, this.clientJid, |
| 474 this.sharedSecret, this.authenticationMethods, | 476 this.sharedSecret, this.authenticationMethods, |
| 475 this.authenticationTag); | 477 this.authenticationTag); |
| 476 }; | 478 }; |
| 477 | 479 |
| 478 /** | 480 /** |
| 479 * Callback that the plugin invokes to indicate that the connection | 481 * Callback that the plugin invokes to indicate that the connection |
| 480 * status has changed. | 482 * status has changed. |
| 481 * | 483 * |
| 484 * @private |
| 482 * @param {number} status The plugin's status. | 485 * @param {number} status The plugin's status. |
| 483 * @param {number} error The plugin's error state, if any. | 486 * @param {number} error The plugin's error state, if any. |
| 484 */ | 487 */ |
| 485 remoting.ClientSession.prototype.connectionStatusUpdateCallback = | 488 remoting.ClientSession.prototype.onConnectionStatusUpdate_ = |
| 486 function(status, error) { | 489 function(status, error) { |
| 487 if (status == remoting.ClientSession.State.CONNECTED) { | 490 if (status == remoting.ClientSession.State.CONNECTED) { |
| 488 this.onDesktopSizeChanged_(); | 491 this.onDesktopSizeChanged_(); |
| 489 } else if (status == remoting.ClientSession.State.FAILED) { | 492 } else if (status == remoting.ClientSession.State.FAILED) { |
| 490 this.error = /** @type {remoting.ClientSession.ConnectionError} */ (error); | 493 this.error = /** @type {remoting.ClientSession.ConnectionError} */ (error); |
| 491 } | 494 } |
| 492 this.setState_(/** @type {remoting.ClientSession.State} */ (status)); | 495 this.setState_(/** @type {remoting.ClientSession.State} */ (status)); |
| 493 }; | 496 }; |
| 494 | 497 |
| 495 /** | 498 /** |
| 499 * Callback that the plugin invokes to indicate when the connection is |
| 500 * ready. |
| 501 * |
| 502 * @private |
| 503 * @param {boolean} ready True if the connection is ready. |
| 504 */ |
| 505 remoting.ClientSession.prototype.onConnectionReady_ = function(ready) { |
| 506 if (!ready) { |
| 507 this.plugin.element().classList.add("session-client-inactive"); |
| 508 } else { |
| 509 this.plugin.element().classList.remove("session-client-inactive"); |
| 510 } |
| 511 } |
| 512 |
| 513 /** |
| 496 * @private | 514 * @private |
| 497 * @param {remoting.ClientSession.State} newState The new state for the session. | 515 * @param {remoting.ClientSession.State} newState The new state for the session. |
| 498 * @return {void} Nothing. | 516 * @return {void} Nothing. |
| 499 */ | 517 */ |
| 500 remoting.ClientSession.prototype.setState_ = function(newState) { | 518 remoting.ClientSession.prototype.setState_ = function(newState) { |
| 501 var oldState = this.state; | 519 var oldState = this.state; |
| 502 this.state = newState; | 520 this.state = newState; |
| 503 if (this.onStateChange) { | 521 if (this.onStateChange) { |
| 504 this.onStateChange(oldState, newState); | 522 this.onStateChange(oldState, newState); |
| 505 } | 523 } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 style.marginLeft = adjustMargin(style.marginLeft, dx, | 718 style.marginLeft = adjustMargin(style.marginLeft, dx, |
| 701 window.innerWidth, plugin.width, stopX); | 719 window.innerWidth, plugin.width, stopX); |
| 702 var stopY = { stop: false }; | 720 var stopY = { stop: false }; |
| 703 style.marginTop = adjustMargin(style.marginTop, dy, | 721 style.marginTop = adjustMargin(style.marginTop, dy, |
| 704 window.innerHeight, plugin.height, stopY); | 722 window.innerHeight, plugin.height, stopY); |
| 705 return stopX.stop && stopY.stop; | 723 return stopX.stop && stopY.stop; |
| 706 } | 724 } |
| 707 | 725 |
| 708 /** | 726 /** |
| 709 * Enable or disable bump-scrolling. | 727 * Enable or disable bump-scrolling. |
| 728 * @private |
| 710 * @param {boolean} enable True to enable bump-scrolling, false to disable it. | 729 * @param {boolean} enable True to enable bump-scrolling, false to disable it. |
| 711 */ | 730 */ |
| 712 remoting.ClientSession.prototype.enableBumpScroll_ = function(enable) { | 731 remoting.ClientSession.prototype.enableBumpScroll_ = function(enable) { |
| 713 if (enable) { | 732 if (enable) { |
| 714 /** @type {null|function(Event):void} */ | 733 /** @type {null|function(Event):void} */ |
| 715 this.onMouseMoveRef_ = this.onMouseMove_.bind(this); | 734 this.onMouseMoveRef_ = this.onMouseMove_.bind(this); |
| 716 this.plugin.element().addEventListener('mousemove', this.onMouseMoveRef_, | 735 this.plugin.element().addEventListener('mousemove', this.onMouseMoveRef_, |
| 717 false); | 736 false); |
| 718 } else { | 737 } else { |
| 719 this.plugin.element().removeEventListener('mousemove', this.onMouseMoveRef_, | 738 this.plugin.element().removeEventListener('mousemove', this.onMouseMoveRef_, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 var lateAdjustment = 1 + (now - expected) / timeout; | 791 var lateAdjustment = 1 + (now - expected) / timeout; |
| 773 if (!that.scroll_(lateAdjustment * dx, lateAdjustment * dy)) { | 792 if (!that.scroll_(lateAdjustment * dx, lateAdjustment * dy)) { |
| 774 that.bumpScrollTimer_ = window.setTimeout( | 793 that.bumpScrollTimer_ = window.setTimeout( |
| 775 function() { repeatScroll(now + timeout); }, | 794 function() { repeatScroll(now + timeout); }, |
| 776 timeout); | 795 timeout); |
| 777 } | 796 } |
| 778 }; | 797 }; |
| 779 repeatScroll(new Date().getTime()); | 798 repeatScroll(new Date().getTime()); |
| 780 } | 799 } |
| 781 }; | 800 }; |
| OLD | NEW |