Index: background.js |
=================================================================== |
--- a/background.js |
+++ b/background.js |
@@ -36,22 +36,21 @@ 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 importingOldData = importOldData(); |
var addonVersion = require("info").addonVersion; |
var prevVersion = localStorage.currentVersion; |
if (prevVersion != addonVersion) |
{ |
isFirstRun = !prevVersion; |
localStorage.currentVersion = addonVersion; |
if (!importingOldData) |
@@ -146,31 +145,35 @@ function refreshIconAndContextMenu(tab) |
chrome.contextMenus.removeAll(); |
else |
showContextMenu(); |
} |
/** |
* Old versions for Opera stored patterns.ini in the localStorage object, this |
* will import it into FilterStorage properly. |
+ * @return {Boolean} true if data import is in progress |
*/ |
function importOldData() |
{ |
if ("patterns.ini" in localStorage) |
{ |
- importingOldData = true; |
FilterStorage.loadFromDisk(localStorage["patterns.ini"]); |
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]]; |
+ |
+ return true; |
} |
+ else |
+ return false; |
} |
/** |
* This function is called on an extension update. It will add the default |
* filter subscription if necessary. |
*/ |
function addSubscription(prevVersion) |
{ |