OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 * Implements a basic UX control for a connected app remoting session. | 7 * Implements a basic UX control for a connected app remoting session. |
8 */ | 8 */ |
9 | 9 |
10 /** @suppress {duplicate} */ | 10 /** @suppress {duplicate} */ |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 * @private | 232 * @private |
233 */ | 233 */ |
234 remoting.AppConnectedView.prototype.sendGoogleDriveAccessToken_ = | 234 remoting.AppConnectedView.prototype.sendGoogleDriveAccessToken_ = |
235 function(sendExtensionMessage) { | 235 function(sendExtensionMessage) { |
236 var googleDriveScopes = [ | 236 var googleDriveScopes = [ |
237 'https://docs.google.com/feeds/', | 237 'https://docs.google.com/feeds/', |
238 'https://www.googleapis.com/auth/drive' | 238 'https://www.googleapis.com/auth/drive' |
239 ]; | 239 ]; |
240 remoting.identity.getNewToken(googleDriveScopes).then( | 240 remoting.identity.getNewToken(googleDriveScopes).then( |
241 function(/** string */ token){ | 241 function(/** string */ token){ |
| 242 base.debug.assert(token !== previousToken_); |
| 243 previousToken_ = token; |
242 sendExtensionMessage('accessToken', token); | 244 sendExtensionMessage('accessToken', token); |
243 }).catch(remoting.Error.handler(function(/** remoting.Error */ error) { | 245 }).catch(remoting.Error.handler(function(/** remoting.Error */ error) { |
244 console.log('Failed to refresh access token: ' + error.toString()); | 246 console.log('Failed to refresh access token: ' + error.toString()); |
245 })); | 247 })); |
246 }; | 248 }; |
247 | 249 |
| 250 // The access token last received from getNewToken. Saved to ensure that we |
| 251 // get a fresh token each time. |
| 252 var previousToken_ = ''; |
| 253 |
248 })(); | 254 })(); |
OLD | NEW |