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 16 matching lines...) Expand all Loading... |
27 authContinue(); | 27 authContinue(); |
28 }; | 28 }; |
29 dialog.hidden = false; | 29 dialog.hidden = false; |
30 button.addEventListener('click', consentGranted, false); | 30 button.addEventListener('click', consentGranted, false); |
31 } | 31 } |
32 | 32 |
33 /** | 33 /** |
34 * Entry point for app initialization. | 34 * Entry point for app initialization. |
35 */ | 35 */ |
36 remoting.init = function() { | 36 remoting.init = function() { |
| 37 migrateLocalToChromeStorage_(); |
| 38 |
37 // TODO(jamiewalch): Remove this when we migrate to apps v2 | 39 // TODO(jamiewalch): Remove this when we migrate to apps v2 |
38 // (http://crbug.com/ 134213). | 40 // (http://crbug.com/ 134213). |
39 remoting.initMockStorage(); | 41 remoting.initMockStorage(); |
40 | 42 |
41 remoting.logExtensionInfo_(); | 43 remoting.logExtensionInfo_(); |
42 l10n.localize(); | 44 l10n.localize(); |
43 // Create global objects. | 45 // Create global objects. |
44 remoting.settings = new remoting.Settings(); | 46 remoting.settings = new remoting.Settings(); |
45 remoting.oauth2 = new remoting.OAuth2(); | 47 remoting.oauth2 = new remoting.OAuth2(); |
46 // TODO(jamiewalch): Reinstate this when we migrate to apps v2 | 48 // TODO(jamiewalch): Reinstate this when we migrate to apps v2 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 } else { | 351 } else { |
350 chrome.windows.get(tab.windowId, null, windowCallback); | 352 chrome.windows.get(tab.windowId, null, windowCallback); |
351 } | 353 } |
352 }; | 354 }; |
353 if (chrome.tabs) { | 355 if (chrome.tabs) { |
354 chrome.tabs.getCurrent(tabCallback); | 356 chrome.tabs.getCurrent(tabCallback); |
355 } else { | 357 } else { |
356 console.error('chome.tabs is not available.'); | 358 console.error('chome.tabs is not available.'); |
357 } | 359 } |
358 } | 360 } |
| 361 |
| 362 /** |
| 363 * Migrate settings in window.localStorage to chrome.storage.local so that |
| 364 * users of older web-apps that used the former do not lose their settings. |
| 365 */ |
| 366 function migrateLocalToChromeStorage_() { |
| 367 // The OAuth2 class still uses window.localStorage, so don't migrate any of |
| 368 // those settings. |
| 369 var oauthSettings = [ |
| 370 'oauth2-refresh-token', |
| 371 'oauth2-refresh-token-revokable', |
| 372 'oauth2-access-token', |
| 373 'oauth2-xsrf-token', |
| 374 'remoting-email' |
| 375 ]; |
| 376 for (var setting in window.localStorage) { |
| 377 if (oauthSettings.indexOf(setting) == -1) { |
| 378 var copy = {} |
| 379 copy[setting] = window.localStorage.getItem(setting); |
| 380 chrome.storage.local.set(copy); |
| 381 window.localStorage.removeItem(setting); |
| 382 } |
| 383 } |
| 384 } |
OLD | NEW |