| 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 430 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 }; |
| 451 | |
| 452 /** | |
| 453 * If the user's email address is cached, return it, otherwise return null. | |
| 454 * | |
| 455 * @return {?string} The email address, if it has been cached by a previous call | |
| 456 * to getEmail or getUserInfo, otherwise null. | |
| 457 */ | |
| 458 remoting.OAuth2.prototype.getCachedEmail = function() { | |
| 459 var value = window.localStorage.getItem(this.KEY_EMAIL_); | |
| 460 if (typeof value == 'string') { | |
| 461 return value; | |
| 462 } | |
| 463 return null; | |
| 464 }; | |
| 465 | |
| 466 /** | |
| 467 * If the user's full name is cached, return it, otherwise return null. | |
| 468 * | |
| 469 * @return {?string} The user's full name, if it has been cached by a previous | |
| 470 * call to getUserInfo, otherwise null. | |
| 471 */ | |
| 472 remoting.OAuth2.prototype.getCachedUserFullName = function() { | |
| 473 var value = window.localStorage.getItem(this.KEY_FULLNAME_); | |
| 474 if (typeof value == 'string') { | |
| 475 return value; | |
| 476 } | |
| 477 return null; | |
| 478 }; | |
| OLD | NEW |