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

Unified Diff: remoting/webapp/base/js/application.js

Issue 988963003: Add Application.Delegate.stop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer feedback. Created 5 years, 9 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/crd/js/app_launcher.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/base/js/application.js
diff --git a/remoting/webapp/base/js/application.js b/remoting/webapp/base/js/application.js
index 5ba56f8ff67d633b771aa6e00b1c5ea0fa0bfe2b..488b8fce9683eba0d661199228ffa95744bd46cf 100644
--- a/remoting/webapp/base/js/application.js
+++ b/remoting/webapp/base/js/application.js
@@ -101,9 +101,28 @@ remoting.Application.prototype.start = function() {
remoting.initIdentity();
this.delegate_.init();
+
+ var that = this;
remoting.identity.getToken().then(
- this.delegate_.start.bind(this.delegate_, this.getSessionConnector()),
- remoting.Error.handler(this.delegate_.signInFailed.bind(this.delegate_)));
+ this.delegate_.start.bind(this.delegate_, this.getSessionConnector())
+ ).catch(remoting.Error.handler(
+ function(/** remoting.Error */ error) {
+ if (error == remoting.Error.CANCELLED) {
+ that.exit();
+ } else {
+ that.delegate_.signInFailed(error);
+ }
+ }
+ )
+ );
+};
+
+/**
+ * Quit the application.
+ */
+remoting.Application.prototype.exit = function() {
+ this.delegate_.handleExit();
+ chrome.app.window.current().close();
};
/** Disconnect the remoting client. */
@@ -282,7 +301,7 @@ remoting.Application.Delegate.prototype.start = function(connector, token) {};
/**
* Report an authentication error to the user. This is called in lieu of start()
- * if the user cannot be authenticated or if they decline the app permissions.
+ * if the user cannot be authenticated.
*
* @param {remoting.Error} error The failure reason.
*/
@@ -351,6 +370,14 @@ remoting.Application.Delegate.prototype.handleExtensionMessage =
*/
remoting.Application.Delegate.prototype.handleError = function(errorTag) {};
+/**
+ * Perform any application-specific cleanup before exiting. This is called in
+ * lieu of start() if the user declines the app permissions, and will usually
+ * be called immediately prior to exiting, although delegates should not rely
+ * on this.
+ */
+remoting.Application.Delegate.prototype.handleExit = function() {};
+
/** @type {remoting.Application} */
remoting.app = null;
« no previous file with comments | « remoting/webapp/app_remoting/js/app_remoting.js ('k') | remoting/webapp/crd/js/app_launcher.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698