| Index: lib/contentPolicy.js |
| =================================================================== |
| --- a/lib/contentPolicy.js |
| +++ b/lib/contentPolicy.js |
| @@ -67,33 +67,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); |
| - let messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"] |
| - .getService(Ci.nsIMessageListenerManager) |
| - .QueryInterface(Ci.nsIMessageBroadcaster); |
| - let handler = (message => this.shouldAllow(message.data)); |
| - messageManager.addMessageListener("AdblockPlus:ShouldAllow", handler); |
| - onShutdown.add(() => messageManager.removeMessageListener("AdblockPlus:ShouldAllow", handler)); |
| + Utils.addChildMessageListener("AdblockPlus:ShouldAllow", this.shouldAllow.bind(this)); |
| // 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); |
| - |
| - let handler2 = () => collapsedClass; |
| - messageManager.addMessageListener("AdblockPlus:GetCollapsedClass", handler2); |
| - onShutdown.add(() => messageManager.removeMessageListener("AdblockPlus:GetCollapsedClass", handler2)); |
| + Utils.addChildMessageListener("AdblockPlus:GetCollapsedClass", () => collapsedClass); |
| 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); |