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 * Wrapper class for Chrome's identity API. | 7 * Wrapper class for Chrome's identity API. |
8 */ | 8 */ |
9 /** @suppress {duplicate} */ | 9 /** @suppress {duplicate} */ |
10 var remoting = remoting || {}; | 10 var remoting = remoting || {}; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 * @return {!Promise<string>} A promise resolved with an access token | 88 * @return {!Promise<string>} A promise resolved with an access token |
89 * or rejected with a remoting.Error. | 89 * or rejected with a remoting.Error. |
90 */ | 90 */ |
91 remoting.Identity.prototype.getNewToken = function(opt_scopes) { | 91 remoting.Identity.prototype.getNewToken = function(opt_scopes) { |
92 /** @type {remoting.Identity} */ | 92 /** @type {remoting.Identity} */ |
93 var that = this; | 93 var that = this; |
94 | 94 |
95 return this.getToken(opt_scopes).then(function(/** string */ token) { | 95 return this.getToken(opt_scopes).then(function(/** string */ token) { |
96 return new Promise(function(resolve, reject) { | 96 return new Promise(function(resolve, reject) { |
97 chrome.identity.removeCachedAuthToken({'token': token }, function() { | 97 chrome.identity.removeCachedAuthToken({'token': token }, function() { |
98 resolve(that.getToken()); | 98 resolve(that.getToken(opt_scopes)); |
99 }); | 99 }); |
100 }); | 100 }); |
101 }); | 101 }); |
102 }; | 102 }; |
103 | 103 |
104 /** | 104 /** |
105 * Removes the cached auth token, if any. | 105 * Removes the cached auth token, if any. |
106 * | 106 * |
107 * @return {!Promise<null>} A promise resolved with the operation completes. | 107 * @return {!Promise<null>} A promise resolved with the operation completes. |
108 */ | 108 */ |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 238 |
239 /** | 239 /** |
240 * @param {Array<string>=} opt_scopes | 240 * @param {Array<string>=} opt_scopes |
241 * @return {string} | 241 * @return {string} |
242 */ | 242 */ |
243 function getScopesKey(opt_scopes) { | 243 function getScopesKey(opt_scopes) { |
244 return opt_scopes ? JSON.stringify(opt_scopes) : ''; | 244 return opt_scopes ? JSON.stringify(opt_scopes) : ''; |
245 } | 245 } |
246 | 246 |
247 })(); | 247 })(); |
OLD | NEW |