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

Unified Diff: adblockplus/Api.jsm

Issue 29350065: Issue 2853 - Settings changes are sometimes not saved if the user quits the app (Closed)
Patch Set: Removing now unused getFiltersLoaded Created Dec. 28, 2016, 2:15 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
Index: adblockplus/Api.jsm
===================================================================
--- a/adblockplus/Api.jsm
+++ b/adblockplus/Api.jsm
@@ -32,23 +32,40 @@ function require(module)
{
let result = {};
result.wrappedJSObject = result;
Services.obs.notifyObservers(result, "adblockplus-require", module);
return result.exports;
}
let {Filter} = require("filterClasses");
+let {FilterNotifier} = require("filterNotifier");
let {FilterStorage} = require("filterStorage");
let {defaultMatcher} = require("matcher");
let {Prefs} = require("prefs");
let {Subscription, SpecialSubscription, RegularSubscription, DownloadableSubscription, ExternalSubscription} = require("subscriptionClasses");
let {Synchronizer} = require("synchronizer");
let {UI} = require("ui");
+function initFilterListeners()
+{
+ FilterNotifier.on("load", onFiltersLoad);
+ FilterNotifier.on("save", onFiltersSave);
+}
+
+function onFiltersLoad()
+{
+ Messaging.sendRequest({ type: "Abb:OnFiltersLoad" });
+}
+
+function onFiltersSave()
+{
+ Messaging.sendRequest({ type: "Abb:OnFiltersSave" });
+}
+
function getWhitelistingFilter(url)
{
let uriObject = Services.io.newURI(url, null, null);
try
{
return defaultMatcher.whitelist.matchesAny(
uriObject.spec, "DOCUMENT", uriObject.host, false, null);
}
@@ -157,24 +174,23 @@ var AdblockPlusApi =
if (filter.subscriptions.length)
filter.disabled = true;
filter = getWhitelistingFilter(url);
}
}
},
initCommunication: function()
{
+ initFilterListeners();
+
Messaging.addListener((function(data)
{
if (!data)
return {"success": false, "error": "malformed request"};
- if (data["action"] == "getFiltersLoaded")
- return {"success": true, "value": this.filtersLoaded};
-
if (!this.filtersLoaded)
return {"success": false, "error": "filters not loaded"};
switch (data["action"])
{
case "getAcceptableAdsEnabled":
return {"success": true, "value": this.acceptableAdsEnabled};
case "setAcceptableAdsEnabled":

Powered by Google App Engine
This is Rietveld