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-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 13 matching lines...) Expand all Loading... |
24 var sourcePage = new ext.Page({id: details.sourceTabId}); | 24 var sourcePage = new ext.Page({id: details.sourceTabId}); |
25 var sourceFrame = ext.getFrame(details.sourceTabId, details.sourceFrameId); | 25 var sourceFrame = ext.getFrame(details.sourceTabId, details.sourceFrameId); |
26 | 26 |
27 if (!sourceFrame || isFrameWhitelisted(sourcePage, sourceFrame)) | 27 if (!sourceFrame || isFrameWhitelisted(sourcePage, sourceFrame)) |
28 return; | 28 return; |
29 | 29 |
30 var documentHost = extractHostFromFrame(sourceFrame); | 30 var documentHost = extractHostFromFrame(sourceFrame); |
31 if (!documentHost) | 31 if (!documentHost) |
32 return; | 32 return; |
33 | 33 |
34 tabsLoading[details.tabId] = documentHost; | 34 var specificOnly = isFrameWhitelisted(sourcePage, sourceFrame, |
35 checkPotentialPopup(details.tabId, details.url, documentHost); | 35 RegExpFilter.typeMap.GENERICBLOCK); |
| 36 |
| 37 tabsLoading[details.tabId] = { |
| 38 documentHost: documentHost, |
| 39 specificOnly: specificOnly |
| 40 }; |
| 41 checkPotentialPopup(details.tabId, details.url, documentHost, specificOnly); |
36 }); | 42 }); |
37 | 43 |
38 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) | 44 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) |
39 { | 45 { |
40 if (!(tabId in tabsLoading)) | 46 if (!(tabId in tabsLoading)) |
41 { | 47 { |
42 // Not a pop-up we've previously seen | 48 // Not a pop-up we've previously seen |
43 return; | 49 return; |
44 } | 50 } |
45 | 51 |
46 if ("url" in changeInfo) | 52 if ("url" in changeInfo) |
47 checkPotentialPopup(tabId, tab.url, tabsLoading[tabId]); | 53 { |
| 54 var source = tabsLoading[tabId]; |
| 55 checkPotentialPopup(tabId, tab.url, source.documentHost, |
| 56 source.specificOnly); |
| 57 } |
48 | 58 |
49 if ("status" in changeInfo && changeInfo.status == "complete" && tab.url !=
"about:blank") | 59 if ("status" in changeInfo && changeInfo.status == "complete" && tab.url !=
"about:blank") |
50 delete tabsLoading[tabId]; | 60 delete tabsLoading[tabId]; |
51 }); | 61 }); |
52 } | 62 } |
53 | 63 |
54 function checkPotentialPopup(tabId, url, documentHost) | 64 function checkPotentialPopup(tabId, url, documentHost, specificOnly) |
55 { | 65 { |
56 url = new URL(url || "about:blank"); | 66 url = new URL(url || "about:blank"); |
57 | 67 |
58 var filter = defaultMatcher.matchesAny( | 68 var filter = defaultMatcher.matchesAny( |
59 stringifyURL(url), RegExpFilter.typeMap.POPUP, | 69 stringifyURL(url), RegExpFilter.typeMap.POPUP, |
60 documentHost, isThirdParty(url, documentHost) | 70 documentHost, isThirdParty(url, documentHost), |
| 71 null, specificOnly |
61 ); | 72 ); |
62 | 73 |
63 if (filter instanceof BlockingFilter) | 74 if (filter instanceof BlockingFilter) |
64 chrome.tabs.remove(tabId); | 75 chrome.tabs.remove(tabId); |
65 } | 76 } |
OLD | NEW |