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 27 matching lines...) Expand all Loading... |
38 /** | 38 /** |
39 * Entry point for app initialization. | 39 * Entry point for app initialization. |
40 */ | 40 */ |
41 remoting.init = function() { | 41 remoting.init = function() { |
42 // Determine whether or not this is a V2 web-app. In order to keep the apps | 42 // Determine whether or not this is a V2 web-app. In order to keep the apps |
43 // v2 patch as small as possible, all JS changes needed for apps v2 are done | 43 // v2 patch as small as possible, all JS changes needed for apps v2 are done |
44 // at run-time. Only the manifest is patched. | 44 // at run-time. Only the manifest is patched. |
45 var manifest = chrome.runtime.getManifest(); | 45 var manifest = chrome.runtime.getManifest(); |
46 if (manifest && manifest.app && manifest.app.background) { | 46 if (manifest && manifest.app && manifest.app.background) { |
47 remoting.isAppsV2 = true; | 47 remoting.isAppsV2 = true; |
48 document.body.classList.add('apps-v2'); | 48 var htmlNode = /** @type {HTMLElement} */ (document.body.parentNode); |
| 49 htmlNode.classList.add('apps-v2'); |
49 } | 50 } |
50 | 51 |
51 if (!remoting.isAppsV2) { | 52 if (!remoting.isAppsV2) { |
52 migrateLocalToChromeStorage_(); | 53 migrateLocalToChromeStorage_(); |
53 } | 54 } |
54 | 55 |
55 remoting.logExtensionInfo_(); | 56 remoting.logExtensionInfo_(); |
56 l10n.localize(); | 57 l10n.localize(); |
57 | 58 |
58 // Create global objects. | 59 // Create global objects. |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 /** | 458 /** |
458 * Generate a nonce, to be used as an xsrf protection token. | 459 * Generate a nonce, to be used as an xsrf protection token. |
459 * | 460 * |
460 * @return {string} A URL-Safe Base64-encoded 128-bit random value. */ | 461 * @return {string} A URL-Safe Base64-encoded 128-bit random value. */ |
461 remoting.generateXsrfToken = function() { | 462 remoting.generateXsrfToken = function() { |
462 var random = new Uint8Array(16); | 463 var random = new Uint8Array(16); |
463 window.crypto.getRandomValues(random); | 464 window.crypto.getRandomValues(random); |
464 var base64Token = window.btoa(String.fromCharCode.apply(null, random)); | 465 var base64Token = window.btoa(String.fromCharCode.apply(null, random)); |
465 return base64Token.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); | 466 return base64Token.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); |
466 }; | 467 }; |
OLD | NEW |