Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: remoting/webapp/crd/js/oauth2.js

Issue 803653004: Update Chromoting to use /third_party/closure_compiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused types Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 window.localStorage.setItem(this.KEY_ACCESS_TOKEN_, 149 window.localStorage.setItem(this.KEY_ACCESS_TOKEN_,
150 JSON.stringify(access_token)); 150 JSON.stringify(access_token));
151 }; 151 };
152 152
153 /** 153 /**
154 * Returns the current access token, setting it to a invalid value if none 154 * Returns the current access token, setting it to a invalid value if none
155 * existed before. 155 * existed before.
156 * 156 *
157 * @private 157 * @private
158 * @return {{token: string, expiration: number}} The current access token, or 158 * @return {{token: string, expiration: number}} The current access token, or
159 * an invalid token if not authenticated. 159 * an invalid token if not authenticated.
160 */ 160 */
161 remoting.OAuth2.prototype.getAccessTokenInternal_ = function() { 161 remoting.OAuth2.prototype.getAccessTokenInternal_ = function() {
162 if (!window.localStorage.getItem(this.KEY_ACCESS_TOKEN_)) { 162 if (!window.localStorage.getItem(this.KEY_ACCESS_TOKEN_)) {
163 // Always be able to return structured data. 163 // Always be able to return structured data.
164 this.setAccessToken_('', 0); 164 this.setAccessToken_('', 0);
165 } 165 }
166 var accessToken = window.localStorage.getItem(this.KEY_ACCESS_TOKEN_); 166 var accessToken = window.localStorage.getItem(this.KEY_ACCESS_TOKEN_);
167 if (typeof accessToken == 'string') { 167 if (typeof accessToken == 'string') {
168 var result = base.jsonParseSafe(accessToken); 168 var result = base.jsonParseSafe(accessToken);
169 if (result && 'token' in result && 'expiration' in result) { 169 if (result && 'token' in result && 'expiration' in result) {
170 return /** @type {{token: string, expiration: number}} */ result; 170 return /** @type {{token: string, expiration: number}} */(result);
171 } 171 }
172 } 172 }
173 console.log('Invalid access token stored.'); 173 console.log('Invalid access token stored.');
174 return {'token': '', 'expiration': 0}; 174 return {'token': '', 'expiration': 0};
175 }; 175 };
176 176
177 /** 177 /**
178 * Returns true if the access token is expired, or otherwise invalid. 178 * Returns true if the access token is expired, or otherwise invalid.
179 * 179 *
180 * Will throw if !isAuthenticated(). 180 * Will throw if !isAuthenticated().
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 * @return {?string} The user's full name, if it has been cached by a previous 457 * @return {?string} The user's full name, if it has been cached by a previous
458 * call to getUserInfo, otherwise null. 458 * call to getUserInfo, otherwise null.
459 */ 459 */
460 remoting.OAuth2.prototype.getCachedUserFullName = function() { 460 remoting.OAuth2.prototype.getCachedUserFullName = function() {
461 var value = window.localStorage.getItem(this.KEY_FULLNAME_); 461 var value = window.localStorage.getItem(this.KEY_FULLNAME_);
462 if (typeof value == 'string') { 462 if (typeof value == 'string') {
463 return value; 463 return value;
464 } 464 }
465 return null; 465 return null;
466 }; 466 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698