| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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 27 matching lines...) Expand all Loading... | |
| 38 | 38 |
| 39 let {Filter} = require("filterClasses"); | 39 let {Filter} = require("filterClasses"); |
| 40 let {FilterNotifier} = require("filterNotifier"); | 40 let {FilterNotifier} = require("filterNotifier"); |
| 41 let {FilterStorage} = require("filterStorage"); | 41 let {FilterStorage} = require("filterStorage"); |
| 42 let {defaultMatcher} = require("matcher"); | 42 let {defaultMatcher} = require("matcher"); |
| 43 let {Prefs} = require("prefs"); | 43 let {Prefs} = require("prefs"); |
| 44 let {Subscription, SpecialSubscription, RegularSubscription, DownloadableSubscri ption, ExternalSubscription} = require("subscriptionClasses"); | 44 let {Subscription, SpecialSubscription, RegularSubscription, DownloadableSubscri ption, ExternalSubscription} = require("subscriptionClasses"); |
| 45 let {Synchronizer} = require("synchronizer"); | 45 let {Synchronizer} = require("synchronizer"); |
| 46 let {UI} = require("ui"); | 46 let {UI} = require("ui"); |
| 47 | 47 |
| 48 function initListeners() | 48 function initFilterListeners() |
| 49 { | 49 { |
| 50 FilterNotifier.on("save", onSave); | 50 FilterNotifier.on("load", onFiltersLoad); |
| 51 } | 51 FilterNotifier.on("save", onFiltersSave); |
| 52 | 52 } |
| 53 function onSave() | 53 |
| 54 { | 54 function onFiltersLoad() |
| 55 Messaging.sendRequest({ type: "Abb:OnSave" }); | 55 { |
| 56 Messaging.sendRequest({ type: "Abb:OnFiltersLoad" }); | |
| 57 } | |
| 58 | |
| 59 function onFiltersSave() | |
| 60 { | |
| 61 Messaging.sendRequest({ type: "Abb:OnFiltersSave" }); | |
| 56 } | 62 } |
| 57 | 63 |
| 58 function getWhitelistingFilter(url) | 64 function getWhitelistingFilter(url) |
| 59 { | 65 { |
| 60 let uriObject = Services.io.newURI(url, null, null); | 66 let uriObject = Services.io.newURI(url, null, null); |
| 61 try | 67 try |
| 62 { | 68 { |
| 63 return defaultMatcher.whitelist.matchesAny( | 69 return defaultMatcher.whitelist.matchesAny( |
| 64 uriObject.spec, "DOCUMENT", uriObject.host, false, null); | 70 uriObject.spec, "DOCUMENT", uriObject.host, false, null); |
| 65 } | 71 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 { | 172 { |
| 167 FilterStorage.removeFilter(filter); | 173 FilterStorage.removeFilter(filter); |
| 168 if (filter.subscriptions.length) | 174 if (filter.subscriptions.length) |
| 169 filter.disabled = true; | 175 filter.disabled = true; |
| 170 filter = getWhitelistingFilter(url); | 176 filter = getWhitelistingFilter(url); |
| 171 } | 177 } |
| 172 } | 178 } |
| 173 }, | 179 }, |
| 174 initCommunication: function() | 180 initCommunication: function() |
| 175 { | 181 { |
| 176 initListeners(); | 182 initFilterListeners(); |
|
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.
| |
| 177 | 183 |
| 178 Messaging.addListener((function(data) | 184 Messaging.addListener((function(data) |
| 179 { | 185 { |
| 180 if (!data) | 186 if (!data) |
| 181 return {"success": false, "error": "malformed request"}; | 187 return {"success": false, "error": "malformed request"}; |
| 182 | |
| 183 if (data["action"] == "getFiltersLoaded") | |
| 184 return {"success": true, "value": this.filtersLoaded}; | |
| 185 | 188 |
| 186 if (!this.filtersLoaded) | 189 if (!this.filtersLoaded) |
| 187 return {"success": false, "error": "filters not loaded"}; | 190 return {"success": false, "error": "filters not loaded"}; |
| 188 | 191 |
| 189 switch (data["action"]) | 192 switch (data["action"]) |
| 190 { | 193 { |
| 191 case "getAcceptableAdsEnabled": | 194 case "getAcceptableAdsEnabled": |
| 192 return {"success": true, "value": this.acceptableAdsEnabled}; | 195 return {"success": true, "value": this.acceptableAdsEnabled}; |
| 193 case "setAcceptableAdsEnabled": | 196 case "setAcceptableAdsEnabled": |
| 194 if ("enable" in data) | 197 if ("enable" in data) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 { | 240 { |
| 238 this.whitelistSite(data["url"], data["whitelisted"]); | 241 this.whitelistSite(data["url"], data["whitelisted"]); |
| 239 return {"success": true}; | 242 return {"success": true}; |
| 240 } | 243 } |
| 241 break; | 244 break; |
| 242 } | 245 } |
| 243 return {"success": false, "error": "malformed request"}; | 246 return {"success": false, "error": "malformed request"}; |
| 244 }).bind(this), "AdblockPlus:Api"); | 247 }).bind(this), "AdblockPlus:Api"); |
| 245 } | 248 } |
| 246 }; | 249 }; |
| LEFT | RIGHT |