Left: | ||
Right: |
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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 Loading... | |
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 {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); | |
36 | 37 |
37 let {shouldAllowAsync} = require("child/contentPolicy"); | 38 let {shouldAllowAsync} = require("child/contentPolicy"); |
39 let {getFrames, isPrivate} = require("child/utils"); | |
40 let {RequestNotifier} = require("child/requestNotifier"); | |
38 let {port} = require("messaging"); | 41 let {port} = require("messaging"); |
39 let {Utils} = require("utils"); | 42 let {Utils} = require("utils"); |
40 | 43 |
41 // The allowXBL binding below won't have any effect on the element. For elements | 44 // The allowXBL binding below won't have any effect on the element. For elements |
42 // that should be hidden however we don't return any binding at all, this makes | 45 // that should be hidden however we don't return any binding at all, this makes |
43 // Gecko stop constructing the node - it cannot be shown. | 46 // Gecko stop constructing the node - it cannot be shown. |
44 const allowXBL = "<bindings xmlns='http://www.mozilla.org/xbl'><binding id='dumm y' bindToUntrustedContent='true'/></bindings>"; | 47 const allowXBL = "<bindings xmlns='http://www.mozilla.org/xbl'><binding id='dumm y' bindToUntrustedContent='true'/></bindings>"; |
45 const hideXBL = "<bindings xmlns='http://www.mozilla.org/xbl'/>"; | 48 const hideXBL = "<bindings xmlns='http://www.mozilla.org/xbl'/>"; |
46 | 49 |
47 const notImplemented = () => Cr.NS_ERROR_NOT_IMPLEMENTED; | 50 const notImplemented = () => Cr.NS_ERROR_NOT_IMPLEMENTED; |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 return new Promise((resolve, reject) => | 289 return new Promise((resolve, reject) => |
287 { | 290 { |
288 let window = Utils.getRequestWindow(this); | 291 let window = Utils.getRequestWindow(this); |
289 shouldAllowAsync(window, window.document, "ELEMHIDE", this.key, allow => | 292 shouldAllowAsync(window, window.document, "ELEMHIDE", this.key, allow => |
290 { | 293 { |
291 resolve(allow ? allowXBL : hideXBL); | 294 resolve(allow ? allowXBL : hideXBL); |
292 }); | 295 }); |
293 }); | 296 }); |
294 } | 297 } |
295 }; | 298 }; |
299 | |
300 let observer = { | |
301 QueryInterface: XPCOMUtils.generateQI([ | |
302 Ci.nsIObserver, Ci.nsISupportsWeakReference | |
303 ]), | |
304 | |
305 topic: "content-document-global-created", | |
306 styleURL: Utils.makeURI("about:abp-elemhide?css"), | |
307 sheet: null, | |
308 | |
309 init: function() | |
310 { | |
311 Services.obs.addObserver(this, this.topic, true); | |
312 onShutdown.add(() => | |
313 { | |
314 Services.obs.removeObserver(this, this.topic); | |
315 }); | |
316 | |
317 port.on("elemhideupdate", () => | |
318 { | |
319 this.sheet = null; | |
Thomas Greiner
2016/06/23 14:12:42
If I understand this correctly, we no longer apply
Wladimir Palant
2016/06/29 16:18:21
Yes, this is very much desirable and indeed listed
| |
320 }); | |
321 }, | |
322 | |
323 observe: function(subject, topic, data) | |
324 { | |
325 if (topic != this.topic) | |
326 return; | |
327 | |
328 port.emitWithResponse("elemhideEnabled", { | |
329 frames: getFrames(subject), | |
330 isPrivate: isPrivate(subject) | |
331 }).then(({ | |
332 enabled, contentType, docDomain, thirdParty, location, filter, | |
333 filterType | |
334 }) => | |
335 { | |
336 if (enabled) | |
337 { | |
338 if (!this.sheet) | |
339 { | |
340 this.sheet = Utils.styleService.preloadSheet(this.styleURL, | |
341 Ci.nsIStyleSheetService.USER_SHEET); | |
342 } | |
343 | |
344 let utils = subject.QueryInterface(Ci.nsIInterfaceRequestor) | |
345 .getInterface(Ci.nsIDOMWindowUtils); | |
346 utils.addSheet(this.sheet, Ci.nsIStyleSheetService.USER_SHEET); | |
347 } | |
348 else if (filter) | |
349 { | |
350 RequestNotifier.addNodeData(subject.document, subject.top, { | |
351 contentType, docDomain, thirdParty, location, filter, filterType | |
352 }); | |
353 } | |
354 }); | |
355 } | |
356 }; | |
357 observer.init(); | |
OLD | NEW |