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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
9 | 9 |
10 /** @type {remoting.HostSession} */ remoting.hostSession = null; | 10 /** @type {remoting.HostSession} */ remoting.hostSession = null; |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 ]; | 375 ]; |
376 for (var setting in window.localStorage) { | 376 for (var setting in window.localStorage) { |
377 if (oauthSettings.indexOf(setting) == -1) { | 377 if (oauthSettings.indexOf(setting) == -1) { |
378 var copy = {} | 378 var copy = {} |
379 copy[setting] = window.localStorage.getItem(setting); | 379 copy[setting] = window.localStorage.getItem(setting); |
380 chrome.storage.local.set(copy); | 380 chrome.storage.local.set(copy); |
381 window.localStorage.removeItem(setting); | 381 window.localStorage.removeItem(setting); |
382 } | 382 } |
383 } | 383 } |
384 } | 384 } |
| 385 |
| 386 /** |
| 387 * Generate a nonce, to be used as an xsrf protection token. |
| 388 * |
| 389 * @return {string} A URL-Safe Base64-encoded 128-bit random value. */ |
| 390 remoting.generateXsrfToken = function() { |
| 391 var random = new Uint8Array(16); |
| 392 window.crypto.getRandomValues(random); |
| 393 var base64Token = window.btoa(String.fromCharCode.apply(null, random)); |
| 394 return base64Token.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); |
| 395 }; |
OLD | NEW |