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": |