diff options
| author | Jez Ng | 2012-01-18 22:37:05 +0800 |
|---|---|---|
| committer | Jez Ng | 2012-01-26 02:48:00 -0500 |
| commit | c51d33799eb56675292b65ef0cc04ef97ba02f6f (patch) | |
| tree | 9ee7afd7593842fa91f28d0d1a59bdee4b562368 /background | |
| parent | 4ad21d921120dba576a75d432b1e2bf4d42f51e3 (diff) | |
| download | vimium-c51d33799eb56675292b65ef0cc04ef97ba02f6f.tar.bz2 | |
Add migration code for old localStorage values.
Finish up the wrapping of localStorage. All background code should now
modify localStorage via settings.js rather than doing it directly.
Diffstat (limited to 'background')
| -rw-r--r-- | background/settings.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/background/settings.js b/background/settings.js index 4792429d..51ac053c 100644 --- a/background/settings.js +++ b/background/settings.js @@ -35,6 +35,19 @@ var settings = { nextPatterns: "next,more,>,\u2192,\xbb,\u226b,>>", }, + init: function() { + // settingsVersion was introduced in v1.31, and is used to coordinate data migration. We do not use + // previousVersion as it is used to coordinate the display of the upgrade message, and is not updated + // early enough when the extension loads. + // 1.31 was also the version where we converted all localStorage values to JSON. + if (!this.has("settingsVersion")) { + for (var key in localStorage) { + localStorage[key] = JSON.stringify(localStorage[key]); + } + this.set("settingsVersion", utils.getCurrentVersion()); + } + }, + get: function(key) { if (!(key in localStorage)) return this.defaultSettings[key]; @@ -59,3 +72,5 @@ var settings = { }, }; + +settings.init(); |
