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 /** | 10 /** |
11 * @type {base.EventSource} An event source object for handling global events. | 11 * @type {base.EventSource} An event source object for handling global events. |
12 * This is an interim hack. Eventually, we should move functionalities | 12 * This is an interim hack. Eventually, we should move functionalities |
13 * away from the remoting namespace and into smaller objects. | 13 * away from the remoting namespace and into smaller objects. |
14 */ | 14 */ |
15 remoting.testEvents; | 15 remoting.testEvents; |
16 | 16 |
17 /** | 17 /** |
18 * Initialization tasks that are common to all remoting apps. | 18 * Initialization tasks that are common to all remoting apps. |
19 */ | 19 */ |
20 remoting.initGlobalObjects = function() { | 20 remoting.initGlobalObjects = function() { |
21 if (base.isAppsV2()) { | 21 if (base.isAppsV2()) { |
22 var htmlNode = /** @type {HTMLElement} */ (document.body.parentNode); | 22 var htmlNode = /** @type {HTMLElement} */ (document.body.parentNode); |
23 htmlNode.classList.add('apps-v2'); | 23 htmlNode.classList.add('apps-v2'); |
24 } else { | |
25 migrateLocalToChromeStorage_(); | |
Jamie
2015/01/20 22:32:01
I don't think this code needs to be removed. It's
kelvinp
2015/01/21 21:16:21
I think it is a good practice to clean up dead cod
| |
26 } | 24 } |
27 | 25 |
28 console.log(remoting.getExtensionInfo()); | 26 console.log(remoting.getExtensionInfo()); |
29 l10n.localize(); | 27 l10n.localize(); |
30 | 28 |
31 if (base.isAppsV2()) { | 29 if (base.isAppsV2()) { |
32 remoting.fullscreen = new remoting.FullscreenAppsV2(); | 30 remoting.fullscreen = new remoting.FullscreenAppsV2(); |
33 } else { | 31 } else { |
34 remoting.fullscreen = new remoting.FullscreenAppsV1(); | 32 remoting.fullscreen = new remoting.FullscreenAppsV1(); |
35 } | 33 } |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 chrome.windows.get(tab.windowId, null, windowCallback); | 222 chrome.windows.get(tab.windowId, null, windowCallback); |
225 } | 223 } |
226 }; | 224 }; |
227 if (chrome.tabs) { | 225 if (chrome.tabs) { |
228 chrome.tabs.getCurrent(tabCallback); | 226 chrome.tabs.getCurrent(tabCallback); |
229 } else { | 227 } else { |
230 console.error('chome.tabs is not available.'); | 228 console.error('chome.tabs is not available.'); |
231 } | 229 } |
232 } | 230 } |
233 | 231 |
234 /** | |
235 * Migrate settings in window.localStorage to chrome.storage.local so that | |
236 * users of older web-apps that used the former do not lose their settings. | |
237 */ | |
238 function migrateLocalToChromeStorage_() { | |
239 // The OAuth2 class still uses window.localStorage, so don't migrate any of | |
240 // those settings. | |
241 var oauthSettings = [ | |
242 'oauth2-refresh-token', | |
243 'oauth2-refresh-token-revokable', | |
244 'oauth2-access-token', | |
245 'oauth2-xsrf-token', | |
246 'remoting-email' | |
247 ]; | |
248 for (var setting in window.localStorage) { | |
249 if (oauthSettings.indexOf(setting) == -1) { | |
250 var copy = {} | |
251 copy[setting] = window.localStorage.getItem(setting); | |
252 chrome.storage.local.set(copy); | |
253 window.localStorage.removeItem(setting); | |
254 } | |
255 } | |
256 } | |
OLD | NEW |