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

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: 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
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..0a0117162c07518b6d8006ae5b5eec90d00f9845 100644
--- a/remoting/webapp/base/js/application.js
+++ b/remoting/webapp/base/js/application.js
@@ -101,9 +101,26 @@ 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(
garykac 2015/03/07 02:16:01 This indentation looks wrong.
Jamie 2015/03/09 17:41:15 Done.
+ 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_.stop();
+ chrome.app.window.current().close();
};
/** Disconnect the remoting client. */
@@ -281,8 +298,16 @@ remoting.Application.Delegate.prototype.init = function() {};
remoting.Application.Delegate.prototype.start = function(connector, token) {};
/**
+ * 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.stop = function() {};
+
+/**
* 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.
*/

Powered by Google App Engine
This is Rietveld 408576698