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: Rebased Created Nov. 12, 2015, 12:29 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
@@ -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);
« 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