diff options
Diffstat (limited to 'remoting/webapp')
-rw-r--r-- | remoting/webapp/app_remoting/js/app_remoting.js | 4 | ||||
-rw-r--r-- | remoting/webapp/app_remoting/js/app_remoting_activity.js | 30 | ||||
-rw-r--r-- | remoting/webapp/base/js/application.js | 25 | ||||
-rw-r--r-- | remoting/webapp/browser_test/browser_test.js | 7 | ||||
-rw-r--r-- | remoting/webapp/crd/js/activity.js | 6 | ||||
-rw-r--r-- | remoting/webapp/crd/js/client_plugin.js | 4 | ||||
-rw-r--r-- | remoting/webapp/crd/js/client_plugin_impl.js | 8 | ||||
-rw-r--r-- | remoting/webapp/crd/js/desktop_remoting.js | 18 | ||||
-rw-r--r-- | remoting/webapp/crd/js/desktop_remoting_activity.js | 18 | ||||
-rw-r--r-- | remoting/webapp/crd/js/it2me_activity.js | 4 | ||||
-rw-r--r-- | remoting/webapp/crd/js/me2me_activity.js | 8 | ||||
-rw-r--r-- | remoting/webapp/crd/js/session_connector_impl.js | 9 | ||||
-rw-r--r-- | remoting/webapp/crd/js/smart_reconnector.js | 9 | ||||
-rw-r--r-- | remoting/webapp/crd/js/toolbar.js | 7 | ||||
-rw-r--r-- | remoting/webapp/crd/js/window_frame.js | 13 |
15 files changed, 111 insertions, 59 deletions
diff --git a/remoting/webapp/app_remoting/js/app_remoting.js b/remoting/webapp/app_remoting/js/app_remoting.js index 8d60ae9..cbb1506 100644 --- a/remoting/webapp/app_remoting/js/app_remoting.js +++ b/remoting/webapp/app_remoting/js/app_remoting.js @@ -38,6 +38,10 @@ remoting.AppRemoting.prototype.getApplicationName = function() { return manifest.name; }; +remoting.AppRemoting.prototype.getActivity = function() { + return this.activity_; +}; + /** * @param {!remoting.Error} error The failure reason. * @override {remoting.ApplicationInterface} diff --git a/remoting/webapp/app_remoting/js/app_remoting_activity.js b/remoting/webapp/app_remoting/js/app_remoting_activity.js index 16a5ab3..3685946 100644 --- a/remoting/webapp/app_remoting/js/app_remoting_activity.js +++ b/remoting/webapp/app_remoting/js/app_remoting_activity.js @@ -38,6 +38,9 @@ remoting.AppRemotingActivity = function(appCapabilities) { this.connector_ = remoting.SessionConnector.factory.createConnector( document.getElementById('client-container'), appCapabilities, this); + + /** @private {remoting.ClientSession} */ + this.session_ = null; }; remoting.AppRemotingActivity.prototype.dispose = function() { @@ -56,6 +59,19 @@ remoting.AppRemotingActivity.prototype.start = function() { }); }; +remoting.AppRemotingActivity.prototype.stop = function() { + if (this.session_) { + this.session_.disconnect(remoting.Error.none()); + } +}; + +/** @private */ +remoting.AppRemotingActivity.prototype.cleanup_ = function() { + base.dispose(this.connectedView_); + this.connectedView_ = null; + this.session_ = null; +}; + /** * @param {string} token * @return {Promise<!remoting.Xhr.Response>} @@ -96,10 +112,6 @@ remoting.AppRemotingActivity.prototype.onAppHostResponse_ = remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); - var idleDetector = new remoting.IdleDetector( - document.getElementById('idle-dialog'), - remoting.app.disconnect.bind(remoting.app)); - /** * @param {string} tokenUrl Token-issue URL received from the host. * @param {string} hostPublicKey Host public key (DER and Base64 @@ -137,6 +149,10 @@ remoting.AppRemotingActivity.prototype.onConnected = function(connectionInfo) { this.connectedView_ = new remoting.AppConnectedView( document.getElementById('client-container'), connectionInfo); + this.session_ = connectionInfo.session(); + var idleDetector = new remoting.IdleDetector( + document.getElementById('idle-dialog'), this.stop.bind(this)); + // Map Cmd to Ctrl on Mac since hosts typically use Ctrl for keyboard // shortcuts, but we want them to act as natively as possible. if (remoting.platformIsMac()) { @@ -145,8 +161,7 @@ remoting.AppRemotingActivity.prototype.onConnected = function(connectionInfo) { }; remoting.AppRemotingActivity.prototype.onDisconnected = function() { - base.dispose(this.connectedView_); - this.connectedView_ = null; + this.cleanup_(); chrome.app.window.current().close(); }; @@ -166,8 +181,7 @@ remoting.AppRemotingActivity.prototype.onError = function(error) { remoting.MessageWindow.showErrorMessage( chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'), chrome.i18n.getMessage(error.getTag())); - base.dispose(this.connectedView_); - this.connectedView_ = null; + this.cleanup_(); }; })(); diff --git a/remoting/webapp/base/js/application.js b/remoting/webapp/base/js/application.js index 4e79fcc..5b6768b 100644 --- a/remoting/webapp/base/js/application.js +++ b/remoting/webapp/base/js/application.js @@ -57,14 +57,6 @@ remoting.Application.prototype.setConnectionMode = function(mode) { this.connectionMode_ = mode; }; -/* Disconnect the remoting client. */ -remoting.Application.prototype.disconnect = function() { - if (remoting.clientSession) { - remoting.clientSession.disconnect(remoting.Error.none()); - console.log('Disconnected.'); - } -}; - /* Public method to exit the application. */ remoting.Application.prototype.quit = function() { this.exitApplication_(); @@ -111,7 +103,14 @@ remoting.Application.prototype.start = function() { /** @return {string} */ remoting.Application.prototype.getApplicationName = function() { - base.debug.assert(false, "Subclass must override"); + base.debug.assert(false, 'Subclass must override'); +}; + +/** + * @return {remoting.Activity} The Current activity. + */ +remoting.Application.prototype.getActivity = function() { + base.debug.assert(false, 'Subclass must override'); }; /** @@ -119,12 +118,12 @@ remoting.Application.prototype.getApplicationName = function() { * @protected */ remoting.Application.prototype.signInFailed_ = function(error) { - base.debug.assert(false, "Subclass must override"); + base.debug.assert(false, 'Subclass must override'); }; /** @protected */ remoting.Application.prototype.initApplication_ = function() { - base.debug.assert(false, "Subclass must override"); + base.debug.assert(false, 'Subclass must override'); }; /** @@ -132,12 +131,12 @@ remoting.Application.prototype.initApplication_ = function() { * @protected */ remoting.Application.prototype.startApplication_ = function(token) { - base.debug.assert(false, "Subclass must override"); + base.debug.assert(false, 'Subclass must override'); }; /** @protected */ remoting.Application.prototype.exitApplication_ = function() { - base.debug.assert(false, "Subclass must override"); + base.debug.assert(false, 'Subclass must override'); }; /** diff --git a/remoting/webapp/browser_test/browser_test.js b/remoting/webapp/browser_test/browser_test.js index 30c6962..fcf616f 100644 --- a/remoting/webapp/browser_test/browser_test.js +++ b/remoting/webapp/browser_test/browser_test.js @@ -222,7 +222,12 @@ browserTest.disconnect = function() { finishedButton = 'client-finished-it2me-button'; } - remoting.app.disconnect(); + var activity = remoting.app.getActivity(); + if (!activity) { + return Promise.resolve(); + } + + activity.stop(); return browserTest.onUIMode(finishedMode).then(function() { browserTest.clickOnControl(finishedButton); diff --git a/remoting/webapp/crd/js/activity.js b/remoting/webapp/crd/js/activity.js index 44e2fab..206073c 100644 --- a/remoting/webapp/crd/js/activity.js +++ b/remoting/webapp/crd/js/activity.js @@ -29,4 +29,10 @@ remoting.Activity = function() {}; */ remoting.Activity.prototype.start = function() {}; +/** + * Cancels or disconnects a remote connection. + * @return {void} + */ +remoting.Activity.prototype.stop = function() {}; + })();
\ No newline at end of file diff --git a/remoting/webapp/crd/js/client_plugin.js b/remoting/webapp/crd/js/client_plugin.js index d251227..6006175 100644 --- a/remoting/webapp/crd/js/client_plugin.js +++ b/remoting/webapp/crd/js/client_plugin.js @@ -232,6 +232,10 @@ remoting.ClientPlugin.ConnectionEventHandler.prototype.onConnectionReady = remoting.ClientPlugin.ConnectionEventHandler.prototype.onSetCapabilities = function(capabilities) {}; +/** Called when the first video frame is received */ +remoting.ClientPlugin.ConnectionEventHandler.prototype.onFirstFrameReceived = + function() {}; + /** * @interface */ diff --git a/remoting/webapp/crd/js/client_plugin_impl.js b/remoting/webapp/crd/js/client_plugin_impl.js index c2ba6c0..c9b2144 100644 --- a/remoting/webapp/crd/js/client_plugin_impl.js +++ b/remoting/webapp/crd/js/client_plugin_impl.js @@ -250,6 +250,9 @@ remoting.ClientPluginImpl.prototype.handleMessageMethod_ = function(message) { base.getStringAttr(message.data, 'capabilities')); handler.onSetCapabilities(capabilities); + } else if (message.method == 'onFirstFrameReceived') { + handler.onFirstFrameReceived(); + } } @@ -311,11 +314,6 @@ remoting.ClientPluginImpl.prototype.handleMessageMethod_ = function(message) { var item = base.getStringAttr(message.data, 'item'); this.updateClipboardData_(mimetype, item); - } else if (message.method == 'onFirstFrameReceived') { - if (remoting.clientSession) { - remoting.clientSession.onFirstFrameReceived(); - } - } else if (message.method == 'fetchPin') { // The pairingSupported value in the dictionary indicates whether both // client and host support pairing. If the client doesn't support pairing, diff --git a/remoting/webapp/crd/js/desktop_remoting.js b/remoting/webapp/crd/js/desktop_remoting.js index 29c32a0..a8b1cf2 100644 --- a/remoting/webapp/crd/js/desktop_remoting.js +++ b/remoting/webapp/crd/js/desktop_remoting.js @@ -49,7 +49,7 @@ remoting.DesktopRemoting.prototype.initApplication_ = function() { if (base.isAppsV2()) { remoting.windowFrame = new remoting.WindowFrame( - document.getElementById('title-bar')); + document.getElementById('title-bar'), this.disconnect_.bind(this)); remoting.optionsMenu = remoting.windowFrame.createOptionsMenu(); var START_FULLSCREEN = 'start-fullscreen'; @@ -73,13 +73,13 @@ remoting.DesktopRemoting.prototype.initApplication_ = function() { } else { remoting.fullscreen = new remoting.FullscreenAppsV1(); remoting.toolbar = new remoting.Toolbar( - document.getElementById('session-toolbar')); + document.getElementById('session-toolbar'), + this.disconnect_.bind(this)); remoting.optionsMenu = remoting.toolbar.createOptionsMenu(); window.addEventListener('beforeunload', this.promptClose_.bind(this), false); - window.addEventListener('unload', - remoting.app.disconnect.bind(remoting.app), false); + window.addEventListener('unload', this.disconnect_.bind(this), false); } remoting.initHostlist_(this.connectMe2Me_.bind(this)); @@ -189,6 +189,16 @@ remoting.DesktopRemoting.prototype.getConnectedViewForTesting = function() { return activity.getDesktopActivity().getConnectedView(); }; +remoting.DesktopRemoting.prototype.getActivity = function() { + return this.activity_; +}; + +remoting.DesktopRemoting.prototype.disconnect_ = function() { + if (this.activity_) { + this.activity_.stop(); + } +}; + /** * Entry-point for Me2Me connections. * diff --git a/remoting/webapp/crd/js/desktop_remoting_activity.js b/remoting/webapp/crd/js/desktop_remoting_activity.js index 768eccc..d311130 100644 --- a/remoting/webapp/crd/js/desktop_remoting_activity.js +++ b/remoting/webapp/crd/js/desktop_remoting_activity.js @@ -24,6 +24,15 @@ remoting.DesktopRemotingActivity = function(parentActivity) { this.parentActivity_ = parentActivity; /** @private {remoting.DesktopConnectedView} */ this.connectedView_ = null; + /** @private {remoting.ClientSession} */ + this.session_ = null; +}; + +remoting.DesktopRemotingActivity.prototype.stop = function() { + if (this.session_) { + this.session_.disconnect(remoting.Error.none()); + console.log('Disconnected.'); + } }; /** @@ -37,6 +46,8 @@ remoting.DesktopRemotingActivity.prototype.onConnected = remoting.toolbar.preview(); } + this.session_ = connectionInfo.session(); + this.connectedView_ = new remoting.DesktopConnectedView( document.getElementById('client-container'), connectionInfo); @@ -58,8 +69,7 @@ remoting.DesktopRemotingActivity.prototype.onConnected = remoting.DesktopRemotingActivity.prototype.onDisconnected = function() { this.parentActivity_.onDisconnected(); - base.dispose(this.connectedView_); - this.connectedView_ = null; + this.dispose(); }; /** @@ -84,13 +94,13 @@ remoting.DesktopRemotingActivity.prototype.onError = function(error) { this.parentActivity_.onError(error); - base.dispose(this.connectedView_); - this.connectedView_ = null; + this.dispose(); }; remoting.DesktopRemotingActivity.prototype.dispose = function() { base.dispose(this.connectedView_); this.connectedView_ = null; + this.session_ = null; }; /** @return {remoting.DesktopConnectedView} */ diff --git a/remoting/webapp/crd/js/it2me_activity.js b/remoting/webapp/crd/js/it2me_activity.js index 98b4bf5..4ee50c3 100644 --- a/remoting/webapp/crd/js/it2me_activity.js +++ b/remoting/webapp/crd/js/it2me_activity.js @@ -66,6 +66,10 @@ remoting.It2MeActivity.prototype.start = function() { }); }; +remoting.It2MeActivity.prototype.stop = function() { + this.desktopActivity_.stop(); +}; + /** * @param {!remoting.Error} error */ diff --git a/remoting/webapp/crd/js/me2me_activity.js b/remoting/webapp/crd/js/me2me_activity.js index 7dac1ed..9020691 100644 --- a/remoting/webapp/crd/js/me2me_activity.js +++ b/remoting/webapp/crd/js/me2me_activity.js @@ -55,6 +55,10 @@ remoting.Me2MeActivity.prototype.start = function() { }); }; +remoting.Me2MeActivity.prototype.stop = function() { + this.desktopActivity_.stop(); +}; + /** @return {remoting.DesktopRemotingActivity} */ remoting.Me2MeActivity.prototype.getDesktopActivity = function() { return this.desktopActivity_; @@ -164,7 +168,9 @@ remoting.Me2MeActivity.prototype.onConnected = function(connectionInfo) { base.dispose(this.reconnector_); this.reconnector_ = new remoting.SmartReconnector( - this.connect_.bind(this, false), connectionInfo.session()); + this.connect_.bind(this, false), + this.stop.bind(this), + connectionInfo.session()); }; remoting.Me2MeActivity.prototype.onDisconnected = function() { diff --git a/remoting/webapp/crd/js/session_connector_impl.js b/remoting/webapp/crd/js/session_connector_impl.js index 6c19789..438a1f0 100644 --- a/remoting/webapp/crd/js/session_connector_impl.js +++ b/remoting/webapp/crd/js/session_connector_impl.js @@ -13,13 +13,6 @@ var remoting = remoting || {}; /** - * @type {remoting.ClientSession} The client session object, set once the - * connector has invoked its onOk callback. - * TODO(garykac): Have this owned by someone instead of being global. - */ -remoting.clientSession; - -/** * @param {HTMLElement} clientContainer Container element for the client view. * @param {Array<string>} requiredCapabilities Connector capabilities * required by this application. @@ -75,7 +68,6 @@ remoting.SessionConnectorImpl.prototype.closeSession_ = function() { base.dispose(this.clientSession_); /** @private {remoting.ClientSession} */ this.clientSession_ = null; - remoting.clientSession = null; base.dispose(this.plugin_); /** @private {remoting.ClientPlugin} */ @@ -209,7 +201,6 @@ remoting.SessionConnectorImpl.prototype.onPluginInitialized_ = function( this.clientSession_ = new remoting.ClientSession( this.plugin_, this.host_, this.signalStrategy_); - remoting.clientSession = this.clientSession_; this.clientSession_.logHostOfflineErrors(this.logHostOfflineErrors_); this.eventHook_ = new base.EventHook( diff --git a/remoting/webapp/crd/js/smart_reconnector.js b/remoting/webapp/crd/js/smart_reconnector.js index d7e331b..1597332 100644 --- a/remoting/webapp/crd/js/smart_reconnector.js +++ b/remoting/webapp/crd/js/smart_reconnector.js @@ -20,16 +20,21 @@ var remoting = remoting || {}; /** * @constructor * @param {function()} reconnectCallback + * @param {function()} disconnectCallback * @param {remoting.ClientSession} clientSession This represents the current * remote desktop connection. It is used to monitor the changes in * connection state. * @implements {base.Disposable} */ -remoting.SmartReconnector = function(reconnectCallback, clientSession) { +remoting.SmartReconnector = + function(reconnectCallback, disconnectCallback, clientSession) { /** @private */ this.reconnectCallback_ = reconnectCallback; /** @private */ + this.disconnectCallback_ = disconnectCallback; + + /** @private */ this.clientSession_ = clientSession; /** @private */ @@ -67,7 +72,7 @@ remoting.SmartReconnector.kConnectionTimeout = 10000; remoting.SmartReconnector.prototype = { reconnect_: function() { this.cancelPending_(); - remoting.app.disconnect(); + this.disconnectCallback_(); remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); this.reconnectCallback_(); }, diff --git a/remoting/webapp/crd/js/toolbar.js b/remoting/webapp/crd/js/toolbar.js index a06e2e5..f1b7692 100644 --- a/remoting/webapp/crd/js/toolbar.js +++ b/remoting/webapp/crd/js/toolbar.js @@ -14,9 +14,11 @@ var remoting = remoting || {}; /** * @param {HTMLElement} toolbar The HTML element representing the tool-bar. + * @param {function()} disconnectCallback Callback for disconnecting the + * session. * @constructor */ -remoting.Toolbar = function(toolbar) { +remoting.Toolbar = function(toolbar, disconnectCallback) { /** @private {HTMLElement} */ this.toolbar_ = toolbar; /** @private {HTMLElement} */ @@ -42,8 +44,7 @@ remoting.Toolbar = function(toolbar) { window.addEventListener('mousemove', remoting.Toolbar.onMouseMove, false); window.addEventListener('resize', this.center.bind(this), false); - registerEventListener('toolbar-disconnect', 'click', - remoting.app.disconnect.bind(remoting.app)); + registerEventListener('toolbar-disconnect', 'click', disconnectCallback); registerEventListener('toolbar-stub', 'click', function() { remoting.toolbar.toggle(); }); diff --git a/remoting/webapp/crd/js/window_frame.js b/remoting/webapp/crd/js/window_frame.js index 0bb0b64..65d8afe 100644 --- a/remoting/webapp/crd/js/window_frame.js +++ b/remoting/webapp/crd/js/window_frame.js @@ -14,9 +14,11 @@ var remoting = remoting || {}; /** * @param {HTMLElement} titleBar The root node of the title-bar DOM hierarchy. + * @param {function()} disconnectCallback Callback for disconnecting the + * session. * @constructor */ -remoting.WindowFrame = function(titleBar) { +remoting.WindowFrame = function(titleBar, disconnectCallback) { /** @private {remoting.DesktopConnectedView} */ this.desktopConnectedView_ = null; @@ -49,7 +51,7 @@ remoting.WindowFrame = function(titleBar) { * @type {Array<{cls:string, fn: function()}>} */ var handlers = [ - { cls: 'window-disconnect', fn: this.disconnectSession_.bind(this) }, + { cls: 'window-disconnect', fn: disconnectCallback }, { cls: 'window-maximize-restore', fn: this.maximizeOrRestoreWindow_.bind(this) }, { cls: 'window-minimize', fn: this.minimizeWindow_.bind(this) }, @@ -127,13 +129,6 @@ remoting.WindowFrame.prototype.getClientArea = function() { /** * @private */ -remoting.WindowFrame.prototype.disconnectSession_ = function() { - remoting.app.disconnect(); -}; - -/** - * @private - */ remoting.WindowFrame.prototype.maximizeOrRestoreWindow_ = function() { /** @type {boolean} */ var restore = |