Index: background.js |
=================================================================== |
--- a/background.js |
+++ b/background.js |
@@ -36,29 +36,31 @@ var Utils = require("utils").Utils; |
var Notification = require("notification").Notification; |
// Some types cannot be distinguished |
RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT; |
RegExpFilter.typeMap.MEDIA = RegExpFilter.typeMap.FONT = RegExpFilter.typeMap.OTHER; |
var isFirstRun = false; |
var seenDataCorruption = false; |
+var importingOldData = false; |
require("filterNotifier").FilterNotifier.addListener(function(action) |
{ |
if (action == "load") |
{ |
importOldData(); |
var addonVersion = require("info").addonVersion; |
- var prevVersion = localStorage["currentVersion"]; |
- if (seenDataCorruption || prevVersion != addonVersion) |
+ var prevVersion = localStorage.currentVersion; |
+ if (prevVersion != addonVersion) |
{ |
isFirstRun = !prevVersion; |
- localStorage["currentVersion"] = addonVersion; |
- addSubscription(prevVersion); |
+ localStorage.currentVersion = addonVersion; |
+ if (!importingOldData) |
Thomas Greiner
2013/11/26 13:40:13
You're only using this variable for this check her
Wladimir Palant
2013/11/27 15:46:21
Done.
|
+ addSubscription(prevVersion); |
} |
} |
}); |
// Special-case domains for which we cannot use style-based hiding rules. |
// See http://crbug.com/68705. |
var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"]; |
@@ -149,18 +151,18 @@ function refreshIconAndContextMenu(tab) |
/** |
* Old versions for Opera stored patterns.ini in the localStorage object, this |
* will import it into FilterStorage properly. |
*/ |
function importOldData() |
{ |
if ("patterns.ini" in localStorage) |
{ |
+ importingOldData = true; |
FilterStorage.loadFromDisk(localStorage["patterns.ini"]); |
- seenDataCorruption = false; |
var remove = []; |
for (var key in localStorage) |
if (key.indexOf("patterns.ini") == 0 || key.indexOf("patterns-backup") == 0) |
remove.push(key); |
for (var i = 0; i < remove.length; i++) |
delete localStorage[remove[i]]; |
} |
@@ -173,17 +175,17 @@ function importOldData() |
function addSubscription(prevVersion) |
{ |
// Make sure to remove "Recommended filters", no longer necessary |
var toRemove = "https://easylist-downloads.adblockplus.org/chrome_supplement.txt"; |
if (toRemove in FilterStorage.knownSubscriptions) |
FilterStorage.removeSubscription(FilterStorage.knownSubscriptions[toRemove]); |
// Add "acceptable ads" subscription for new users |
- var addAcceptable = !prevVersion || seenDataCorruption; |
+ var addAcceptable = !prevVersion; |
if (addAcceptable) |
{ |
addAcceptable = !FilterStorage.subscriptions.some(function(subscription) |
{ |
return subscription.url == Prefs.subscriptions_exceptionsurl; |
}); |
} |