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

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

Issue 9884001: Added screen options menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 this.plugin = null; 57 this.plugin = null;
58 this.scaleToFit = false; 58 this.scaleToFit = false;
59 this.logToServer = new remoting.LogToServer(); 59 this.logToServer = new remoting.LogToServer();
60 this.onStateChange = onStateChange; 60 this.onStateChange = onStateChange;
61 /** @type {remoting.ClientSession} */ 61 /** @type {remoting.ClientSession} */
62 var that = this; 62 var that = this;
63 /** @type {function():void} @private */ 63 /** @type {function():void} @private */
64 this.callPluginLostFocus_ = function() { that.pluginLostFocus_(); }; 64 this.callPluginLostFocus_ = function() { that.pluginLostFocus_(); };
65 /** @type {function():void} @private */ 65 /** @type {function():void} @private */
66 this.callPluginGotFocus_ = function() { that.pluginGotFocus_(); }; 66 this.callPluginGotFocus_ = function() { that.pluginGotFocus_(); };
67 /** @type {remoting.MenuButton} @private */
68 this.screenOptionsMenu_ = new remoting.MenuButton(
69 document.getElementById('screen-options-menu'),
70 function() { that.onShowOptionsMenu_(); }
71 );
72 /** @type {HTMLElement} @private */
73 this.shrinkToFit_ = document.getElementById('enable-shrink-to-fit');
74 /** @type {HTMLElement} @private */
75 this.originalSize_ = document.getElementById('disable-shrink-to-fit');
76 /** @type {HTMLElement} @private */
77 this.fullScreen_ = document.getElementById('toggle-full-screen');
78 this.shrinkToFit_.addEventListener('click',
79 function() { that.setScaleToFit(true); },
80 false);
81 this.originalSize_.addEventListener('click',
82 function() { that.setScaleToFit(false); },
83 false);
84 this.fullScreen_.addEventListener('click',
85 function() { that.toggleFullScreen_(); },
86 false);
67 }; 87 };
68 88
69 // Note that the positive values in both of these enums are copied directly 89 // Note that the positive values in both of these enums are copied directly
70 // from chromoting_scriptable_object.h and must be kept in sync. The negative 90 // from chromoting_scriptable_object.h and must be kept in sync. The negative
71 // values represent states transitions that occur within the web-app that have 91 // values represent states transitions that occur within the web-app that have
72 // no corresponding plugin state transition. 92 // no corresponding plugin state transition.
73 /** @enum {number} */ 93 /** @enum {number} */
74 remoting.ClientSession.State = { 94 remoting.ClientSession.State = {
75 CREATED: -3, 95 CREATED: -3,
76 BAD_PLUGIN_VERSION: -2, 96 BAD_PLUGIN_VERSION: -2,
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 354
335 /** 355 /**
336 * Enables or disables the client's scale-to-fit feature. 356 * Enables or disables the client's scale-to-fit feature.
337 * 357 *
338 * @param {boolean} scaleToFit True to enable scale-to-fit, false otherwise. 358 * @param {boolean} scaleToFit True to enable scale-to-fit, false otherwise.
339 * @return {void} Nothing. 359 * @return {void} Nothing.
340 */ 360 */
341 remoting.ClientSession.prototype.setScaleToFit = function(scaleToFit) { 361 remoting.ClientSession.prototype.setScaleToFit = function(scaleToFit) {
342 this.scaleToFit = scaleToFit; 362 this.scaleToFit = scaleToFit;
343 this.updateDimensions(); 363 this.updateDimensions();
344 var button = document.getElementById('toggle-scaling');
345 if (scaleToFit) {
346 button.classList.add('toggle-button-active');
347 } else {
348 button.classList.remove('toggle-button-active');
349 }
350 } 364 }
351 365
352 /** 366 /**
353 * Returns whether the client is currently scaling the host to fit the tab. 367 * Returns whether the client is currently scaling the host to fit the tab.
354 * 368 *
355 * @return {boolean} The current scale-to-fit setting. 369 * @return {boolean} The current scale-to-fit setting.
356 */ 370 */
357 remoting.ClientSession.prototype.getScaleToFit = function() { 371 remoting.ClientSession.prototype.getScaleToFit = function() {
358 return this.scaleToFit; 372 return this.scaleToFit;
359 } 373 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 }; 545 };
532 546
533 /** 547 /**
534 * Logs statistics. 548 * Logs statistics.
535 * 549 *
536 * @param {remoting.ClientSession.PerfStats} stats 550 * @param {remoting.ClientSession.PerfStats} stats
537 */ 551 */
538 remoting.ClientSession.prototype.logStatistics = function(stats) { 552 remoting.ClientSession.prototype.logStatistics = function(stats) {
539 this.logToServer.logStatistics(stats, this.mode); 553 this.logToServer.logStatistics(stats, this.mode);
540 }; 554 };
555
556 /**
557 * Toggles between full-screen and windowed mode.
558 * @return {void} Nothing.
559 * @private
560 */
561 remoting.ClientSession.prototype.toggleFullScreen_ = function() {
562 if (document.webkitIsFullScreen) {
563 document.webkitCancelFullScreen();
564 } else {
565 document.body.webkitRequestFullScreen();
566 }
567 };
568
569 /**
570 * Updates the options menu to reflect the current scale-to-fit and full-screen
571 * settings.
572 * @return {void} Nothing.
573 * @private
574 */
575 remoting.ClientSession.prototype.onShowOptionsMenu_ = function() {
576 if (this.scaleToFit) {
577 this.shrinkToFit_.classList.add(remoting.MenuButton.ITEM_SELECTED_CLASS);
578 this.originalSize_.classList.remove(
579 remoting.MenuButton.ITEM_SELECTED_CLASS);
580 } else {
581 this.shrinkToFit_.classList.remove(remoting.MenuButton.ITEM_SELECTED_CLASS);
582 this.originalSize_.classList.add(remoting.MenuButton.ITEM_SELECTED_CLASS);
583 }
584 if (document.webkitIsFullScreen) {
585 this.fullScreen_.classList.add(remoting.MenuButton.ITEM_SELECTED_CLASS);
586 } else {
587 this.fullScreen_.classList.remove(remoting.MenuButton.ITEM_SELECTED_CLASS);
588 }
589 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698