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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 /** |
264 * Processes the results of the oauth flow. | 264 * Processes the results of the oauth flow. |
265 * | 265 * |
266 * @param {Object.<string, string>} message Dictionary containing the parsed | 266 * @param {Object<string, string>} message Dictionary containing the parsed |
267 * OAuth redirect URL parameters. | 267 * OAuth redirect URL parameters. |
268 * @param {function(*)} sendResponse Function to send response. | 268 * @param {function(*)} sendResponse Function to send response. |
269 */ | 269 */ |
270 function oauth2MessageListener(message, sender, sendResponse) { | 270 function oauth2MessageListener(message, sender, sendResponse) { |
271 if ('code' in message && 'state' in message) { | 271 if ('code' in message && 'state' in message) { |
272 if (message['state'] == xsrf_token) { | 272 if (message['state'] == xsrf_token) { |
273 onDone(message['code']); | 273 onDone(message['code']); |
274 } else { | 274 } else { |
275 console.error('Invalid XSRF token.'); | 275 console.error('Invalid XSRF token.'); |
276 onDone(null); | 276 onDone(null); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 * @return {?string} The user's full name, if it has been cached by a previous | 461 * @return {?string} The user's full name, if it has been cached by a previous |
462 * call to getUserInfo, otherwise null. | 462 * call to getUserInfo, otherwise null. |
463 */ | 463 */ |
464 remoting.OAuth2.prototype.getCachedUserFullName = function() { | 464 remoting.OAuth2.prototype.getCachedUserFullName = function() { |
465 var value = window.localStorage.getItem(this.KEY_FULLNAME_); | 465 var value = window.localStorage.getItem(this.KEY_FULLNAME_); |
466 if (typeof value == 'string') { | 466 if (typeof value == 'string') { |
467 return value; | 467 return value; |
468 } | 468 } |
469 return null; | 469 return null; |
470 }; | 470 }; |
OLD | NEW |