Index: chrome/ext/background.js |
=================================================================== |
--- a/chrome/ext/background.js |
+++ b/chrome/ext/background.js |
@@ -499,8 +499,54 @@ |
/* Storage */ |
- ext.storage = localStorage; |
+ ext.storage = { |
+ get: function(keys, callback) |
+ { |
+ chrome.storage.local.get(keys, callback); |
+ }, |
+ set: function(key, value, callback) |
+ { |
+ let items = {}; |
+ items[key] = value; |
+ chrome.storage.local.set(items, callback); |
+ }, |
+ remove: function(key, callback) |
+ { |
+ chrome.storage.local.remove(key, callback); |
+ }, |
+ onChanged: chrome.storage.onChanged, |
+ // Migrate localStorage to chrome.storage.local, |
+ // ignoring unkown and inavlid preferences. |
+ migratePrefs: function(prefs) |
+ { |
+ var items = {}; |
+ |
+ for (let key in localStorage) |
+ { |
+ var value = localStorage[key]; |
+ |
+ if (key in prefs) |
+ { |
+ try |
+ { |
+ items["pref:" + key] = JSON.parse(value); |
+ } |
+ catch (e) |
+ { |
+ } |
+ } |
+ else if (key == "currentVersion") |
+ { |
+ items[key] = value; |
+ } |
+ } |
Sebastian Noack
2015/03/12 23:35:29
Well, where doese code with a different implementa
|
+ |
+ chrome.storage.local.set(items, function() { |
+ localStorage.clear(); |
+ }); |
+ } |
+ }; |
/* Options */ |