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

Side by Side Diff: adblockplus/Api.jsm

Issue 4826014056185856: Add filtersLoaded and filterLoadListener to AdblockPlusApi (Closed)
Patch Set: Created March 20, 2015, 4:26 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 14 matching lines...) Expand all
25 Cu.import("resource://gre/modules/Services.jsm"); 25 Cu.import("resource://gre/modules/Services.jsm");
26 26
27 function require(module) 27 function require(module)
28 { 28 {
29 let result = {}; 29 let result = {};
30 result.wrappedJSObject = result; 30 result.wrappedJSObject = result;
31 Services.obs.notifyObservers(result, "adblockplus-require", module); 31 Services.obs.notifyObservers(result, "adblockplus-require", module);
32 return result.exports; 32 return result.exports;
33 } 33 }
34 34
35 let {FilterNotifier} = require("filterNotifier");
35 let {FilterStorage} = require("filterStorage"); 36 let {FilterStorage} = require("filterStorage");
36 let {Prefs} = require("prefs"); 37 let {Prefs} = require("prefs");
37 let {UI} = require("ui"); 38 let {UI} = require("ui");
38 39
40 let filtersLoaded = false;
41
39 var AdblockPlusApi = 42 var AdblockPlusApi =
40 { 43 {
44 get filtersLoaded()
45 {
46 return filtersLoaded;
Wladimir Palant 2015/03/20 16:38:20 return FilterStorage._loading?
Felix Dahlke 2015/03/20 16:54:57 What we want to know here is whether the filters h
Felix Dahlke 2015/03/20 21:13:02 Well actually, you're right. Api.jsm is not necess
47 },
48 filterLoadListener: null,
41 get acceptableAdsEnabled() 49 get acceptableAdsEnabled()
42 { 50 {
43 return FilterStorage.subscriptions.some( 51 return FilterStorage.subscriptions.some(
44 (subscription) => subscription.url == Prefs.subscriptions_exceptionsurl); 52 (subscription) => subscription.url == Prefs.subscriptions_exceptionsurl);
45 }, 53 },
46 set acceptableAdsEnabled(acceptableAdsEnabled) 54 set acceptableAdsEnabled(acceptableAdsEnabled)
47 { 55 {
48 if (acceptableAdsEnabled != AdblockPlusApi.acceptableAdsEnabled) 56 if (acceptableAdsEnabled != AdblockPlusApi.acceptableAdsEnabled)
49 UI.toggleAcceptableAds(); 57 UI.toggleAcceptableAds();
50 } 58 }
51 }; 59 };
60
61 FilterNotifier.addListener(function(action)
62 {
63 if (action != "load")
64 return;
65
66 filtersLoaded = true;
Wladimir Palant 2015/03/20 16:38:20 This listener should be removed after the first ca
Felix Dahlke 2015/03/20 16:54:57 Done.
Felix Dahlke 2015/03/20 17:13:06 Well, NOW it's done. Misunderstood you, unregister
67 if ("filterLoadListener" in AdblockPlusApi &&
68 typeof AdblockPlusApi.filterLoadListener == "function")
Wladimir Palant 2015/03/20 16:38:20 Using typeof is sufficient, "filterLoadListener" i
Felix Dahlke 2015/03/20 16:54:57 Ouch, getting rusty...
69 AdblockPlusApi.filterLoadListener();
70 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld