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

Side by Side Diff: lib/child/elemHide.js

Issue 29329336: Issue 3208 - Inject content policy implementation into all processes (Closed)
Patch Set: Created Oct. 22, 2015, 9:03 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 15 matching lines...) Expand all
26 let property = Object.getOwnPropertyDescriptor(proto, "Components"); 26 let property = Object.getOwnPropertyDescriptor(proto, "Components");
27 if (property && property.get) 27 if (property && property.get)
28 delete proto.Components; 28 delete proto.Components;
29 } 29 }
30 catch (e) 30 catch (e)
31 { 31 {
32 Cu.reportError(e); 32 Cu.reportError(e);
33 } 33 }
34 34
35 let {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {}); 35 let {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
36 let {PrivateBrowsingUtils} = Cu.import("resource://gre/modules/PrivateBrowsingUt ils.jsm")
37 36
38 let {Utils} = require("utils"); 37 let {Utils} = require("utils");
38 let {getFrames, isPrivate} = require("child/utils");
39 39
40 let messageID = 0; 40 let messageID = 0;
41 41
42 // The allowXBL binding below won't have any effect on the element. For elements 42 // The allowXBL binding below won't have any effect on the element. For elements
43 // that should be hidden however we don't return any binding at all, this makes 43 // that should be hidden however we don't return any binding at all, this makes
44 // Gecko stop constructing the node - it cannot be shown. 44 // Gecko stop constructing the node - it cannot be shown.
45 const allowXBL = "<bindings xmlns='http://www.mozilla.org/xbl'><binding id='dumm y' bindToUntrustedContent='true'/></bindings>"; 45 const allowXBL = "<bindings xmlns='http://www.mozilla.org/xbl'><binding id='dumm y' bindToUntrustedContent='true'/></bindings>";
46 const hideXBL = "<bindings xmlns='http://www.mozilla.org/xbl'/>"; 46 const hideXBL = "<bindings xmlns='http://www.mozilla.org/xbl'/>";
47 47
48 function getFrames(window)
49 {
50 let frames = [];
51 while (window)
52 {
53 let frame = {
54 location: window.location.href,
55 sitekey: null
56 };
57
58 let documentElement = window.document && window.document.documentElement;
59 if (documentElement)
60 frame.sitekey = documentElement.getAttribute("data-adblockkey")
61
62 if (window == window.parent)
63 frame.privateBrowsing = PrivateBrowsingUtils.isWindowPrivate(window);
64
65 frames.push(frame);
66 window = (window != window.parent ? window.parent : null);
67 }
68 return frames;
69 }
70
71 /** 48 /**
72 * about: URL module used to count hits. 49 * about: URL module used to count hits.
73 * @class 50 * @class
74 */ 51 */
75 let AboutHandler = 52 let AboutHandler =
76 { 53 {
77 classID: Components.ID("{55fb7be0-1dd2-11b2-98e6-9e97caf8ba67}"), 54 classID: Components.ID("{55fb7be0-1dd2-11b2-98e6-9e97caf8ba67}"),
78 classDescription: "Element hiding hit registration protocol handler", 55 classDescription: "Element hiding hit registration protocol handler",
79 aboutPrefix: "abp-elemhidehit", 56 aboutPrefix: "abp-elemhidehit",
80 57
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 listener.onStartRequest(this, context); 145 listener.onStartRequest(this, context);
169 } catch(e) {} 146 } catch(e) {}
170 try { 147 try {
171 listener.onDataAvailable(this, context, stream, 0, stream.available()); 148 listener.onDataAvailable(this, context, stream, 0, stream.available());
172 } catch(e) {} 149 } catch(e) {}
173 try { 150 try {
174 listener.onStopRequest(this, context, Cr.NS_OK); 151 listener.onStopRequest(this, context, Cr.NS_OK);
175 } catch(e) {} 152 } catch(e) {}
176 }; 153 };
177 154
155 let window = Utils.getRequestWindow(this);
178 addMessageListener(responseMessage, processResponse); 156 addMessageListener(responseMessage, processResponse);
179 sendAsyncMessage("AdblockPlus:ElemHideHit", { 157 sendAsyncMessage("AdblockPlus:ElemHideHit", {
180 responseMessage, 158 responseMessage,
181 key: this.key, 159 key: this.key,
182 frames: getFrames(Utils.getRequestWindow(this)) 160 frames: getFrames(window),
161 isPrivate: isPrivate(window)
183 }); 162 });
184 }, 163 },
185 164
186 asyncOpen2: function(listener) 165 asyncOpen2: function(listener)
187 { 166 {
188 if (!this.loadInfo.triggeringPrincipal.equals(Utils.systemPrincipal)) 167 if (!this.loadInfo.triggeringPrincipal.equals(Utils.systemPrincipal))
189 throw Cr.NS_ERROR_FAILURE; 168 throw Cr.NS_ERROR_FAILURE;
190 this.asyncOpen(listener, null); 169 this.asyncOpen(listener, null);
191 }, 170 },
192 171
(...skipping 13 matching lines...) Expand all
206 { 185 {
207 throw Cr.NS_ERROR_NOT_IMPLEMENTED; 186 throw Cr.NS_ERROR_NOT_IMPLEMENTED;
208 }, 187 },
209 resume: function() 188 resume: function()
210 { 189 {
211 throw Cr.NS_ERROR_NOT_IMPLEMENTED; 190 throw Cr.NS_ERROR_NOT_IMPLEMENTED;
212 }, 191 },
213 192
214 QueryInterface: XPCOMUtils.generateQI([Ci.nsIChannel, Ci.nsIRequest]) 193 QueryInterface: XPCOMUtils.generateQI([Ci.nsIChannel, Ci.nsIRequest])
215 }; 194 };
OLDNEW

Powered by Google App Engine
This is Rietveld