Migrate window.localStorage settings to chrome.storage.local at start-up.

This ensures that users don't lose any saved settings when upgrading to M27.

BUG=226488


Review URL: https://chromiumcodereview.appspot.com/13619010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192494 0039d316-1c4b-4281-b951-d872f2087c98
parent ee2cebc4
...@@ -34,6 +34,8 @@ function consentRequired_(authContinue) { ...@@ -34,6 +34,8 @@ function consentRequired_(authContinue) {
* Entry point for app initialization. * Entry point for app initialization.
*/ */
remoting.init = function() { remoting.init = function() {
migrateLocalToChromeStorage_();
// TODO(jamiewalch): Remove this when we migrate to apps v2 // TODO(jamiewalch): Remove this when we migrate to apps v2
// (http://crbug.com/ 134213). // (http://crbug.com/ 134213).
remoting.initMockStorage(); remoting.initMockStorage();
...@@ -356,3 +358,27 @@ function isWindowed_(callback) { ...@@ -356,3 +358,27 @@ function isWindowed_(callback) {
console.error('chome.tabs is not available.'); console.error('chome.tabs is not available.');
} }
} }
/**
* Migrate settings in window.localStorage to chrome.storage.local so that
* users of older web-apps that used the former do not lose their settings.
*/
function migrateLocalToChromeStorage_() {
// The OAuth2 class still uses window.localStorage, so don't migrate any of
// those settings.
var oauthSettings = [
'oauth2-refresh-token',
'oauth2-refresh-token-revokable',
'oauth2-access-token',
'oauth2-xsrf-token',
'remoting-email'
];
for (var setting in window.localStorage) {
if (oauthSettings.indexOf(setting) == -1) {
var copy = {}
copy[setting] = window.localStorage.getItem(setting);
chrome.storage.local.set(copy);
window.localStorage.removeItem(setting);
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment