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: Fixed remaining comment Created Nov. 27, 2013, 3:45 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 | no next file » | 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,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)
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld