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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2017 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 /** @module whitelisting */ | 18 /** @module whitelisting */ |
19 | 19 |
20 "use strict"; | 20 "use strict"; |
21 | 21 |
22 const {defaultMatcher} = require("matcher"); | 22 const {defaultMatcher} = require("matcher"); |
23 const {RegExpFilter} = require("filterClasses"); | 23 const {RegExpFilter} = require("filterClasses"); |
24 const {DownloadableSubscription} = require("subscriptionClasses"); | |
25 const {FilterNotifier} = require("filterNotifier"); | 24 const {FilterNotifier} = require("filterNotifier"); |
26 const {stringifyURL, getDecodedHostname, | 25 const {stringifyURL, getDecodedHostname, |
27 extractHostFromFrame, isThirdParty} = require("url"); | 26 extractHostFromFrame, isThirdParty} = require("url"); |
28 const {port} = require("messaging"); | 27 const {port} = require("messaging"); |
29 const devtools = require("devtools"); | 28 const devtools = require("devtools"); |
30 const {verifySignature} = require("rsa"); | 29 const {verifySignature} = require("rsa"); |
31 | 30 |
32 let sitekeys = new ext.PageMap(); | 31 let sitekeys = new ext.PageMap(); |
33 | 32 |
34 function match(page, url, typeMask, docDomain, sitekey) | 33 function match(page, url, typeMask, docDomain, sitekey) |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 let page = new ext.Page({id: details.tabId}); | 176 let page = new ext.Page({id: details.tabId}); |
178 | 177 |
179 for (let header of details.responseHeaders) | 178 for (let header of details.responseHeaders) |
180 { | 179 { |
181 if (header.name.toLowerCase() == "x-adblock-key" && header.value) | 180 if (header.name.toLowerCase() == "x-adblock-key" && header.value) |
182 { | 181 { |
183 let url = new URL(details.url); | 182 let url = new URL(details.url); |
184 let key = checkKey(header.value, url); | 183 let key = checkKey(header.value, url); |
185 if (key) | 184 if (key) |
186 { | 185 { |
187 // For pre-rendered tabs we don't know for sure the navigation is going | |
188 // to happen until the onCommitted event fires. Unfortunately if we want | |
189 // sitekey whitelisting to work for requests made before onCommitted has | |
190 // been fired we must update the page structure now anyway. | |
191 ext._updatePageFrameStructure(details.frameId, details.tabId, | |
192 details.url, true); | |
193 recordKey(key, page, url); | 186 recordKey(key, page, url); |
194 break; | 187 break; |
195 } | 188 } |
196 } | 189 } |
197 } | 190 } |
198 } | 191 } |
199 | 192 |
200 if (typeof chrome == "object") | 193 if (typeof chrome == "object") |
201 { | 194 { |
202 chrome.webRequest.onHeadersReceived.addListener( | 195 chrome.webRequest.onHeadersReceived.addListener( |
203 onHeadersReceived, | 196 onHeadersReceived, |
204 { | 197 { |
205 urls: ["http://*/*", "https://*/*"], | 198 urls: ["http://*/*", "https://*/*"], |
206 types: ["main_frame", "sub_frame"] | 199 types: ["main_frame", "sub_frame"] |
207 }, | 200 }, |
208 ["responseHeaders"] | 201 ["responseHeaders"] |
209 ); | 202 ); |
210 } | 203 } |
LEFT | RIGHT |