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

Unified Diff: lib/contentPolicy.js

Issue 29329742: Issue 3251 - Simplify messaging from child scripts to parent (Closed)
Patch Set: Adjusted a caller that was forgotten Created Nov. 9, 2015, 1:36 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/child/elemHide.js ('k') | lib/elemHide.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/contentPolicy.js
===================================================================
--- a/lib/contentPolicy.js
+++ b/lib/contentPolicy.js
@@ -73,26 +73,18 @@ 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));
-
- let handler2 = () => collapsedClass;
- messageManager.addMessageListener("AdblockPlus:GetCollapsedClass", handler2);
- onShutdown.add(() => messageManager.removeMessageListener("AdblockPlus:GetCollapsedClass", handler2));
+ Utils.addChildMessageListener("AdblockPlus:ShouldAllow", this.shouldAllow.bind(this));
+ Utils.addChildMessageListener("AdblockPlus:GetCollapsedClass", () => collapsedClass);
// Generate class identifier used to collapse node and register corresponding
// stylesheet.
let offset = "a".charCodeAt(0);
for (let i = 0; i < 20; i++)
collapsedClass += String.fromCharCode(offset + Math.random() * 26);
let collapseStyle = Services.io.newURI("data:text/css," +
« no previous file with comments | « lib/child/elemHide.js ('k') | lib/elemHide.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld