Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: remoting/webapp/client_session.js

Issue 10692179: Propagate connection state from networking layer to UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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.onConnectionInactiveHandler =
308 this.onConnectionInactive_.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
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 * inactive.
501 *
502 * @private
503 * @param {boolean} inactive True if the connection is inactive.
504 */
505 remoting.ClientSession.prototype.onConnectionInactive_ =
506 function(inactive) {
507 if (inactive) {
508 this.plugin.element().classList.add("session-client-inactive");
509 } else {
510 this.plugin.element().classList.remove("session-client-inactive");
511 }
512 }
513
514 /**
496 * @private 515 * @private
497 * @param {remoting.ClientSession.State} newState The new state for the session. 516 * @param {remoting.ClientSession.State} newState The new state for the session.
498 * @return {void} Nothing. 517 * @return {void} Nothing.
499 */ 518 */
500 remoting.ClientSession.prototype.setState_ = function(newState) { 519 remoting.ClientSession.prototype.setState_ = function(newState) {
501 var oldState = this.state; 520 var oldState = this.state;
502 this.state = newState; 521 this.state = newState;
503 if (this.onStateChange) { 522 if (this.onStateChange) {
504 this.onStateChange(oldState, newState); 523 this.onStateChange(oldState, newState);
505 } 524 }
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 style.marginLeft = adjustMargin(style.marginLeft, dx, 717 style.marginLeft = adjustMargin(style.marginLeft, dx,
699 window.innerWidth, plugin.width, stopX); 718 window.innerWidth, plugin.width, stopX);
700 var stopY = { stop: false }; 719 var stopY = { stop: false };
701 style.marginTop = adjustMargin(style.marginTop, dy, 720 style.marginTop = adjustMargin(style.marginTop, dy,
702 window.innerHeight, plugin.height, stopY); 721 window.innerHeight, plugin.height, stopY);
703 return stopX.stop && stopY.stop; 722 return stopX.stop && stopY.stop;
704 } 723 }
705 724
706 /** 725 /**
707 * Enable or disable bump-scrolling. 726 * Enable or disable bump-scrolling.
727 * @private
708 * @param {boolean} enable True to enable bump-scrolling, false to disable it. 728 * @param {boolean} enable True to enable bump-scrolling, false to disable it.
709 */ 729 */
710 remoting.ClientSession.prototype.enableBumpScroll_ = function(enable) { 730 remoting.ClientSession.prototype.enableBumpScroll_ = function(enable) {
711 if (enable) { 731 if (enable) {
712 /** @type {null|function(Event):void} */ 732 /** @type {null|function(Event):void} */
713 this.onMouseMoveRef_ = this.onMouseMove_.bind(this); 733 this.onMouseMoveRef_ = this.onMouseMove_.bind(this);
714 this.plugin.element().addEventListener('mousemove', this.onMouseMoveRef_, 734 this.plugin.element().addEventListener('mousemove', this.onMouseMoveRef_,
715 false); 735 false);
716 } else { 736 } else {
717 this.plugin.element().removeEventListener('mousemove', this.onMouseMoveRef_, 737 this.plugin.element().removeEventListener('mousemove', this.onMouseMoveRef_,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 var lateAdjustment = 1 + (now - expected) / timeout; 790 var lateAdjustment = 1 + (now - expected) / timeout;
771 if (!that.scroll_(lateAdjustment * dx, lateAdjustment * dy)) { 791 if (!that.scroll_(lateAdjustment * dx, lateAdjustment * dy)) {
772 that.bumpScrollTimer_ = window.setTimeout( 792 that.bumpScrollTimer_ = window.setTimeout(
773 function() { repeatScroll(now + timeout); }, 793 function() { repeatScroll(now + timeout); },
774 timeout); 794 timeout);
775 } 795 }
776 }; 796 };
777 repeatScroll(new Date().getTime()); 797 repeatScroll(new Date().getTime());
778 } 798 }
779 }; 799 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698