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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/client_session.js
diff --git a/remoting/webapp/client_session.js b/remoting/webapp/client_session.js
index 4b5c45a16e717bf30815526bd66c22d5e19fea62..80d60f94138e2f8dffd5f284f7e019cda08a2c38 100644
--- a/remoting/webapp/client_session.js
+++ b/remoting/webapp/client_session.js
@@ -64,6 +64,26 @@ remoting.ClientSession = function(hostJid, hostPublicKey, sharedSecret,
this.callPluginLostFocus_ = function() { that.pluginLostFocus_(); };
/** @type {function():void} @private */
this.callPluginGotFocus_ = function() { that.pluginGotFocus_(); };
+ /** @type {remoting.MenuButton} @private */
+ this.screenOptionsMenu_ = new remoting.MenuButton(
+ document.getElementById('screen-options-menu'),
+ function() { that.onShowOptionsMenu_(); }
+ );
+ /** @type {HTMLElement} @private */
+ this.shrinkToFit_ = document.getElementById('enable-shrink-to-fit');
+ /** @type {HTMLElement} @private */
+ this.originalSize_ = document.getElementById('disable-shrink-to-fit');
+ /** @type {HTMLElement} @private */
+ this.fullScreen_ = document.getElementById('toggle-full-screen');
+ this.shrinkToFit_.addEventListener('click',
+ function() { that.setScaleToFit(true); },
+ false);
+ this.originalSize_.addEventListener('click',
+ function() { that.setScaleToFit(false); },
+ false);
+ this.fullScreen_.addEventListener('click',
+ function() { that.toggleFullScreen_(); },
+ false);
};
// Note that the positive values in both of these enums are copied directly
@@ -341,12 +361,6 @@ remoting.ClientSession.prototype.disconnect = function() {
remoting.ClientSession.prototype.setScaleToFit = function(scaleToFit) {
this.scaleToFit = scaleToFit;
this.updateDimensions();
- var button = document.getElementById('toggle-scaling');
- if (scaleToFit) {
- button.classList.add('toggle-button-active');
- } else {
- button.classList.remove('toggle-button-active');
- }
}
/**
@@ -538,3 +552,38 @@ remoting.ClientSession.prototype.getPerfStats = function() {
remoting.ClientSession.prototype.logStatistics = function(stats) {
this.logToServer.logStatistics(stats, this.mode);
};
+
+/**
+ * Toggles between full-screen and windowed mode.
+ * @return {void} Nothing.
+ * @private
+ */
+remoting.ClientSession.prototype.toggleFullScreen_ = function() {
+ if (document.webkitIsFullScreen) {
+ document.webkitCancelFullScreen();
+ } else {
+ document.body.webkitRequestFullScreen();
+ }
+};
+
+/**
+ * Updates the options menu to reflect the current scale-to-fit and full-screen
+ * settings.
+ * @return {void} Nothing.
+ * @private
+ */
+remoting.ClientSession.prototype.onShowOptionsMenu_ = function() {
+ if (this.scaleToFit) {
+ this.shrinkToFit_.classList.add(remoting.MenuButton.ITEM_SELECTED_CLASS);
+ this.originalSize_.classList.remove(
+ remoting.MenuButton.ITEM_SELECTED_CLASS);
+ } else {
+ this.shrinkToFit_.classList.remove(remoting.MenuButton.ITEM_SELECTED_CLASS);
+ this.originalSize_.classList.add(remoting.MenuButton.ITEM_SELECTED_CLASS);
+ }
+ if (document.webkitIsFullScreen) {
+ this.fullScreen_.classList.add(remoting.MenuButton.ITEM_SELECTED_CLASS);
+ } else {
+ this.fullScreen_.classList.remove(remoting.MenuButton.ITEM_SELECTED_CLASS);
+ }
+};

Powered by Google App Engine
This is Rietveld 408576698