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

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

Issue 7821017: Center the desktop if it's smaller than the frame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 9 years, 3 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
« no previous file with comments | « remoting/webapp/me2mom/choice.css ('k') | remoting/webapp/me2mom/toolbar.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 * Session class that handles creation and teardown of a remoting session. 7 * Session class that handles creation and teardown of a remoting session.
8 * 8 *
9 * This abstracts a <embed> element and controls the plugin which does the 9 * This abstracts a <embed> element and controls the plugin which does the
10 * actual remoting work. There should be no UI code inside this class. It 10 * actual remoting work. There should be no UI code inside this class. It
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 345 }
346 }; 346 };
347 347
348 /** 348 /**
349 * This is a callback that gets called when the desktop size contained in the 349 * This is a callback that gets called when the desktop size contained in the
350 * the plugin has changed. 350 * the plugin has changed.
351 * 351 *
352 * @return {void} Nothing. 352 * @return {void} Nothing.
353 */ 353 */
354 remoting.ClientSession.prototype.onDesktopSizeChanged_ = function() { 354 remoting.ClientSession.prototype.onDesktopSizeChanged_ = function() {
355 var width = this.plugin.desktopWidth; 355 remoting.debug.log('desktop size changed: ' +
356 var height = this.plugin.desktopHeight; 356 this.plugin.desktopWidth + 'x' +
357 remoting.debug.log('desktop size changed: ' + width + 'x' + height); 357 this.plugin.desktopHeight);
358 this.plugin.width = width; 358 this.setScaleToFit(remoting.scaleToFit);
359 this.plugin.height = height;
360 }; 359 };
361 360
362 /** 361 /**
363 * Informs the plugin that it should scale itself. 362 * Informs the plugin that it should scale itself.
364 * 363 *
365 * @param {boolean} shouldScale If the plugin should scale itself. 364 * @param {boolean} shouldScale If the plugin should scale itself.
366 * @return {void} Nothing. 365 * @return {void} Nothing.
367 */ 366 */
368 remoting.ClientSession.prototype.setScaleToFit = function(shouldScale) { 367 remoting.ClientSession.prototype.setScaleToFit = function(shouldScale) {
369 if (shouldScale) { 368 if (shouldScale) {
(...skipping 18 matching lines...) Expand all
388 remoting.debug.log('scale up is not supported'); 387 remoting.debug.log('scale up is not supported');
389 scale = 1.0; 388 scale = 1.0;
390 } 389 }
391 390
392 this.plugin.width = this.plugin.desktopWidth * scale; 391 this.plugin.width = this.plugin.desktopWidth * scale;
393 this.plugin.height = this.plugin.desktopHeight * scale; 392 this.plugin.height = this.plugin.desktopHeight * scale;
394 } else { 393 } else {
395 this.plugin.width = this.plugin.desktopWidth; 394 this.plugin.width = this.plugin.desktopWidth;
396 this.plugin.height = this.plugin.desktopHeight; 395 this.plugin.height = this.plugin.desktopHeight;
397 } 396 }
397
398 // Resize the plugin's container. The container's style places its origin at
399 // the center of the page, so we use -ve margins to move that origin to the
400 // center of the container, rather than its top-left corner, so that it will
401 // appear centered on the page.
402 if (this.plugin.parentNode) {
403 var parentNode = this.plugin.parentNode;
404 parentNode.style["width"] = this.plugin.width + "px";
405 parentNode.style["height"] = this.plugin.height + "px";
406 parentNode.style["margin-left"] = -(this.plugin.width/2) + "px";
407 parentNode.style["margin-top"] = -(this.plugin.height/2) + "px";
408 }
409
398 remoting.debug.log('plugin size is now: ' + 410 remoting.debug.log('plugin size is now: ' +
399 this.plugin.width + ' x ' + this.plugin.height + '.'); 411 this.plugin.width + ' x ' + this.plugin.height + '.');
400 this.plugin.setScaleToFit(shouldScale); 412 this.plugin.setScaleToFit(shouldScale);
401 remoting.debug.log('scale to fit is now: ' + shouldScale); 413 remoting.debug.log('scale to fit is now: ' + shouldScale);
402 }; 414 };
403 415
404 /** 416 /**
405 * Returns an associative array with a set of stats for this connection. 417 * Returns an associative array with a set of stats for this connection.
406 * 418 *
407 * @return {Object} The connection statistics. 419 * @return {Object} The connection statistics.
408 */ 420 */
409 remoting.ClientSession.prototype.stats = function() { 421 remoting.ClientSession.prototype.stats = function() {
410 return { 422 return {
411 'video_bandwidth': this.plugin.videoBandwidth, 423 'video_bandwidth': this.plugin.videoBandwidth,
412 'capture_latency': this.plugin.videoCaptureLatency, 424 'capture_latency': this.plugin.videoCaptureLatency,
413 'encode_latency': this.plugin.videoEncodeLatency, 425 'encode_latency': this.plugin.videoEncodeLatency,
414 'decode_latency': this.plugin.videoDecodeLatency, 426 'decode_latency': this.plugin.videoDecodeLatency,
415 'render_latency': this.plugin.videoRenderLatency, 427 'render_latency': this.plugin.videoRenderLatency,
416 'roundtrip_latency': this.plugin.roundTripLatency 428 'roundtrip_latency': this.plugin.roundTripLatency
417 }; 429 };
418 }; 430 };
419 431
420 }()); 432 }());
OLDNEW
« no previous file with comments | « remoting/webapp/me2mom/choice.css ('k') | remoting/webapp/me2mom/toolbar.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698