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

Unified Diff: lib/contentPolicy.js

Issue 29338279: Issue 3499 - Use new messaging API in the content policy implementation (Closed)
Patch Set: More obvious logic in postProcessNodes Created March 16, 2016, 10:10 a.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
« lib/child/contentPolicy.js ('K') | « lib/child/contentPolicy.js ('k') | no next file » | 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
@@ -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));
// 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);
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();
/**
« lib/child/contentPolicy.js ('K') | « lib/child/contentPolicy.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld