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: Created Nov. 4, 2015, 2:58 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
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 => JSON.stringify(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," +
« lib/child/bootstrap.js ('K') | « lib/child/elemHide.js ('k') | lib/elemHide.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld