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-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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 return; | 252 return; |
253 } | 253 } |
254 } | 254 } |
255 | 255 |
256 updatePageFrameStructure(details.frameId, details.tabId, details.url, | 256 updatePageFrameStructure(details.frameId, details.tabId, details.url, |
257 details.parentFrameId); | 257 details.parentFrameId); |
258 }, | 258 }, |
259 {types: ["main_frame", "sub_frame"], urls: ["http://*/*", "https://*/*"]}, | 259 {types: ["main_frame", "sub_frame"], urls: ["http://*/*", "https://*/*"]}, |
260 ["responseHeaders"]); | 260 ["responseHeaders"]); |
261 | 261 |
262 browser.webNavigation.onBeforeNavigate.addListener(details => | |
263 { | |
264 // Requests can be made by about:blank frames before the frame's | |
265 // onCommitted event has fired, so we update the frame structure | |
266 // for those now. | |
267 if (details.url == "about:blank") | |
268 { | |
269 updatePageFrameStructure(details.frameId, details.tabId, details.url, | |
270 details.parentFrameId); | |
271 } | |
272 }); | |
273 | |
262 browser.webNavigation.onCommitted.addListener(details => | 274 browser.webNavigation.onCommitted.addListener(details => |
263 { | 275 { |
264 // We have to update the frame structure for documents that weren't | 276 // We have to update the frame structure for documents that weren't |
265 // loaded over HTTP (including documents cached by Service Workers), | 277 // loaded over HTTP (including documents cached by Service Workers), |
266 // when the navigation occurs. However, we must be careful to not | 278 // when the navigation occurs. However, we must be careful to not |
267 // update the state of the same document twice, otherewise the number | 279 // update the state of the same document twice, otherewise the number |
268 // of any ads blocked already and any recorded sitekey could get lost. | 280 // of any ads blocked already and any recorded sitekey could get lost. |
269 let frame = ext.getFrame(details.tabId, details.frameId); | 281 let frame = ext.getFrame(details.tabId, details.frameId); |
270 if (!frame || frame.url.href != details.url) | 282 if (!frame || frame.url.href != details.url) |
271 { | 283 { |
272 updatePageFrameStructure(details.frameId, details.tabId, details.url, | 284 updatePageFrameStructure(details.frameId, details.tabId, details.url, |
273 details.parentFrameId); | |
274 } | |
275 }); | |
276 | |
277 browser.webNavigation.onBeforeNavigate.addListener(details => | |
278 { | |
279 // We also need to update the frame structure for about:blank frames, in | |
280 // order to properly attribute the requests they make. | |
Sebastian Noack
2018/05/29 17:35:09
This comment is a bit vague. In my tests about:bla
kzar
2018/05/29 17:46:18
Done.
| |
281 let {url} = details; | |
Sebastian Noack
2018/05/29 17:35:08
Nit: I don't think this temporary variable is wort
kzar
2018/05/29 17:46:18
Done.
| |
282 if (url == "about:blank") | |
283 { | |
284 updatePageFrameStructure(details.frameId, details.tabId, url, | |
285 details.parentFrameId); | 285 details.parentFrameId); |
286 } | 286 } |
287 }); | 287 }); |
288 | 288 |
289 function forgetTab(tabId) | 289 function forgetTab(tabId) |
290 { | 290 { |
291 ext.pages.onRemoved._dispatch(tabId); | 291 ext.pages.onRemoved._dispatch(tabId); |
292 | 292 |
293 removeFromAllPageMaps(tabId); | 293 removeFromAllPageMaps(tabId); |
294 framesOfTabs.delete(tabId); | 294 framesOfTabs.delete(tabId); |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
582 return frames.get(0) || null; | 582 return frames.get(0) || null; |
583 } | 583 } |
584 }; | 584 }; |
585 } | 585 } |
586 | 586 |
587 return ext.onMessage._dispatch( | 587 return ext.onMessage._dispatch( |
588 message, sender, sendResponse | 588 message, sender, sendResponse |
589 ).includes(true); | 589 ).includes(true); |
590 }); | 590 }); |
591 } | 591 } |
LEFT | RIGHT |