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

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: Simplified onShow callback. 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
« no previous file with comments | « remoting/webapp/_locales/en/messages.json ('k') | remoting/webapp/event_handlers.js » ('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) 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 {function():void} @private */
68 this.callEnableShrink_ = function() { that.setScaleToFit(true); };
69 /** @type {function():void} @private */
70 this.callDisableShrink_ = function() { that.setScaleToFit(false); };
71 /** @type {function():void} @private */
72 this.callToggleFullScreen_ = function() { that.toggleFullScreen_(); };
73 /** @type {remoting.MenuButton} @private */
74 this.screenOptionsMenu_ = new remoting.MenuButton(
75 document.getElementById('screen-options-menu'),
76 function() { that.onShowOptionsMenu_(); }
77 );
78 /** @type {HTMLElement} @private */
79 this.shrinkToFit_ = document.getElementById('enable-shrink-to-fit');
80 /** @type {HTMLElement} @private */
81 this.originalSize_ = document.getElementById('disable-shrink-to-fit');
82 /** @type {HTMLElement} @private */
83 this.fullScreen_ = document.getElementById('toggle-full-screen');
84 this.shrinkToFit_.addEventListener('click', this.callEnableShrink_, false);
85 this.originalSize_.addEventListener('click', this.callDisableShrink_, false);
86 this.fullScreen_.addEventListener('click', this.callToggleFullScreen_, 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 */ 312 */
293 remoting.ClientSession.prototype.removePlugin = function() { 313 remoting.ClientSession.prototype.removePlugin = function() {
294 if (this.plugin) { 314 if (this.plugin) {
295 this.plugin.element().removeEventListener( 315 this.plugin.element().removeEventListener(
296 'focus', this.callPluginGotFocus_, false); 316 'focus', this.callPluginGotFocus_, false);
297 this.plugin.element().removeEventListener( 317 this.plugin.element().removeEventListener(
298 'blur', this.callPluginLostFocus_, false); 318 'blur', this.callPluginLostFocus_, false);
299 this.plugin.cleanup(); 319 this.plugin.cleanup();
300 this.plugin = null; 320 this.plugin = null;
301 } 321 }
322 this.shrinkToFit_.removeEventListener('click', this.callEnableShrink_, false);
323 this.originalSize_.removeEventListener('click', this.callDisableShrink_,
324 false);
325 this.fullScreen_.removeEventListener('click', this.callToggleFullScreen_,
326 false);
302 }; 327 };
303 328
304 /** 329 /**
305 * Deletes the <embed> element from the container and disconnects. 330 * Deletes the <embed> element from the container and disconnects.
306 * 331 *
307 * @return {void} Nothing. 332 * @return {void} Nothing.
308 */ 333 */
309 remoting.ClientSession.prototype.disconnect = function() { 334 remoting.ClientSession.prototype.disconnect = function() {
310 // The plugin won't send a state change notification, so we explicitly log 335 // The plugin won't send a state change notification, so we explicitly log
311 // the fact that the connection has closed. 336 // the fact that the connection has closed.
(...skipping 22 matching lines...) Expand all
334 359
335 /** 360 /**
336 * Enables or disables the client's scale-to-fit feature. 361 * Enables or disables the client's scale-to-fit feature.
337 * 362 *
338 * @param {boolean} scaleToFit True to enable scale-to-fit, false otherwise. 363 * @param {boolean} scaleToFit True to enable scale-to-fit, false otherwise.
339 * @return {void} Nothing. 364 * @return {void} Nothing.
340 */ 365 */
341 remoting.ClientSession.prototype.setScaleToFit = function(scaleToFit) { 366 remoting.ClientSession.prototype.setScaleToFit = function(scaleToFit) {
342 this.scaleToFit = scaleToFit; 367 this.scaleToFit = scaleToFit;
343 this.updateDimensions(); 368 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 } 369 }
351 370
352 /** 371 /**
353 * Returns whether the client is currently scaling the host to fit the tab. 372 * Returns whether the client is currently scaling the host to fit the tab.
354 * 373 *
355 * @return {boolean} The current scale-to-fit setting. 374 * @return {boolean} The current scale-to-fit setting.
356 */ 375 */
357 remoting.ClientSession.prototype.getScaleToFit = function() { 376 remoting.ClientSession.prototype.getScaleToFit = function() {
358 return this.scaleToFit; 377 return this.scaleToFit;
359 } 378 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 }; 550 };
532 551
533 /** 552 /**
534 * Logs statistics. 553 * Logs statistics.
535 * 554 *
536 * @param {remoting.ClientSession.PerfStats} stats 555 * @param {remoting.ClientSession.PerfStats} stats
537 */ 556 */
538 remoting.ClientSession.prototype.logStatistics = function(stats) { 557 remoting.ClientSession.prototype.logStatistics = function(stats) {
539 this.logToServer.logStatistics(stats, this.mode); 558 this.logToServer.logStatistics(stats, this.mode);
540 }; 559 };
560
561 /**
562 * Toggles between full-screen and windowed mode.
563 * @return {void} Nothing.
564 * @private
565 */
566 remoting.ClientSession.prototype.toggleFullScreen_ = function() {
567 if (document.webkitIsFullScreen) {
568 document.webkitCancelFullScreen();
569 } else {
570 document.body.webkitRequestFullScreen();
571 }
572 };
573
574 /**
575 * Updates the options menu to reflect the current scale-to-fit and full-screen
576 * settings.
577 * @return {void} Nothing.
578 * @private
579 */
580 remoting.ClientSession.prototype.onShowOptionsMenu_ = function() {
581 remoting.MenuButton.select(this.shrinkToFit_, this.scaleToFit);
582 remoting.MenuButton.select(this.originalSize_, !this.scaleToFit);
583 remoting.MenuButton.select(this.fullScreen_, document.webkitIsFullScreen);
584 };
OLDNEW
« no previous file with comments | « remoting/webapp/_locales/en/messages.json ('k') | remoting/webapp/event_handlers.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698