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 19 matching lines...) Expand all Loading... |
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 {Utils} = require("utils"); | 37 let {Utils} = require("utils"); |
38 let {getFrames, isPrivate} = require("child/utils"); | 38 let {getFrames, isPrivate} = require("child/utils"); |
39 | 39 |
40 let messageID = 0; | |
41 | |
42 // 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 |
43 // 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 |
44 // Gecko stop constructing the node - it cannot be shown. | 42 // 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>"; | 43 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'/>"; | 44 const hideXBL = "<bindings xmlns='http://www.mozilla.org/xbl'/>"; |
47 | 45 |
48 /** | 46 /** |
49 * about: URL module used to count hits. | 47 * about: URL module used to count hits. |
50 * @class | 48 * @class |
51 */ | 49 */ |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 owner: Utils.systemPrincipal, | 122 owner: Utils.systemPrincipal, |
125 securityInfo: null, | 123 securityInfo: null, |
126 notificationCallbacks: null, | 124 notificationCallbacks: null, |
127 loadFlags: 0, | 125 loadFlags: 0, |
128 loadGroup: null, | 126 loadGroup: null, |
129 name: null, | 127 name: null, |
130 status: Cr.NS_OK, | 128 status: Cr.NS_OK, |
131 | 129 |
132 asyncOpen: function(listener, context) | 130 asyncOpen: function(listener, context) |
133 { | 131 { |
134 let responseMessage = "AdblockPlus:ElemHideHit:Response" + (++messageID); | 132 let processResponse = (response) => |
135 | |
136 let processResponse = (message) => | |
137 { | 133 { |
138 removeMessageListener(responseMessage, processResponse); | 134 let data = (response ? hideXBL : allowXBL); |
139 | |
140 let data = (message.data ? hideXBL : allowXBL); | |
141 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); |
142 stream.setData(data, data.length); | 136 stream.setData(data, data.length); |
143 | 137 |
144 try { | 138 try { |
145 listener.onStartRequest(this, context); | 139 listener.onStartRequest(this, context); |
146 } catch(e) {} | 140 } catch(e) {} |
147 try { | 141 try { |
148 listener.onDataAvailable(this, context, stream, 0, stream.available()); | 142 listener.onDataAvailable(this, context, stream, 0, stream.available()); |
149 } catch(e) {} | 143 } catch(e) {} |
150 try { | 144 try { |
151 listener.onStopRequest(this, context, Cr.NS_OK); | 145 listener.onStopRequest(this, context, Cr.NS_OK); |
152 } catch(e) {} | 146 } catch(e) {} |
153 }; | 147 }; |
154 | 148 |
155 let window = Utils.getRequestWindow(this); | 149 let window = Utils.getRequestWindow(this); |
156 addMessageListener(responseMessage, processResponse); | |
157 sendAsyncMessage("AdblockPlus:ElemHideHit", { | 150 sendAsyncMessage("AdblockPlus:ElemHideHit", { |
158 responseMessage, | |
159 key: this.key, | 151 key: this.key, |
160 frames: getFrames(window), | 152 frames: getFrames(window), |
161 isPrivate: isPrivate(window) | 153 isPrivate: isPrivate(window) |
162 }); | 154 }, processResponse); |
163 }, | 155 }, |
164 | 156 |
165 asyncOpen2: function(listener) | 157 asyncOpen2: function(listener) |
166 { | 158 { |
167 if (!this.loadInfo.triggeringPrincipal.equals(Utils.systemPrincipal)) | 159 if (!this.loadInfo.triggeringPrincipal.equals(Utils.systemPrincipal)) |
168 throw Cr.NS_ERROR_FAILURE; | 160 throw Cr.NS_ERROR_FAILURE; |
169 this.asyncOpen(listener, null); | 161 this.asyncOpen(listener, null); |
170 }, | 162 }, |
171 | 163 |
172 open: function() | 164 open: function() |
(...skipping 12 matching lines...) Expand all Loading... |
185 { | 177 { |
186 throw Cr.NS_ERROR_NOT_IMPLEMENTED; | 178 throw Cr.NS_ERROR_NOT_IMPLEMENTED; |
187 }, | 179 }, |
188 resume: function() | 180 resume: function() |
189 { | 181 { |
190 throw Cr.NS_ERROR_NOT_IMPLEMENTED; | 182 throw Cr.NS_ERROR_NOT_IMPLEMENTED; |
191 }, | 183 }, |
192 | 184 |
193 QueryInterface: XPCOMUtils.generateQI([Ci.nsIChannel, Ci.nsIRequest]) | 185 QueryInterface: XPCOMUtils.generateQI([Ci.nsIChannel, Ci.nsIRequest]) |
194 }; | 186 }; |
OLD | NEW |