| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 /** | 5 /** | 
| 6  * @fileoverview | 6  * @fileoverview | 
| 7  * OAuth2 class that handles retrieval/storage of an OAuth2 token. | 7  * OAuth2 class that handles retrieval/storage of an OAuth2 token. | 
| 8  * | 8  * | 
| 9  * Uses a content script to trampoline the OAuth redirect page back into the | 9  * Uses a content script to trampoline the OAuth redirect page back into the | 
| 10  * extension context.  This works around the lack of native support for | 10  * extension context.  This works around the lack of native support for | 
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 243 /** | 243 /** | 
| 244  * Redirect page to get a new OAuth2 authorization code | 244  * Redirect page to get a new OAuth2 authorization code | 
| 245  * | 245  * | 
| 246  * @param {function(?string):void} onDone Completion callback to receive | 246  * @param {function(?string):void} onDone Completion callback to receive | 
| 247  *     the authorization code, or null on error. | 247  *     the authorization code, or null on error. | 
| 248  * @return {void} Nothing. | 248  * @return {void} Nothing. | 
| 249  */ | 249  */ | 
| 250 remoting.OAuth2.prototype.getAuthorizationCode = function(onDone) { | 250 remoting.OAuth2.prototype.getAuthorizationCode = function(onDone) { | 
| 251   var xsrf_token = base.generateXsrfToken(); | 251   var xsrf_token = base.generateXsrfToken(); | 
| 252   var GET_CODE_URL = this.getOAuth2AuthEndpoint_() + '?' + | 252   var GET_CODE_URL = this.getOAuth2AuthEndpoint_() + '?' + | 
| 253     remoting.xhr.urlencodeParamHash({ | 253     remoting.Xhr.urlencodeParamHash({ | 
| 254           'client_id': this.getClientId_(), | 254           'client_id': this.getClientId_(), | 
| 255           'redirect_uri': this.getRedirectUri_(), | 255           'redirect_uri': this.getRedirectUri_(), | 
| 256           'scope': this.SCOPE_, | 256           'scope': this.SCOPE_, | 
| 257           'state': xsrf_token, | 257           'state': xsrf_token, | 
| 258           'response_type': 'code', | 258           'response_type': 'code', | 
| 259           'access_type': 'offline', | 259           'access_type': 'offline', | 
| 260           'approval_prompt': 'force' | 260           'approval_prompt': 'force' | 
| 261         }); | 261         }); | 
| 262 | 262 | 
| 263   /** | 263   /** | 
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 441       window.localStorage.setItem(that.KEY_FULLNAME_, name); | 441       window.localStorage.setItem(that.KEY_FULLNAME_, name); | 
| 442       resolve({email: email, name: name}); | 442       resolve({email: email, name: name}); | 
| 443     }; | 443     }; | 
| 444 | 444 | 
| 445     that.getToken().then( | 445     that.getToken().then( | 
| 446         remoting.oauth2Api.getUserInfo.bind( | 446         remoting.oauth2Api.getUserInfo.bind( | 
| 447             remoting.oauth2Api, onResponse, reject), | 447             remoting.oauth2Api, onResponse, reject), | 
| 448         reject); | 448         reject); | 
| 449   }); | 449   }); | 
| 450 }; | 450 }; | 
| OLD | NEW | 
|---|