| 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 }; | 311 }; |
| 312 | 312 |
| 313 /** | 313 /** |
| 314 * Asynchronously exchanges an authorization code for a refresh token. | 314 * Asynchronously exchanges an authorization code for a refresh token. |
| 315 * | 315 * |
| 316 * @param {string} code The OAuth2 authorization code. | 316 * @param {string} code The OAuth2 authorization code. |
| 317 * @param {function():void} onDone Callback to invoke on completion. | 317 * @param {function():void} onDone Callback to invoke on completion. |
| 318 * @return {void} Nothing. | 318 * @return {void} Nothing. |
| 319 */ | 319 */ |
| 320 remoting.OAuth2.prototype.exchangeCodeForToken = function(code, onDone) { | 320 remoting.OAuth2.prototype.exchangeCodeForToken = function(code, onDone) { |
| 321 /** @param {remoting.Error} error */ | 321 /** @param {!remoting.Error} error */ |
| 322 var onError = function(error) { | 322 var onError = function(error) { |
| 323 console.error('Unable to exchange code for token: ', error); | 323 console.error('Unable to exchange code for token: ', error); |
| 324 }; | 324 }; |
| 325 | 325 |
| 326 remoting.oauth2Api.exchangeCodeForTokens( | 326 remoting.oauth2Api.exchangeCodeForTokens( |
| 327 this.onTokens_.bind(this, onDone), onError, | 327 this.onTokens_.bind(this, onDone), onError, |
| 328 this.getClientId_(), this.getClientSecret_(), code, | 328 this.getClientId_(), this.getClientSecret_(), code, |
| 329 this.getRedirectUri_()); | 329 this.getRedirectUri_()); |
| 330 }; | 330 }; |
| 331 | 331 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 * @return {?string} The user's full name, if it has been cached by a previous | 466 * @return {?string} The user's full name, if it has been cached by a previous |
| 467 * call to getUserInfo, otherwise null. | 467 * call to getUserInfo, otherwise null. |
| 468 */ | 468 */ |
| 469 remoting.OAuth2.prototype.getCachedUserFullName = function() { | 469 remoting.OAuth2.prototype.getCachedUserFullName = function() { |
| 470 var value = window.localStorage.getItem(this.KEY_FULLNAME_); | 470 var value = window.localStorage.getItem(this.KEY_FULLNAME_); |
| 471 if (typeof value == 'string') { | 471 if (typeof value == 'string') { |
| 472 return value; | 472 return value; |
| 473 } | 473 } |
| 474 return null; | 474 return null; |
| 475 }; | 475 }; |
| OLD | NEW |