Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: background.js

Issue 5693109165883392: Issue 2040 - Replaced localStorage with chrome.storage.local (Closed)
Patch Set: Rebased and used map func for migration code Created March 13, 2015, 10:30 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/ext/background.js » ('j') | safari/ext/background.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: background.js
===================================================================
--- a/background.js
+++ b/background.js
@@ -69,31 +69,34 @@
{
if (action == "load")
{
- var addonVersion = require("info").addonVersion;
- var prevVersion = ext.storage.currentVersion;
+ ext.storage.get(["currentVersion"], function(items)
+ {
+ var addonVersion = require("info").addonVersion;
+ var prevVersion = items.currentVersion;
- // There are no filters stored so we need to reinitialize all filterlists
- if (!FilterStorage.firstRun && FilterStorage.subscriptions.length === 0)
- {
- filterlistsReinitialized = true;
- prevVersion = null;
- }
+ // There are no filters stored so we need to reinitialize all filterlists
+ if (!FilterStorage.firstRun && FilterStorage.subscriptions.length === 0)
+ {
+ filterlistsReinitialized = true;
+ prevVersion = null;
+ }
- if (prevVersion != addonVersion || FilterStorage.firstRun)
- {
- seenDataCorruption = prevVersion && FilterStorage.firstRun;
- ext.storage.currentVersion = addonVersion;
- addSubscription(prevVersion);
- }
+ if (prevVersion != addonVersion || FilterStorage.firstRun)
+ {
+ seenDataCorruption = prevVersion && FilterStorage.firstRun;
+ ext.storage.set("currentVersion", addonVersion);
+ addSubscription(prevVersion);
+ }
+
+ // The "Hide placeholders" option has been removed from the UI in 1.8.8.1285
+ // So we reset the option for users updating from older versions.
+ if (prevVersion && Services.vc.compare(prevVersion, "1.8.8.1285") < 0)
+ Prefs.hidePlaceholders = true;
+ });
if (canUseChromeNotifications)
initChromeNotifications();
initAntiAdblockNotification();
-
- // The "Hide placeholders" option has been removed from the UI in 1.8.8.1285
- // So we reset the option for users updating from older versions.
- if (prevVersion && Services.vc.compare(prevVersion, "1.8.8.1285") < 0)
- Prefs.hidePlaceholders = true;
}
// update browser actions when whitelisting might have changed,
@@ -107,20 +110,6 @@
var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"];
var htmlPages = new ext.PageMap();
-
-function removeDeprecatedOptions()
-{
- var deprecatedOptions = ["specialCaseYouTube", "experimental", "disableInlineTextAds"];
- deprecatedOptions.forEach(function(option)
- {
- if (option in ext.storage)
- delete ext.storage[option];
- });
-}
-
-// Remove deprecated options before we do anything else.
-removeDeprecatedOptions();
-
var activeNotification = null;
var contextMenuItem = {
« no previous file with comments | « no previous file | chrome/ext/background.js » ('j') | safari/ext/background.js » ('J')

Powered by Google App Engine
This is Rietveld