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

Unified Diff: remoting/webapp/app_remoting/js/app_remoting_activity.js

Issue 1082383002: [Webapp Refactor] Remove remoting.clientSession. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix browser tests Created 5 years, 8 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
« no previous file with comments | « remoting/webapp/app_remoting/js/app_remoting.js ('k') | remoting/webapp/base/js/application.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_();
};
})();
« no previous file with comments | « remoting/webapp/app_remoting/js/app_remoting.js ('k') | remoting/webapp/base/js/application.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698