Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 init: function() | 69 init: function() |
70 { | 70 { |
71 // whitelisted URL schemes | 71 // whitelisted URL schemes |
72 for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" ")) | 72 for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" ")) |
73 this.whitelistSchemes.add(scheme); | 73 this.whitelistSchemes.add(scheme); |
74 | 74 |
75 let messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"] | 75 let messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"] |
76 .getService(Ci.nsIMessageListenerManager) | 76 .getService(Ci.nsIMessageListenerManager) |
77 .QueryInterface(Ci.nsIMessageBroadcaster); | 77 .QueryInterface(Ci.nsIMessageBroadcaster); |
78 let handler = (message => this.shouldAllow(message.data)); | 78 let handler = (message => this.shouldAllow(message.data)); |
79 messageManager.addMessageListener("AdblockPlus:ShouldAllow", handler); | 79 messageManager.addMessageListener("AdblockPlus:ShouldAllow", handler); |
tschuster
2015/11/12 14:04:17
nit: The surrounding brackets are unnecessary.
Wladimir Palant
2015/11/12 15:16:31
This code is going to be replaced in https://coder
| |
80 onShutdown.add(() => messageManager.removeMessageListener("AdblockPlus:Shoul dAllow", handler)); | 80 onShutdown.add(() => messageManager.removeMessageListener("AdblockPlus:Shoul dAllow", handler)); |
81 | 81 |
82 // Generate class identifier used to collapse nodes and register | 82 // Generate class identifier used to collapse nodes and register |
83 // corresponding stylesheet. | 83 // corresponding stylesheet. |
84 let collapsedClass = ""; | 84 let collapsedClass = ""; |
85 let offset = "a".charCodeAt(0); | 85 let offset = "a".charCodeAt(0); |
86 for (let i = 0; i < 20; i++) | 86 for (let i = 0; i < 20; i++) |
87 collapsedClass += String.fromCharCode(offset + Math.random() * 26); | 87 collapsedClass += String.fromCharCode(offset + Math.random() * 26); |
88 | 88 |
89 let handler2 = () => collapsedClass; | 89 let handler2 = () => collapsedClass; |
(...skipping 10 matching lines...) Expand all Loading... | |
100 }); | 100 }); |
101 }, | 101 }, |
102 | 102 |
103 /** | 103 /** |
104 * Checks whether a node should be blocked, hides it if necessary | 104 * Checks whether a node should be blocked, hides it if necessary |
105 * @param {Object} data request data | 105 * @param {Object} data request data |
106 * @param {String} data.contentType | 106 * @param {String} data.contentType |
107 * @param {String} data.location | 107 * @param {String} data.location |
108 * @param {Object[]} data.frames | 108 * @param {Object[]} data.frames |
109 * @param {Boolean} data.isPrivate true if the request belongs to a private b rowsing window | 109 * @param {Boolean} data.isPrivate true if the request belongs to a private b rowsing window |
110 * @return {Object} An object containing properties block, collapse and hits | 110 * @return {Object} An object containing properties allow, collapse and hits |
tschuster
2015/11/12 14:04:17
I think s/block/allow
Wladimir Palant
2015/11/12 15:16:31
Right, fixed.
| |
111 * indicating how this request should be handled. | 111 * indicating how this request should be handled. |
112 */ | 112 */ |
113 shouldAllow: function({contentType, location, frames, isPrivate}) | 113 shouldAllow: function({contentType, location, frames, isPrivate}) |
114 { | 114 { |
115 let hits = []; | 115 let hits = []; |
116 | 116 |
117 function addHit(frameIndex, contentType, docDomain, thirdParty, location, fi lter) | 117 function addHit(frameIndex, contentType, docDomain, thirdParty, location, fi lter) |
118 { | 118 { |
119 if (filter && !isPrivate) | 119 if (filter && !isPrivate) |
120 FilterStorage.increaseHitCount(filter); | 120 FilterStorage.increaseHitCount(filter); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
407 if (!wnd || wnd.closed) | 407 if (!wnd || wnd.closed) |
408 return; | 408 return; |
409 | 409 |
410 if (entry.type == "OBJECT") | 410 if (entry.type == "OBJECT") |
411 { | 411 { |
412 node.removeEventListener("mouseover", objectMouseEventHander, true); | 412 node.removeEventListener("mouseover", objectMouseEventHander, true); |
413 node.removeEventListener("mouseout", objectMouseEventHander, true); | 413 node.removeEventListener("mouseout", objectMouseEventHander, true); |
414 } | 414 } |
415 Policy.processNode(wnd, node, entry.type, entry.location, true); | 415 Policy.processNode(wnd, node, entry.type, entry.location, true); |
416 } | 416 } |
LEFT | RIGHT |