diff options
author | jamiewalch@google.com <jamiewalch@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-25 23:46:46 +0000 |
---|---|---|
committer | jamiewalch@google.com <jamiewalch@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-25 23:46:46 +0000 |
commit | 23e4353dfe2483dcfc7511bf2b23643fbdc5a949 (patch) | |
tree | 10a60918d09269d958da529185e920ee6cb6bce6 /remoting/webapp/host_setup_dialog.js | |
parent | e335fd5150fc614e1b9df1d9e7e93ec7793d26f7 (diff) | |
download | chromium_src-23e4353dfe2483dcfc7511bf2b23643fbdc5a949.zip chromium_src-23e4353dfe2483dcfc7511bf2b23643fbdc5a949.tar.gz chromium_src-23e4353dfe2483dcfc7511bf2b23643fbdc5a949.tar.bz2 |
Pass OAuth token refresh errors back to the caller.
This allows the app to advise the user to sign back in to Chromoting only when
we believe it will actually help. As a bonus, the unhelpfully-named
ERROR_GENERIC is now gone--apart from OAuth refresh failures, it was being used
for edge-cases where we don't expect anything to go wrong (these now use the
more suitably-named ERROR_UNEXPECTED).
As part of fixing this, I have cleaned up some OAuth call points that were
written before callWithToken existed, and which weren't using it.
BUG=122899,130794
TEST=Corrupt the oauth2-refresh-token value in HTML Local Storage
Review URL: https://chromiumcodereview.appspot.com/10579012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144059 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp/host_setup_dialog.js')
-rw-r--r-- | remoting/webapp/host_setup_dialog.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/remoting/webapp/host_setup_dialog.js b/remoting/webapp/host_setup_dialog.js index fe60ecb..c0e5ae2 100644 --- a/remoting/webapp/host_setup_dialog.js +++ b/remoting/webapp/host_setup_dialog.js @@ -150,6 +150,18 @@ remoting.HostSetupDialog = function(hostController) { * @return {void} Nothing. */ remoting.HostSetupDialog.prototype.showForStart = function() { + // Although we don't need an access token in order to start the host, + // using callWithToken here ensures consistent error handling in the + // case where the refresh token is invalid. + remoting.oauth2.callWithToken(this.showForStartWithToken_.bind(this), + remoting.defaultOAuthErrorHandler); +}; + +/** + * @param {string} token The OAuth2 token. + * @private + */ +remoting.HostSetupDialog.prototype.showForStartWithToken_ = function(token) { /** @type {remoting.HostSetupDialog} */ var that = this; @@ -423,7 +435,7 @@ remoting.HostSetupDialog.validPin_ = function(pin) { } } return true; -} +}; /** * @return {void} Nothing. @@ -436,14 +448,14 @@ remoting.HostSetupDialog.prototype.onInstallDialogOk = function() { } else { remoting.setMode(remoting.AppMode.HOST_SETUP_INSTALL_PENDING); } -} +}; /** * @return {void} Nothing. */ remoting.HostSetupDialog.prototype.onInstallDialogRetry = function() { remoting.setMode(remoting.AppMode.HOST_SETUP_INSTALL); -} +}; /** @type {remoting.HostSetupDialog} */ remoting.hostSetupDialog = null; |