| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 function require(module) | 31 function require(module) |
| 32 { | 32 { |
| 33 let result = {}; | 33 let result = {}; |
| 34 result.wrappedJSObject = result; | 34 result.wrappedJSObject = result; |
| 35 Services.obs.notifyObservers(result, "adblockplus-require", module); | 35 Services.obs.notifyObservers(result, "adblockplus-require", module); |
| 36 return result.exports; | 36 return result.exports; |
| 37 } | 37 } |
| 38 | 38 |
| 39 let {Filter} = require("filterClasses"); | 39 let {Filter} = require("filterClasses"); |
| 40 let {FilterNotifier} = require("filterNotifier"); | |
| 40 let {FilterStorage} = require("filterStorage"); | 41 let {FilterStorage} = require("filterStorage"); |
| 41 let {defaultMatcher} = require("matcher"); | 42 let {defaultMatcher} = require("matcher"); |
| 42 let {Prefs} = require("prefs"); | 43 let {Prefs} = require("prefs"); |
| 43 let {Subscription, SpecialSubscription, RegularSubscription, DownloadableSubscri ption, ExternalSubscription} = require("subscriptionClasses"); | 44 let {Subscription, SpecialSubscription, RegularSubscription, DownloadableSubscri ption, ExternalSubscription} = require("subscriptionClasses"); |
| 44 let {Synchronizer} = require("synchronizer"); | 45 let {Synchronizer} = require("synchronizer"); |
| 45 let {UI} = require("ui"); | 46 let {UI} = require("ui"); |
| 46 | 47 |
| 48 function initListeners() | |
| 49 { | |
| 50 FilterNotifier.on("save", onSave); | |
| 51 } | |
| 52 | |
| 53 function onSave() | |
| 54 { | |
| 55 Messaging.sendRequest({ type: "Abb:OnSave" }); | |
| 56 } | |
| 57 | |
| 47 function getWhitelistingFilter(url) | 58 function getWhitelistingFilter(url) |
| 48 { | 59 { |
| 49 let uriObject = Services.io.newURI(url, null, null); | 60 let uriObject = Services.io.newURI(url, null, null); |
| 50 try | 61 try |
| 51 { | 62 { |
| 52 return defaultMatcher.whitelist.matchesAny( | 63 return defaultMatcher.whitelist.matchesAny( |
| 53 uriObject.spec, "DOCUMENT", uriObject.host, false, null); | 64 uriObject.spec, "DOCUMENT", uriObject.host, false, null); |
| 54 } | 65 } |
| 55 catch (e) | 66 catch (e) |
| 56 { | 67 { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 { | 166 { |
| 156 FilterStorage.removeFilter(filter); | 167 FilterStorage.removeFilter(filter); |
| 157 if (filter.subscriptions.length) | 168 if (filter.subscriptions.length) |
| 158 filter.disabled = true; | 169 filter.disabled = true; |
| 159 filter = getWhitelistingFilter(url); | 170 filter = getWhitelistingFilter(url); |
| 160 } | 171 } |
| 161 } | 172 } |
| 162 }, | 173 }, |
| 163 initCommunication: function() | 174 initCommunication: function() |
| 164 { | 175 { |
| 176 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.
| |
| 177 | |
| 165 Messaging.addListener((function(data) | 178 Messaging.addListener((function(data) |
| 166 { | 179 { |
| 167 if (!data) | 180 if (!data) |
| 168 return {"success": false, "error": "malformed request"}; | 181 return {"success": false, "error": "malformed request"}; |
| 169 | 182 |
| 170 if (data["action"] == "getFiltersLoaded") | 183 if (data["action"] == "getFiltersLoaded") |
| 171 return {"success": true, "value": this.filtersLoaded}; | 184 return {"success": true, "value": this.filtersLoaded}; |
| 172 | 185 |
| 173 if (!this.filtersLoaded) | 186 if (!this.filtersLoaded) |
| 174 return {"success": false, "error": "filters not loaded"}; | 187 return {"success": false, "error": "filters not loaded"}; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 { | 237 { |
| 225 this.whitelistSite(data["url"], data["whitelisted"]); | 238 this.whitelistSite(data["url"], data["whitelisted"]); |
| 226 return {"success": true}; | 239 return {"success": true}; |
| 227 } | 240 } |
| 228 break; | 241 break; |
| 229 } | 242 } |
| 230 return {"success": false, "error": "malformed request"}; | 243 return {"success": false, "error": "malformed request"}; |
| 231 }).bind(this), "AdblockPlus:Api"); | 244 }).bind(this), "AdblockPlus:Api"); |
| 232 } | 245 } |
| 233 }; | 246 }; |
| OLD | NEW |