| 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;
|
|
|