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

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.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
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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 style.marginLeft = adjustMargin(style.marginLeft, dx, 716 style.marginLeft = adjustMargin(style.marginLeft, dx,
699 window.innerWidth, plugin.width, stopX); 717 window.innerWidth, plugin.width, stopX);
700 var stopY = { stop: false }; 718 var stopY = { stop: false };
701 style.marginTop = adjustMargin(style.marginTop, dy, 719 style.marginTop = adjustMargin(style.marginTop, dy,
702 window.innerHeight, plugin.height, stopY); 720 window.innerHeight, plugin.height, stopY);
703 return stopX.stop && stopY.stop; 721 return stopX.stop && stopY.stop;
704 } 722 }
705 723
706 /** 724 /**
707 * Enable or disable bump-scrolling. 725 * Enable or disable bump-scrolling.
726 * @private
708 * @param {boolean} enable True to enable bump-scrolling, false to disable it. 727 * @param {boolean} enable True to enable bump-scrolling, false to disable it.
709 */ 728 */
710 remoting.ClientSession.prototype.enableBumpScroll_ = function(enable) { 729 remoting.ClientSession.prototype.enableBumpScroll_ = function(enable) {
711 if (enable) { 730 if (enable) {
712 /** @type {null|function(Event):void} */ 731 /** @type {null|function(Event):void} */
713 this.onMouseMoveRef_ = this.onMouseMove_.bind(this); 732 this.onMouseMoveRef_ = this.onMouseMove_.bind(this);
714 this.plugin.element().addEventListener('mousemove', this.onMouseMoveRef_, 733 this.plugin.element().addEventListener('mousemove', this.onMouseMoveRef_,
715 false); 734 false);
716 } else { 735 } else {
717 this.plugin.element().removeEventListener('mousemove', this.onMouseMoveRef_, 736 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; 789 var lateAdjustment = 1 + (now - expected) / timeout;
771 if (!that.scroll_(lateAdjustment * dx, lateAdjustment * dy)) { 790 if (!that.scroll_(lateAdjustment * dx, lateAdjustment * dy)) {
772 that.bumpScrollTimer_ = window.setTimeout( 791 that.bumpScrollTimer_ = window.setTimeout(
773 function() { repeatScroll(now + timeout); }, 792 function() { repeatScroll(now + timeout); },
774 timeout); 793 timeout);
775 } 794 }
776 }; 795 };
777 repeatScroll(new Date().getTime()); 796 repeatScroll(new Date().getTime());
778 } 797 }
779 }; 798 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698