OLD | NEW |
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 16 matching lines...) Expand all Loading... |
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 | 36 |
| 37 let {shouldAllow} = require("child/contentPolicy"); |
37 let {Utils} = require("utils"); | 38 let {Utils} = require("utils"); |
38 let {getFrames, isPrivate} = require("child/utils"); | |
39 | 39 |
40 // The allowXBL binding below won't have any effect on the element. For elements | 40 // The allowXBL binding below won't have any effect on the element. For elements |
41 // that should be hidden however we don't return any binding at all, this makes | 41 // that should be hidden however we don't return any binding at all, this makes |
42 // Gecko stop constructing the node - it cannot be shown. | 42 // Gecko stop constructing the node - it cannot be shown. |
43 const allowXBL = "<bindings xmlns='http://www.mozilla.org/xbl'><binding id='dumm
y' bindToUntrustedContent='true'/></bindings>"; | 43 const allowXBL = "<bindings xmlns='http://www.mozilla.org/xbl'><binding id='dumm
y' bindToUntrustedContent='true'/></bindings>"; |
44 const hideXBL = "<bindings xmlns='http://www.mozilla.org/xbl'/>"; | 44 const hideXBL = "<bindings xmlns='http://www.mozilla.org/xbl'/>"; |
45 | 45 |
46 /** | 46 /** |
47 * about: URL module used to count hits. | 47 * about: URL module used to count hits. |
48 * @class | 48 * @class |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 owner: Utils.systemPrincipal, | 122 owner: Utils.systemPrincipal, |
123 securityInfo: null, | 123 securityInfo: null, |
124 notificationCallbacks: null, | 124 notificationCallbacks: null, |
125 loadFlags: 0, | 125 loadFlags: 0, |
126 loadGroup: null, | 126 loadGroup: null, |
127 name: null, | 127 name: null, |
128 status: Cr.NS_OK, | 128 status: Cr.NS_OK, |
129 | 129 |
130 asyncOpen: function(listener, context) | 130 asyncOpen: function(listener, context) |
131 { | 131 { |
132 let processResponse = (response) => | 132 let processResponse = (allow) => |
133 { | 133 { |
134 let data = (response ? hideXBL : allowXBL); | 134 let data = (allow ? allowXBL : hideXBL); |
135 let stream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci
.nsIStringInputStream); | 135 let stream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci
.nsIStringInputStream); |
136 stream.setData(data, data.length); | 136 stream.setData(data, data.length); |
137 | 137 |
138 try { | 138 try { |
139 listener.onStartRequest(this, context); | 139 listener.onStartRequest(this, context); |
140 } catch(e) {} | 140 } catch(e) {} |
141 try { | 141 try { |
142 listener.onDataAvailable(this, context, stream, 0, stream.available()); | 142 listener.onDataAvailable(this, context, stream, 0, stream.available()); |
143 } catch(e) {} | 143 } catch(e) {} |
144 try { | 144 try { |
145 listener.onStopRequest(this, context, Cr.NS_OK); | 145 listener.onStopRequest(this, context, Cr.NS_OK); |
146 } catch(e) {} | 146 } catch(e) {} |
147 }; | 147 }; |
148 | 148 |
149 let window = Utils.getRequestWindow(this); | 149 let window = Utils.getRequestWindow(this); |
150 sendAsyncMessage("AdblockPlus:ElemHideHit", { | 150 shouldAllow(window, window.document, "ELEMHIDE", this.key, processResponse); |
151 key: this.key, | |
152 frames: getFrames(window), | |
153 isPrivate: isPrivate(window) | |
154 }, processResponse); | |
155 }, | 151 }, |
156 | 152 |
157 asyncOpen2: function(listener) | 153 asyncOpen2: function(listener) |
158 { | 154 { |
159 if (!this.loadInfo.triggeringPrincipal.equals(Utils.systemPrincipal)) | 155 if (!this.loadInfo.triggeringPrincipal.equals(Utils.systemPrincipal)) |
160 throw Cr.NS_ERROR_FAILURE; | 156 throw Cr.NS_ERROR_FAILURE; |
161 this.asyncOpen(listener, null); | 157 this.asyncOpen(listener, null); |
162 }, | 158 }, |
163 | 159 |
164 open: function() | 160 open: function() |
(...skipping 12 matching lines...) Expand all Loading... |
177 { | 173 { |
178 throw Cr.NS_ERROR_NOT_IMPLEMENTED; | 174 throw Cr.NS_ERROR_NOT_IMPLEMENTED; |
179 }, | 175 }, |
180 resume: function() | 176 resume: function() |
181 { | 177 { |
182 throw Cr.NS_ERROR_NOT_IMPLEMENTED; | 178 throw Cr.NS_ERROR_NOT_IMPLEMENTED; |
183 }, | 179 }, |
184 | 180 |
185 QueryInterface: XPCOMUtils.generateQI([Ci.nsIChannel, Ci.nsIRequest]) | 181 QueryInterface: XPCOMUtils.generateQI([Ci.nsIChannel, Ci.nsIRequest]) |
186 }; | 182 }; |
OLD | NEW |