| 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 |
| 11 * chrome-extensions in OAuth2. | 11 * chrome-extensions in OAuth2. |
| 12 */ | 12 */ |
| 13 | 13 |
| 14 // TODO(jamiewalch): Delete this code once Chromoting is a v2 app and uses the | 14 // TODO(jamiewalch): Delete this code once Chromoting is a v2 app and uses the |
| 15 // identity API (http://crbug.com/ 134213). | 15 // identity API (http://crbug.com/ 134213). |
| 16 | 16 |
| 17 'use strict'; | 17 'use strict'; |
| 18 | 18 |
| 19 /** @suppress {duplicate} */ | 19 /** @suppress {duplicate} */ |
| 20 var remoting = remoting || {}; | 20 var remoting = remoting || {}; |
| 21 | 21 |
| 22 /** @type {remoting.OAuth2} */ | 22 /** @type {remoting.OAuth2} */ |
| 23 remoting.oauth2 = null; | 23 remoting.oauth2 = null; |
| 24 | 24 |
| 25 | 25 |
| 26 /** @constructor */ | 26 /** |
| 27 * @constructor |
| 28 * @extends {remoting.Identity} |
| 29 */ |
| 27 remoting.OAuth2 = function() { | 30 remoting.OAuth2 = function() { |
| 28 }; | 31 }; |
| 29 | 32 |
| 30 // Constants representing keys used for storing persistent state. | 33 // Constants representing keys used for storing persistent state. |
| 31 /** @private */ | 34 /** @private */ |
| 32 remoting.OAuth2.prototype.KEY_REFRESH_TOKEN_ = 'oauth2-refresh-token'; | 35 remoting.OAuth2.prototype.KEY_REFRESH_TOKEN_ = 'oauth2-refresh-token'; |
| 33 /** @private */ | 36 /** @private */ |
| 34 remoting.OAuth2.prototype.KEY_ACCESS_TOKEN_ = 'oauth2-access-token'; | 37 remoting.OAuth2.prototype.KEY_ACCESS_TOKEN_ = 'oauth2-access-token'; |
| 35 /** @private */ | 38 /** @private */ |
| 36 remoting.OAuth2.prototype.KEY_EMAIL_ = 'remoting-email'; | 39 remoting.OAuth2.prototype.KEY_EMAIL_ = 'remoting-email'; |
| (...skipping 429 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 | 469 * @return {?string} The user's full name, if it has been cached by a previous |
| 467 * call to getUserInfo, otherwise null. | 470 * call to getUserInfo, otherwise null. |
| 468 */ | 471 */ |
| 469 remoting.OAuth2.prototype.getCachedUserFullName = function() { | 472 remoting.OAuth2.prototype.getCachedUserFullName = function() { |
| 470 var value = window.localStorage.getItem(this.KEY_FULLNAME_); | 473 var value = window.localStorage.getItem(this.KEY_FULLNAME_); |
| 471 if (typeof value == 'string') { | 474 if (typeof value == 'string') { |
| 472 return value; | 475 return value; |
| 473 } | 476 } |
| 474 return null; | 477 return null; |
| 475 }; | 478 }; |
| OLD | NEW |