Index: remoting/webapp/app_remoting/js/app_remoting_activity.js |
diff --git a/remoting/webapp/app_remoting/js/app_remoting_activity.js b/remoting/webapp/app_remoting/js/app_remoting_activity.js |
index 16a5ab3eb9cd9134ff2f5e48f2555d18e394553c..3685946ef08a53ce7e2dbca4c2477df1278ae859 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_(); |
}; |
})(); |