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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 let page = new ext.Page({id: details.tabId, url: details.url}); | 42 let page = new ext.Page({id: details.tabId, url: details.url}); |
43 let frame = ext.getFrame(details.tabId, details.frameId); | 43 let frame = ext.getFrame(details.tabId, details.frameId); |
44 | 44 |
45 if (checkWhitelisted(page, frame)) | 45 if (checkWhitelisted(page, frame)) |
46 return; | 46 return; |
47 | 47 |
48 // To avoid an extra matchesAny for the common case we assumed no | 48 // To avoid an extra matchesAny for the common case we assumed no |
49 // $genericblock filters applied when searching for a matching $csp filter. | 49 // $genericblock filters applied when searching for a matching $csp filter. |
50 // We must now pay the price by first checking for a $genericblock filter | 50 // We must now pay the price by first checking for a $genericblock filter |
51 // and if necessary that our $csp filter is specific. | 51 // and if necessary that our $csp filter is specific. |
52 let specificOnly = !!checkWhitelisted(page, frame, typeMap.GENERICBLOCK); | 52 let specificOnly = !!checkWhitelisted(page, frame, null, |
| 53 typeMap.GENERICBLOCK); |
53 if (specificOnly) | 54 if (specificOnly) |
54 { | 55 { |
55 cspMatch = defaultMatcher.matchesAny(urlString, typeMap.CSP, hostname, | 56 cspMatch = defaultMatcher.matchesAny(urlString, typeMap.CSP, hostname, |
56 thirdParty, null, specificOnly); | 57 thirdParty, null, specificOnly); |
57 if (!cspMatch) | 58 if (!cspMatch) |
58 return; | 59 return; |
59 } | 60 } |
60 | 61 |
61 devtools.logRequest([details.tabId], urlString, "CSP", hostname, | 62 devtools.logRequest([details.tabId], urlString, "CSP", hostname, |
62 thirdParty, null, specificOnly, cspMatch); | 63 thirdParty, null, specificOnly, cspMatch); |
63 FilterNotifier.emit("filter.hitCount", cspMatch, 0, 0, [details.tabId]); | 64 FilterNotifier.emit("filter.hitCount", cspMatch, 0, 0, [details.tabId]); |
64 | 65 |
65 if (cspMatch instanceof WhitelistFilter) | 66 if (cspMatch instanceof WhitelistFilter) |
66 return; | 67 return; |
67 | 68 |
68 details.responseHeaders.push({ | 69 details.responseHeaders.push({ |
69 name: "Content-Security-Policy", | 70 name: "Content-Security-Policy", |
70 value: cspMatch.csp | 71 value: cspMatch.csp |
71 }); | 72 }); |
72 | 73 |
73 return {responseHeaders: details.responseHeaders}; | 74 return {responseHeaders: details.responseHeaders}; |
74 } | 75 } |
75 }, { | 76 }, { |
76 urls: ["http://*/*", "https://*/*"], | 77 urls: ["http://*/*", "https://*/*"], |
77 types: ["main_frame", "sub_frame"] | 78 types: ["main_frame", "sub_frame"] |
78 }, ["blocking", "responseHeaders"]); | 79 }, ["blocking", "responseHeaders"]); |
OLD | NEW |