Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Unified Diff: remoting/webapp/remoting.js

Issue 13619010: Migrate window.localStorage settings to chrome.storage.local at start-up. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewer comments. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/remoting.js
diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js
index c487fa1a666bad14a1ac285d72c4be1186b94216..616732af760ae8dcdb705ecbf8f996e97594d88b 100644
--- a/remoting/webapp/remoting.js
+++ b/remoting/webapp/remoting.js
@@ -34,6 +34,8 @@ function consentRequired_(authContinue) {
* Entry point for app initialization.
*/
remoting.init = function() {
+ migrateLocalToChromeStorage_();
+
// TODO(jamiewalch): Remove this when we migrate to apps v2
// (http://crbug.com/ 134213).
remoting.initMockStorage();
@@ -356,3 +358,27 @@ function isWindowed_(callback) {
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);
+ }
+ }
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698