Chromium Code Reviews| 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. |
| */ |