| Index: lib/contentPolicy.js |
| =================================================================== |
| --- a/lib/contentPolicy.js |
| +++ b/lib/contentPolicy.js |
| @@ -20,16 +20,17 @@ |
| */ |
| "use strict"; |
| let {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {}); |
| let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); |
| let {Utils} = require("utils"); |
| +let {port} = require("messaging"); |
| let {Prefs} = require("prefs"); |
| let {FilterStorage} = require("filterStorage"); |
| let {BlockingFilter, WhitelistFilter, RegExpFilter} = require("filterClasses"); |
| let {defaultMatcher} = require("matcher"); |
| let {ElemHide} = require("elemHide"); |
| /** |
| * Public policy checking functions and auxiliary objects |
| @@ -82,25 +83,25 @@ var Policy = exports.Policy = |
| * Called on module startup, initializes various exported properties. |
| */ |
| init: function() |
| { |
| // whitelisted URL schemes |
| for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" ")) |
| this.whitelistSchemes.add(scheme); |
| - Utils.addChildMessageListener("AdblockPlus:ShouldAllow", message => this.shouldAllow(message)); |
| + port.on("shouldAllow", (message, sender) => this.shouldAllow(message)); |
|
Erik
2016/03/15 22:57:00
`(message, sender) => this.shouldAllow(message)` =
Wladimir Palant
2016/03/16 10:13:00
I'd rather name all parameters explicitly even if
Thomas Greiner
2016/03/16 10:59:11
Personally, I also prefer naming parameters explic
|
| // Generate class identifier used to collapse nodes and register |
| // corresponding stylesheet. |
| let collapsedClass = ""; |
| let offset = "a".charCodeAt(0); |
| for (let i = 0; i < 20; i++) |
| collapsedClass += String.fromCharCode(offset + Math.random() * 26); |
| - Utils.addChildMessageListener("AdblockPlus:GetCollapsedClass", () => collapsedClass); |
| + port.on("getCollapsedClass", (message, sender) => collapsedClass); |
|
Erik
2016/03/15 22:57:00
`(message, sender) => collapsedClass` => `() => co
|
| let collapseStyle = Services.io.newURI("data:text/css," + |
| encodeURIComponent("." + collapsedClass + |
| "{-moz-binding: url(chrome://global/content/bindings/general.xml#foobarbazdummy) !important;}"), null, null); |
| Utils.styleService.loadAndRegisterSheet(collapseStyle, Ci.nsIStyleSheetService.USER_SHEET); |
| onShutdown.add(() => |
| { |
| Utils.styleService.unregisterSheet(collapseStyle, Ci.nsIStyleSheetService.USER_SHEET); |
| @@ -268,32 +269,28 @@ var Policy = exports.Policy = |
| /** |
| * Deletes nodes that were previously stored with a |
| * RequestNotifier.storeNodesForEntries() call or similar. |
| * @param {string} id unique ID of the nodes |
| */ |
| deleteNodes: function(id) |
| { |
| - let messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"] |
| - .getService(Ci.nsIMessageBroadcaster); |
| - messageManager.broadcastAsyncMessage("AdblockPlus:DeleteNodes", id); |
| + port.emit("deleteNodes", id); |
| }, |
| /** |
| * Asynchronously re-checks filters for nodes given by an ID previously |
| * returned by a RequestNotifier.storeNodesForEntries() call or similar. |
| * @param {string} id unique ID of the nodes |
| * @param {RequestEntry} entry |
| */ |
| refilterNodes: function(id, entry) |
| { |
| - let messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"] |
| - .getService(Ci.nsIMessageBroadcaster); |
| - messageManager.broadcastAsyncMessage("AdblockPlus:RefilterNodes", { |
| + port.emit("refilterNodes", { |
| nodesID: id, |
| entry: entry |
| }); |
| } |
| }; |
| Policy.init(); |
| /** |