LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 12 matching lines...) Expand all Loading... |
23 Cu.import("resource://gre/modules/Services.jsm"); | 23 Cu.import("resource://gre/modules/Services.jsm"); |
24 | 24 |
25 let {TimeLine} = require("timeline"); | 25 let {TimeLine} = require("timeline"); |
26 let {Utils} = require("utils"); | 26 let {Utils} = require("utils"); |
27 let {Prefs} = require("prefs"); | 27 let {Prefs} = require("prefs"); |
28 let {FilterStorage} = require("filterStorage"); | 28 let {FilterStorage} = require("filterStorage"); |
29 let {BlockingFilter, WhitelistFilter} = require("filterClasses"); | 29 let {BlockingFilter, WhitelistFilter} = require("filterClasses"); |
30 let {defaultMatcher} = require("matcher"); | 30 let {defaultMatcher} = require("matcher"); |
31 let {objectMouseEventHander} = require("objectTabs"); | 31 let {objectMouseEventHander} = require("objectTabs"); |
32 let {RequestNotifier} = require("requestNotifier"); | 32 let {RequestNotifier} = require("requestNotifier"); |
| 33 let {ElemHide} = require("elemHide"); |
33 | 34 |
34 /** | 35 /** |
35 * List of explicitly supported content types | 36 * List of explicitly supported content types |
36 * @type Array of String | 37 * @type Array of String |
37 */ | 38 */ |
38 let contentTypes = ["OTHER", "SCRIPT", "IMAGE", "STYLESHEET", "OBJECT", "SUBDOCU
MENT", "DOCUMENT", "XMLHTTPREQUEST", "OBJECT_SUBREQUEST", "FONT", "MEDIA"]; | 39 let contentTypes = ["OTHER", "SCRIPT", "IMAGE", "STYLESHEET", "OBJECT", "SUBDOCU
MENT", "DOCUMENT", "XMLHTTPREQUEST", "OBJECT_SUBREQUEST", "FONT", "MEDIA"]; |
39 | 40 |
40 /** | 41 /** |
41 * List of content types that aren't associated with a visual document area | 42 * List of content types that aren't associated with a visual document area |
42 * @type Array of String | 43 * @type Array of String |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 Utils.styleService.loadAndRegisterSheet(collapseStyle, Ci.nsIStyleSheetServi
ce.USER_SHEET); | 136 Utils.styleService.loadAndRegisterSheet(collapseStyle, Ci.nsIStyleSheetServi
ce.USER_SHEET); |
136 onShutdown.add(function() | 137 onShutdown.add(function() |
137 { | 138 { |
138 Utils.styleService.unregisterSheet(collapseStyle, Ci.nsIStyleSheetService.
USER_SHEET); | 139 Utils.styleService.unregisterSheet(collapseStyle, Ci.nsIStyleSheetService.
USER_SHEET); |
139 }) | 140 }) |
140 TimeLine.log("done registering stylesheet"); | 141 TimeLine.log("done registering stylesheet"); |
141 | 142 |
142 TimeLine.leave("Done initializing content policy"); | 143 TimeLine.leave("Done initializing content policy"); |
143 }, | 144 }, |
144 | 145 |
145 processWindow: function(wnd) | 146 /** |
| 147 * Checks whether a window or its parent is whitelisted or has a valid site-ke
y. |
| 148 * @param wnd {nsIDOMWindow} |
| 149 */ |
| 150 shouldNeverBlockWindow: function(wnd) |
146 { | 151 { |
147 let uri = wnd.document.documentURIObject; | 152 let uri = wnd.document.documentURIObject; |
148 if (!uri) | 153 if (!uri) |
149 return true; | 154 return true; |
150 | 155 |
151 if (!Policy.isBlockableScheme(uri.scheme)) | 156 if (!Policy.isBlockableScheme(uri.scheme)) |
152 return true; | 157 return true; |
153 | 158 |
154 let topWnd = wnd.top; | 159 let topWnd = wnd.top; |
155 if (!topWnd || !topWnd.location || !topWnd.location.href) | 160 if (!topWnd || !topWnd.location || !topWnd.location.href) |
(...skipping 18 matching lines...) Expand all Loading... |
174 if (keyMatch && Utils.crypto) | 179 if (keyMatch && Utils.crypto) |
175 { | 180 { |
176 // Website specifies a key that we know but is the signature valid? | 181 // Website specifies a key that we know but is the signature valid? |
177 let uri = Services.io.newURI(testWndLocation, null, null); | 182 let uri = Services.io.newURI(testWndLocation, null, null); |
178 let params = [ | 183 let params = [ |
179 uri.path.replace(/#.*/, ""), // REQUEST_URI | 184 uri.path.replace(/#.*/, ""), // REQUEST_URI |
180 uri.asciiHost, // HTTP_HOST | 185 uri.asciiHost, // HTTP_HOST |
181 Utils.httpProtocol.userAgent // HTTP_USER_AGENT | 186 Utils.httpProtocol.userAgent // HTTP_USER_AGENT |
182 ]; | 187 ]; |
183 if (Utils.verifySignature(key, signature, params.join("\0"))) | 188 if (Utils.verifySignature(key, signature, params.join("\0"))) |
184 match = keyMatch; // XXX what is this? | 189 match = keyMatch; |
185 } | 190 } |
186 } | 191 } |
187 } | 192 } |
188 | 193 |
189 if (match instanceof WhitelistFilter) | 194 if (match instanceof WhitelistFilter) |
190 { | 195 { |
191 FilterStorage.increaseHitCount(match, wnd); | 196 FilterStorage.increaseHitCount(match, wnd); |
192 RequestNotifier.addNodeData(testWnd.document, topWnd, Policy.type.DOCUME
NT, getHostname(parentWndLocation), false, testWndLocation, match); | 197 RequestNotifier.addNodeData(testWnd.document, topWnd, Policy.type.DOCUME
NT, getHostname(parentWndLocation), false, testWndLocation, match); |
193 return true; | 198 return true; |
194 } | 199 } |
(...skipping 11 matching lines...) Expand all Loading... |
206 * Checks whether a node should be blocked, hides it if necessary | 211 * Checks whether a node should be blocked, hides it if necessary |
207 * @param wnd {nsIDOMWindow} | 212 * @param wnd {nsIDOMWindow} |
208 * @param node {nsIDOMElement} | 213 * @param node {nsIDOMElement} |
209 * @param contentType {String} | 214 * @param contentType {String} |
210 * @param location {nsIURI} | 215 * @param location {nsIURI} |
211 * @param collapse {Boolean} true to force hiding of the node | 216 * @param collapse {Boolean} true to force hiding of the node |
212 * @return {Boolean} false if the node should be blocked | 217 * @return {Boolean} false if the node should be blocked |
213 */ | 218 */ |
214 processNode: function(wnd, node, contentType, location, collapse) | 219 processNode: function(wnd, node, contentType, location, collapse) |
215 { | 220 { |
216 if (Policy.processWindow(wnd)) | 221 if (Policy.shouldNeverBlockWindow(wnd)) |
217 return true; | 222 return true; |
218 | 223 |
219 let topWnd = wnd.top; | 224 let topWnd = wnd.top; |
220 let originWindow = Utils.getOriginWindow(wnd); | 225 let originWindow = Utils.getOriginWindow(wnd); |
221 let wndLocation = originWindow.location.href; | 226 let wndLocation = originWindow.location.href; |
222 let docDomain = getHostname(wndLocation); | 227 let docDomain = getHostname(wndLocation); |
223 | 228 |
224 // Data loaded by plugins should be attached to the document | 229 // Data loaded by plugins should be attached to the document |
225 if (contentType == Policy.type.OBJECT_SUBREQUEST && node instanceof Ci.nsIDO
MElement) | 230 if (contentType == Policy.type.OBJECT_SUBREQUEST && node instanceof Ci.nsIDO
MElement) |
226 node = node.ownerDocument; | 231 node = node.ownerDocument; |
(...skipping 27 matching lines...) Expand all Loading... |
254 testWnd = testWnd.parent; | 259 testWnd = testWnd.parent; |
255 } | 260 } |
256 | 261 |
257 match = location; | 262 match = location; |
258 locationText = match.text.replace(/^.*?#/, '#'); | 263 locationText = match.text.replace(/^.*?#/, '#'); |
259 location = locationText; | 264 location = locationText; |
260 | 265 |
261 if (!match.isActiveOnDomain(docDomain)) | 266 if (!match.isActiveOnDomain(docDomain)) |
262 return true; | 267 return true; |
263 | 268 |
264 let {ElemHide} = require("elemHide"); | |
265 let exception = ElemHide.getException(match, docDomain); | 269 let exception = ElemHide.getException(match, docDomain); |
266 if (exception) | 270 if (exception) |
267 { | 271 { |
268 FilterStorage.increaseHitCount(exception, wnd); | 272 FilterStorage.increaseHitCount(exception, wnd); |
269 RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, thirdP
arty, locationText, exception); | 273 RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, thirdP
arty, locationText, exception); |
270 return true; | 274 return true; |
271 } | 275 } |
272 } | 276 } |
273 | 277 |
274 let thirdParty = (contentType == Policy.type.ELEMHIDE ? false : isThirdParty
(location, docDomain)); | 278 let thirdParty = (contentType == Policy.type.ELEMHIDE ? false : isThirdParty
(location, docDomain)); |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 if (!wnd || wnd.closed) | 784 if (!wnd || wnd.closed) |
781 return; | 785 return; |
782 | 786 |
783 if (entry.type == Policy.type.OBJECT) | 787 if (entry.type == Policy.type.OBJECT) |
784 { | 788 { |
785 node.removeEventListener("mouseover", objectMouseEventHander, true); | 789 node.removeEventListener("mouseover", objectMouseEventHander, true); |
786 node.removeEventListener("mouseout", objectMouseEventHander, true); | 790 node.removeEventListener("mouseout", objectMouseEventHander, true); |
787 } | 791 } |
788 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true)
; | 792 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true)
; |
789 } | 793 } |
LEFT | RIGHT |