Index: trunk/src/remoting/webapp/client_session.js |
=================================================================== |
--- trunk/src/remoting/webapp/client_session.js (revision 277837) |
+++ trunk/src/remoting/webapp/client_session.js (working copy) |
@@ -23,7 +23,6 @@ |
var remoting = remoting || {}; |
/** |
- * @param {string} hostDisplayName A human-readable name for the host. |
* @param {string} accessCode The IT2Me access code. Blank for Me2Me. |
* @param {function(boolean, function(string): void): void} fetchPin |
* Called by Me2Me connections when a PIN needs to be obtained |
@@ -47,8 +46,8 @@ |
* @constructor |
* @extends {base.EventSource} |
*/ |
-remoting.ClientSession = function(hostDisplayName, accessCode, fetchPin, |
- fetchThirdPartyToken, authenticationMethods, |
+remoting.ClientSession = function(accessCode, fetchPin, fetchThirdPartyToken, |
+ authenticationMethods, |
hostId, hostJid, hostPublicKey, mode, |
clientPairingId, clientPairedSecret) { |
/** @private */ |
@@ -58,8 +57,6 @@ |
this.error_ = remoting.Error.NONE; |
/** @private */ |
- this.hostDisplayName_ = hostDisplayName; |
- /** @private */ |
this.hostJid_ = hostJid; |
/** @private */ |
this.hostPublicKey_ = hostPublicKey; |
@@ -112,6 +109,8 @@ |
/** @private */ |
this.callPluginGotFocus_ = this.pluginGotFocus_.bind(this); |
/** @private */ |
+ this.callSetScreenMode_ = this.onSetScreenMode_.bind(this); |
+ /** @private */ |
this.callToggleFullScreen_ = remoting.fullscreen.toggle.bind( |
remoting.fullscreen); |
/** @private */ |
@@ -145,8 +144,12 @@ |
this.resizeToClientButton_.hidden = true; |
} else { |
this.resizeToClientButton_.hidden = false; |
+ this.resizeToClientButton_.addEventListener( |
+ 'click', this.callSetScreenMode_, false); |
} |
+ this.shrinkToFitButton_.addEventListener( |
+ 'click', this.callSetScreenMode_, false); |
this.fullScreenButton_.addEventListener( |
'click', this.callToggleFullScreen_, false); |
this.defineEvents(Object.keys(remoting.ClientSession.Events)); |
@@ -161,15 +164,6 @@ |
}; |
/** |
- * Get host display name. |
- * |
- * @return {string} |
- */ |
-remoting.ClientSession.prototype.getHostDisplayName = function() { |
- return this.hostDisplayName_; |
-}; |
- |
-/** |
* Called when the window or desktop size or the scaling settings change, |
* to set the scroll-bar visibility. |
* |
@@ -208,20 +202,6 @@ |
} |
}; |
-/** |
- * @return {boolean} True if shrink-to-fit is enabled; false otherwise. |
- */ |
-remoting.ClientSession.prototype.getShrinkToFit = function() { |
- return this.shrinkToFit_; |
-}; |
- |
-/** |
- * @return {boolean} True if resize-to-client is enabled; false otherwise. |
- */ |
-remoting.ClientSession.prototype.getResizeToClient = function() { |
- return this.resizeToClient_; |
-}; |
- |
// Note that the positive values in both of these enums are copied directly |
// from chromoting_scriptable_object.h and must be kept in sync. The negative |
// values represent state transitions that occur within the web-app that have |
@@ -583,6 +563,10 @@ |
} |
// Delete event handlers that aren't relevent when not connected. |
+ this.resizeToClientButton_.removeEventListener( |
+ 'click', this.callSetScreenMode_, false); |
+ this.shrinkToFitButton_.removeEventListener( |
+ 'click', this.callSetScreenMode_, false); |
this.fullScreenButton_.removeEventListener( |
'click', this.callToggleFullScreen_, false); |
@@ -597,7 +581,6 @@ |
if (remoting.windowFrame) { |
remoting.windowFrame.setConnected(false); |
} |
- remoting.toolbar.setClientSession(null); |
// Remove mediasource-rendering class from video-contained - this will also |
// hide the <video> element. |
@@ -693,7 +676,6 @@ |
* @return {void} Nothing. |
*/ |
remoting.ClientSession.prototype.sendCtrlAltDel = function() { |
- console.log('Sending Ctrl-Alt-Del.'); |
this.sendKeyCombination_([0x0700e0, 0x0700e2, 0x07004c]); |
} |
@@ -703,7 +685,6 @@ |
* @return {void} Nothing. |
*/ |
remoting.ClientSession.prototype.sendPrintScreen = function() { |
- console.log('Sending Print Screen.'); |
this.sendKeyCombination_([0x070046]); |
} |
@@ -766,6 +747,26 @@ |
} |
/** |
+ * Callback for the two "screen mode" related menu items: Resize desktop to |
+ * fit and Shrink to fit. |
+ * |
+ * @param {Event} event The click event indicating which mode was selected. |
+ * @return {void} Nothing. |
+ * @private |
+ */ |
+remoting.ClientSession.prototype.onSetScreenMode_ = function(event) { |
+ var shrinkToFit = this.shrinkToFit_; |
+ var resizeToClient = this.resizeToClient_; |
+ if (event.target == this.shrinkToFitButton_) { |
+ shrinkToFit = !shrinkToFit; |
+ } |
+ if (event.target == this.resizeToClientButton_) { |
+ resizeToClient = !resizeToClient; |
+ } |
+ this.setScreenMode_(shrinkToFit, resizeToClient); |
+}; |
+ |
+/** |
* Set the shrink-to-fit and resize-to-client flags and save them if this is |
* a Me2Me connection. |
* |
@@ -777,8 +778,9 @@ |
* false to disable this behaviour for subsequent window resizes--the |
* current host desktop size is not restored in this case. |
* @return {void} Nothing. |
+ * @private |
*/ |
-remoting.ClientSession.prototype.setScreenMode = |
+remoting.ClientSession.prototype.setScreenMode_ = |
function(shrinkToFit, resizeToClient) { |
if (resizeToClient && !this.resizeToClient_) { |
var clientArea = this.getClientArea_(); |
@@ -980,7 +982,6 @@ |
if (remoting.windowFrame) { |
remoting.windowFrame.setConnected(true); |
} |
- remoting.toolbar.setClientSession(this); |
} else if (status == remoting.ClientSession.State.FAILED) { |
switch (error) { |