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

Unified Diff: background.js

Issue 5923900886089728: Use FileSystem API to store data in Opera (Closed)
Patch Set: Better approach to prevent first-run page from appearing Created Nov. 26, 2013, 12:35 p.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 | lib/filesystem/io.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
});
}
« no previous file with comments | « no previous file | lib/filesystem/io.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld