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

Unified Diff: lib/child/elemHide.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/contentPolicy.js ('k') | lib/contentPolicy.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/child/elemHide.js
===================================================================
--- a/lib/child/elemHide.js
+++ b/lib/child/elemHide.js
@@ -32,18 +32,16 @@ catch (e)
Cu.reportError(e);
}
let {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
let {Utils} = require("utils");
let {getFrames, isPrivate} = require("child/utils");
-let messageID = 0;
-
// The allowXBL binding below won't have any effect on the element. For elements
// that should be hidden however we don't return any binding at all, this makes
// Gecko stop constructing the node - it cannot be shown.
const allowXBL = "<bindings xmlns='http://www.mozilla.org/xbl'><binding id='dummy' bindToUntrustedContent='true'/></bindings>";
const hideXBL = "<bindings xmlns='http://www.mozilla.org/xbl'/>";
/**
* about: URL module used to count hits.
@@ -126,45 +124,39 @@ HitRegistrationChannel.prototype = {
notificationCallbacks: null,
loadFlags: 0,
loadGroup: null,
name: null,
status: Cr.NS_OK,
asyncOpen: function(listener, context)
{
- let responseMessage = "AdblockPlus:ElemHideHit:Response" + (++messageID);
-
- let processResponse = (message) =>
+ let processResponse = (response) =>
{
- removeMessageListener(responseMessage, processResponse);
-
- let data = (message.data ? hideXBL : allowXBL);
+ let data = (response ? hideXBL : allowXBL);
let stream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream);
stream.setData(data, data.length);
try {
listener.onStartRequest(this, context);
} catch(e) {}
try {
listener.onDataAvailable(this, context, stream, 0, stream.available());
} catch(e) {}
try {
listener.onStopRequest(this, context, Cr.NS_OK);
} catch(e) {}
};
let window = Utils.getRequestWindow(this);
- addMessageListener(responseMessage, processResponse);
sendAsyncMessage("AdblockPlus:ElemHideHit", {
- responseMessage,
key: this.key,
frames: getFrames(window),
isPrivate: isPrivate(window)
- });
+ }, processResponse);
},
asyncOpen2: function(listener)
{
if (!this.loadInfo.triggeringPrincipal.equals(Utils.systemPrincipal))
throw Cr.NS_ERROR_FAILURE;
this.asyncOpen(listener, null);
},
« no previous file with comments | « lib/child/contentPolicy.js ('k') | lib/contentPolicy.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld