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: Instead of pooling, adding observer for save operations performed by the extension Created Dec. 21, 2016, 2:22 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,34 @@ 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 initListeners()
+{
+ FilterNotifier.on("save", onSave);
+}
+
+function onSave()
+{
+ Messaging.sendRequest({ type: "Abb:OnSave" });
+}
+
function getWhitelistingFilter(url)
{
let uriObject = Services.io.newURI(url, null, null);
try
{
return defaultMatcher.whitelist.matchesAny(
uriObject.spec, "DOCUMENT", uriObject.host, false, null);
}
@@ -157,16 +168,18 @@ var AdblockPlusApi =
if (filter.subscriptions.length)
filter.disabled = true;
filter = getWhitelistingFilter(url);
}
}
},
initCommunication: function()
{
+ initListeners();
Felix Dahlke 2016/12/21 20:23:25 Nit: Considering how there's only a single listene
diegocarloslima 2016/12/21 20:29:31 Actually there is another listener that is already
Felix Dahlke 2016/12/21 20:36:20 Oh, so it seems you need to rebase this patch? Thi
diegocarloslima 2016/12/21 20:42:03 Acknowledged.
+
Messaging.addListener((function(data)
{
if (!data)
return {"success": false, "error": "malformed request"};
if (data["action"] == "getFiltersLoaded")
return {"success": true, "value": this.filtersLoaded};

Powered by Google App Engine
This is Rietveld