summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remoting/remoting_webapp_files.gypi1
-rw-r--r--remoting/webapp/client_screen.js26
-rw-r--r--remoting/webapp/client_session.js67
-rw-r--r--remoting/webapp/event_handlers.js1
-rw-r--r--remoting/webapp/options_menu.js99
-rw-r--r--remoting/webapp/session_connector.js16
-rw-r--r--remoting/webapp/toolbar.js23
7 files changed, 158 insertions, 75 deletions
diff --git a/remoting/remoting_webapp_files.gypi b/remoting/remoting_webapp_files.gypi
index 5adf428..5bb645d 100644
--- a/remoting/remoting_webapp_files.gypi
+++ b/remoting/remoting_webapp_files.gypi
@@ -86,6 +86,7 @@
'webapp/fullscreen_v2.js',
'webapp/l10n.js',
'webapp/menu_button.js',
+ 'webapp/options_menu.js',
'webapp/ui_mode.js',
'webapp/toolbar.js',
'webapp/window_frame.js',
diff --git a/remoting/webapp/client_screen.js b/remoting/webapp/client_screen.js
index dd583b7..d8dfbea 100644
--- a/remoting/webapp/client_screen.js
+++ b/remoting/webapp/client_screen.js
@@ -77,30 +77,6 @@ remoting.disconnect = function() {
};
/**
- * Sends a Ctrl-Alt-Del sequence to the remoting client.
- *
- * @return {void} Nothing.
- */
-remoting.sendCtrlAltDel = function() {
- if (remoting.clientSession) {
- console.log('Sending Ctrl-Alt-Del.');
- remoting.clientSession.sendCtrlAltDel();
- }
-};
-
-/**
- * Sends a Print Screen keypress to the remoting client.
- *
- * @return {void} Nothing.
- */
-remoting.sendPrintScreen = function() {
- if (remoting.clientSession) {
- console.log('Sending Print Screen.');
- remoting.clientSession.sendPrintScreen();
- }
-};
-
-/**
* Callback function called when the state of the client plugin changes. The
* current and previous states are available via the |state| member variable.
*
@@ -335,8 +311,6 @@ remoting.onConnected = function(clientSession) {
remoting.clientSession = clientSession;
remoting.clientSession.addEventListener('stateChanged', onClientStateChange_);
setConnectionInterruptedButtonsText_();
- var connectedTo = document.getElementById('connected-to');
- connectedTo.innerText = remoting.connector.getHostDisplayName();
document.getElementById('access-code-entry').value = '';
remoting.setMode(remoting.AppMode.IN_SESSION);
remoting.toolbar.center();
diff --git a/remoting/webapp/client_session.js b/remoting/webapp/client_session.js
index 703eee8..2fb6e22 100644
--- a/remoting/webapp/client_session.js
+++ b/remoting/webapp/client_session.js
@@ -23,6 +23,7 @@
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
@@ -46,8 +47,8 @@ var remoting = remoting || {};
* @constructor
* @extends {base.EventSource}
*/
-remoting.ClientSession = function(accessCode, fetchPin, fetchThirdPartyToken,
- authenticationMethods,
+remoting.ClientSession = function(hostDisplayName, accessCode, fetchPin,
+ fetchThirdPartyToken, authenticationMethods,
hostId, hostJid, hostPublicKey, mode,
clientPairingId, clientPairedSecret) {
/** @private */
@@ -57,6 +58,8 @@ remoting.ClientSession = function(accessCode, fetchPin, fetchThirdPartyToken,
this.error_ = remoting.Error.NONE;
/** @private */
+ this.hostDisplayName_ = hostDisplayName;
+ /** @private */
this.hostJid_ = hostJid;
/** @private */
this.hostPublicKey_ = hostPublicKey;
@@ -109,8 +112,6 @@ remoting.ClientSession = function(accessCode, fetchPin, fetchThirdPartyToken,
/** @private */
this.callPluginGotFocus_ = this.pluginGotFocus_.bind(this);
/** @private */
- this.callSetScreenMode_ = this.onSetScreenMode_.bind(this);
- /** @private */
this.callToggleFullScreen_ = remoting.fullscreen.toggle.bind(
remoting.fullscreen);
/** @private */
@@ -144,12 +145,8 @@ remoting.ClientSession = function(accessCode, fetchPin, fetchThirdPartyToken,
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));
@@ -164,6 +161,15 @@ remoting.ClientSession.Events = {
};
/**
+ * 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.
*
@@ -202,6 +208,20 @@ remoting.ClientSession.prototype.updateScrollbarVisibility = function() {
}
};
+/**
+ * @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
@@ -566,10 +586,6 @@ remoting.ClientSession.prototype.removePlugin = function() {
}
// 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);
@@ -584,6 +600,7 @@ remoting.ClientSession.prototype.removePlugin = function() {
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.
@@ -679,6 +696,7 @@ remoting.ClientSession.prototype.sendKeyCombination_ = function(keys) {
* @return {void} Nothing.
*/
remoting.ClientSession.prototype.sendCtrlAltDel = function() {
+ console.log('Sending Ctrl-Alt-Del.');
this.sendKeyCombination_([0x0700e0, 0x0700e2, 0x07004c]);
}
@@ -688,6 +706,7 @@ remoting.ClientSession.prototype.sendCtrlAltDel = function() {
* @return {void} Nothing.
*/
remoting.ClientSession.prototype.sendPrintScreen = function() {
+ console.log('Sending Print Screen.');
this.sendKeyCombination_([0x070046]);
}
@@ -750,26 +769,6 @@ remoting.ClientSession.prototype.applyRemapKeys_ = function(apply) {
}
/**
- * 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.
*
@@ -781,9 +780,8 @@ remoting.ClientSession.prototype.onSetScreenMode_ = function(event) {
* 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_();
@@ -985,6 +983,7 @@ remoting.ClientSession.prototype.onConnectionStatusUpdate_ =
if (remoting.windowFrame) {
remoting.windowFrame.setConnected(true);
}
+ remoting.toolbar.setClientSession(this);
} else if (status == remoting.ClientSession.State.FAILED) {
switch (error) {
diff --git a/remoting/webapp/event_handlers.js b/remoting/webapp/event_handlers.js
index ad15614..50ec1df 100644
--- a/remoting/webapp/event_handlers.js
+++ b/remoting/webapp/event_handlers.js
@@ -105,6 +105,7 @@ function onLoad() {
var auth_actions = [
{ event: 'click', id: 'auth-button', fn: doAuthRedirect },
{ event: 'click', id: 'cancel-connect-button', fn: goHome },
+ { event: 'click', id: 'sign-out', fn:remoting.signOut },
{ event: 'click', id: 'token-refresh-error-ok', fn: goHome },
{ event: 'click', id: 'token-refresh-error-sign-in', fn: fixAuthError }
];
diff --git a/remoting/webapp/options_menu.js b/remoting/webapp/options_menu.js
new file mode 100644
index 0000000..fa1b9fd
--- /dev/null
+++ b/remoting/webapp/options_menu.js
@@ -0,0 +1,99 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview
+ * Class handling the in-session options menu (or menus in the case of apps v1).
+ */
+
+'use strict';
+
+/** @suppress {duplicate} */
+var remoting = remoting || {};
+
+/**
+ * @param {HTMLElement} sendCtrlAltDel
+ * @param {HTMLElement} sendPrtScrn
+ * @param {HTMLElement} resizeToClient
+ * @param {HTMLElement} shrinkToFit
+ * @param {HTMLElement?} fullscreen
+ * @constructor
+ */
+remoting.OptionsMenu = function(sendCtrlAltDel, sendPrtScrn,
+ resizeToClient, shrinkToFit, fullscreen) {
+ this.sendCtrlAltDel_ = sendCtrlAltDel;
+ this.sendPrtScrn_ = sendPrtScrn;
+ this.resizeToClient_ = resizeToClient;
+ this.shrinkToFit_ = shrinkToFit;
+ this.fullscreen_ = fullscreen;
+ /**
+ * @type {remoting.ClientSession}
+ * @private
+ */
+ this.clientSession_ = null;
+
+ this.sendCtrlAltDel_.addEventListener(
+ 'click', this.onSendCtrlAltDel_.bind(this), false);
+ this.sendPrtScrn_.addEventListener(
+ 'click', this.onSendPrtScrn_.bind(this), false);
+ this.resizeToClient_.addEventListener(
+ 'click', this.onResizeToClient_.bind(this), false);
+ this.shrinkToFit_.addEventListener(
+ 'click', this.onShrinkToFit_.bind(this), false);
+ if (this.fullscreen_) {
+ this.fullscreen_.addEventListener(
+ 'click', this.onFullscreen_.bind(this), false);
+ }
+};
+
+/**
+ * @param {remoting.ClientSession} clientSession The active session, or null if
+ * there is no connection.
+ */
+remoting.OptionsMenu.prototype.setClientSession = function(clientSession) {
+ this.clientSession_ = clientSession;
+};
+
+remoting.OptionsMenu.prototype.onShow = function() {
+ if (this.clientSession_) {
+ remoting.MenuButton.select(
+ this.resizeToClient_, this.clientSession_.getResizeToClient());
+ remoting.MenuButton.select(
+ this.shrinkToFit_, this.clientSession_.getShrinkToFit());
+ if (this.fullscreen_) {
+ remoting.MenuButton.select(
+ this.fullscreen_, remoting.fullscreen.isActive());
+ }
+ }
+};
+
+remoting.OptionsMenu.prototype.onSendCtrlAltDel_ = function() {
+ if (this.clientSession_) {
+ this.clientSession_.sendCtrlAltDel();
+ }
+};
+
+remoting.OptionsMenu.prototype.onSendPrtScrn_ = function() {
+ if (this.clientSession_) {
+ this.clientSession_.sendPrintScreen();
+ }
+};
+
+remoting.OptionsMenu.prototype.onResizeToClient_ = function() {
+ if (this.clientSession_) {
+ this.clientSession_.setScreenMode(this.clientSession_.getShrinkToFit(),
+ !this.clientSession_.getResizeToClient());
+ }
+};
+
+remoting.OptionsMenu.prototype.onShrinkToFit_ = function() {
+ if (this.clientSession_) {
+ this.clientSession_.setScreenMode(!this.clientSession_.getShrinkToFit(),
+ this.clientSession_.getResizeToClient());
+ }
+};
+
+remoting.OptionsMenu.prototype.onFullscreen_ = function() {
+ remoting.fullscreen.toggle();
+};
diff --git a/remoting/webapp/session_connector.js b/remoting/webapp/session_connector.js
index e540b20..2b98180 100644
--- a/remoting/webapp/session_connector.js
+++ b/remoting/webapp/session_connector.js
@@ -336,15 +336,6 @@ remoting.SessionConnector.prototype.getHostId = function() {
};
/**
- * Get host display name.
- *
- * @return {string}
- */
-remoting.SessionConnector.prototype.getHostDisplayName = function() {
- return this.hostDisplayName_;
-};
-
-/**
* Continue an IT2Me connection once an access token has been obtained.
*
* @param {string} token An OAuth2 access token.
@@ -402,9 +393,10 @@ remoting.SessionConnector.prototype.createSession_ = function() {
var authenticationMethods =
'third_party,spake2_pair,spake2_hmac,spake2_plain';
this.clientSession_ = new remoting.ClientSession(
- this.passPhrase_, this.fetchPin_, this.fetchThirdPartyToken_,
- authenticationMethods, this.hostId_, this.hostJid_, this.hostPublicKey_,
- this.connectionMode_, this.clientPairingId_, this.clientPairedSecret_);
+ this.hostDisplayName_, this.passPhrase_, this.fetchPin_,
+ this.fetchThirdPartyToken_, authenticationMethods, this.hostId_,
+ this.hostJid_, this.hostPublicKey_, this.connectionMode_,
+ this.clientPairingId_, this.clientPairedSecret_);
this.clientSession_.logHostOfflineErrors(!this.refreshHostJidIfOffline_);
this.clientSession_.addEventListener(
remoting.ClientSession.Events.stateChanged,
diff --git a/remoting/webapp/toolbar.js b/remoting/webapp/toolbar.js
index 23cbd32..32dfdf6 100644
--- a/remoting/webapp/toolbar.js
+++ b/remoting/webapp/toolbar.js
@@ -42,6 +42,16 @@ remoting.Toolbar = function(toolbar) {
* @private
*/
this.stubRight_ = 0;
+ /**
+ * @type {remoting.OptionsMenu}
+ * @private
+ */
+ this.optionsMenu_ = new remoting.OptionsMenu(
+ document.getElementById('send-ctrl-alt-del'),
+ document.getElementById('send-print-screen'),
+ document.getElementById('screen-resize-to-client'),
+ document.getElementById('screen-shrink-to-fit'),
+ document.getElementById('toggle-full-screen'));
window.addEventListener('mousemove', remoting.Toolbar.onMouseMove, false);
window.addEventListener('resize', this.center.bind(this), false);
@@ -54,9 +64,6 @@ remoting.Toolbar = function(toolbar) {
'frame': "none"
});
});
- registerEventListener('send-ctrl-alt-del', 'click', remoting.sendCtrlAltDel);
- registerEventListener('send-print-screen', 'click', remoting.sendPrintScreen);
- registerEventListener('sign-out', 'click', remoting.signOut);
registerEventListener('toolbar-disconnect', 'click', remoting.disconnect);
registerEventListener('toolbar-stub', 'click',
function() { remoting.toolbar.toggle(); });
@@ -108,6 +115,16 @@ remoting.Toolbar.prototype.toggle = function() {
};
/**
+ * @param {remoting.ClientSession} clientSession The active session, or null if
+ * there is no connection.
+ */
+remoting.Toolbar.prototype.setClientSession = function(clientSession) {
+ this.optionsMenu_.setClientSession(clientSession);
+ var connectedTo = document.getElementById('connected-to');
+ connectedTo.innerText = clientSession.getHostDisplayName();
+};
+
+/**
* Test the specified co-ordinate to see if it is close enough to the stub
* to activate it.
*