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

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

Issue 12207099: Update web-app client to use plugin notifyDeviceResolution API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 /** @private */ 57 /** @private */
58 this.resizeToClient_ = false; 58 this.resizeToClient_ = false;
59 /** @private */ 59 /** @private */
60 this.hasReceivedFrame_ = false; 60 this.hasReceivedFrame_ = false;
61 this.logToServer = new remoting.LogToServer(); 61 this.logToServer = new remoting.LogToServer();
62 /** @type {?function(remoting.ClientSession.State, 62 /** @type {?function(remoting.ClientSession.State,
63 remoting.ClientSession.State):void} */ 63 remoting.ClientSession.State):void} */
64 this.onStateChange_ = null; 64 this.onStateChange_ = null;
65 65
66 /** @type {number?} @private */ 66 /** @type {number?} @private */
67 this.notifyClientDimensionsTimer_ = null; 67 this.notifyClientResolutionTimer_ = null;
68 /** @type {number?} @private */ 68 /** @type {number?} @private */
69 this.bumpScrollTimer_ = null; 69 this.bumpScrollTimer_ = null;
70 70
71 /** 71 /**
72 * 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
73 * 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.
74 * 74 *
75 * @type {boolean} @private 75 * @type {boolean} @private
76 */ 76 */
77 this.logHostOfflineErrors_ = true; 77 this.logHostOfflineErrors_ = true;
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 * host to attempt to resize its desktop to match the client window size; 497 * host to attempt to resize its desktop to match the client window size;
498 * false to disable this behaviour for subsequent window resizes--the 498 * false to disable this behaviour for subsequent window resizes--the
499 * current host desktop size is not restored in this case. 499 * current host desktop size is not restored in this case.
500 * @return {void} Nothing. 500 * @return {void} Nothing.
501 * @private 501 * @private
502 */ 502 */
503 remoting.ClientSession.prototype.setScreenMode_ = 503 remoting.ClientSession.prototype.setScreenMode_ =
504 function(shrinkToFit, resizeToClient) { 504 function(shrinkToFit, resizeToClient) {
505 505
506 if (resizeToClient && !this.resizeToClient_) { 506 if (resizeToClient && !this.resizeToClient_) {
507 this.plugin.notifyClientDimensions(window.innerWidth, window.innerHeight); 507 this.plugin.notifyClientResolution(window.innerWidth,
508 window.innerHeight,
509 window.devicePixelRatio);
508 } 510 }
509 511
510 // If enabling shrink, reset bump-scroll offsets. 512 // If enabling shrink, reset bump-scroll offsets.
511 var needsScrollReset = shrinkToFit && !this.shrinkToFit_; 513 var needsScrollReset = shrinkToFit && !this.shrinkToFit_;
512 514
513 this.shrinkToFit_ = shrinkToFit; 515 this.shrinkToFit_ = shrinkToFit;
514 this.resizeToClient_ = resizeToClient; 516 this.resizeToClient_ = resizeToClient;
515 517
516 if (this.hostId != '') { 518 if (this.hostId != '') {
517 var options = {}; 519 var options = {};
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 * 622 *
621 * @private 623 * @private
622 * @param {number} status The plugin's status. 624 * @param {number} status The plugin's status.
623 * @param {number} error The plugin's error state, if any. 625 * @param {number} error The plugin's error state, if any.
624 */ 626 */
625 remoting.ClientSession.prototype.onConnectionStatusUpdate_ = 627 remoting.ClientSession.prototype.onConnectionStatusUpdate_ =
626 function(status, error) { 628 function(status, error) {
627 if (status == remoting.ClientSession.State.CONNECTED) { 629 if (status == remoting.ClientSession.State.CONNECTED) {
628 this.onDesktopSizeChanged_(); 630 this.onDesktopSizeChanged_();
629 if (this.resizeToClient_) { 631 if (this.resizeToClient_) {
630 this.plugin.notifyClientDimensions(window.innerWidth, window.innerHeight); 632 this.plugin.notifyClientResolution(window.innerWidth,
633 window.innerHeight,
634 window.devicePixelRatio);
631 } 635 }
632 } else if (status == remoting.ClientSession.State.FAILED) { 636 } else if (status == remoting.ClientSession.State.FAILED) {
633 this.error_ = /** @type {remoting.ClientSession.ConnectionError} */ (error); 637 this.error_ = /** @type {remoting.ClientSession.ConnectionError} */ (error);
634 } 638 }
635 this.setState_(/** @type {remoting.ClientSession.State} */ (status)); 639 this.setState_(/** @type {remoting.ClientSession.State} */ (status));
636 }; 640 };
637 641
638 /** 642 /**
639 * Callback that the plugin invokes to indicate when the connection is 643 * Callback that the plugin invokes to indicate when the connection is
640 * ready. 644 * ready.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 }; 685 };
682 686
683 /** 687 /**
684 * This is a callback that gets called when the window is resized. 688 * This is a callback that gets called when the window is resized.
685 * 689 *
686 * @return {void} Nothing. 690 * @return {void} Nothing.
687 */ 691 */
688 remoting.ClientSession.prototype.onResize = function() { 692 remoting.ClientSession.prototype.onResize = function() {
689 this.updateDimensions(); 693 this.updateDimensions();
690 694
691 if (this.notifyClientDimensionsTimer_) { 695 if (this.notifyClientResolutionTimer_) {
692 window.clearTimeout(this.notifyClientDimensionsTimer_); 696 window.clearTimeout(this.notifyClientResolutionTimer_);
693 this.notifyClientDimensionsTimer_ = null; 697 this.notifyClientResolutionTimer_ = null;
694 } 698 }
695 699
696 // Defer notifying the host of the change until the window stops resizing, to 700 // Defer notifying the host of the change until the window stops resizing, to
697 // avoid overloading the control channel with notifications. 701 // avoid overloading the control channel with notifications.
698 if (this.resizeToClient_) { 702 if (this.resizeToClient_) {
699 this.notifyClientDimensionsTimer_ = window.setTimeout( 703 this.notifyClientResolutionTimer_ = window.setTimeout(
700 this.plugin.notifyClientDimensions.bind(this.plugin, 704 this.plugin.notifyClientResolution.bind(this.plugin,
701 window.innerWidth, 705 window.innerWidth,
702 window.innerHeight), 706 window.innerHeight,
707 window.devicePixelRatio),
703 1000); 708 1000);
704 } 709 }
705 710
706 // If bump-scrolling is enabled, adjust the plugin margins to fully utilize 711 // If bump-scrolling is enabled, adjust the plugin margins to fully utilize
707 // the new window area. 712 // the new window area.
708 this.scroll_(0, 0); 713 this.scroll_(0, 0);
709 }; 714 };
710 715
711 /** 716 /**
712 * Requests that the host pause or resume video updates. 717 * Requests that the host pause or resume video updates.
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 var lateAdjustment = 1 + (now - expected) / timeout; 1021 var lateAdjustment = 1 + (now - expected) / timeout;
1017 if (!that.scroll_(lateAdjustment * dx, lateAdjustment * dy)) { 1022 if (!that.scroll_(lateAdjustment * dx, lateAdjustment * dy)) {
1018 that.bumpScrollTimer_ = window.setTimeout( 1023 that.bumpScrollTimer_ = window.setTimeout(
1019 function() { repeatScroll(now + timeout); }, 1024 function() { repeatScroll(now + timeout); },
1020 timeout); 1025 timeout);
1021 } 1026 }
1022 }; 1027 };
1023 repeatScroll(new Date().getTime()); 1028 repeatScroll(new Date().getTime());
1024 } 1029 }
1025 }; 1030 };
OLDNEW
« remoting/webapp/client_plugin_async.js ('K') | « remoting/webapp/client_plugin_async.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698