Index: popupBlocker.js |
=================================================================== |
--- a/popupBlocker.js |
+++ b/popupBlocker.js |
@@ -15,6 +15,8 @@ |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
+var logRequest = require("devtools").logRequest; |
+ |
if (require("info").platform == "chromium") |
{ |
var tabsLoading = {}; |
@@ -31,35 +33,34 @@ |
if (!documentHost) |
return; |
- tabsLoading[details.tabId] = documentHost; |
- checkPotentialPopup(details.tabId, details.url, documentHost); |
+ tabsLoading[details.tabId] = {page: sourcePage, host: documentHost}; |
+ checkPotentialPopup(details.tabId, details.url, sourcePage, documentHost); |
}); |
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) |
{ |
- if (!(tabId in tabsLoading)) |
- { |
- // Not a pop-up we've previously seen |
+ var opener = tabsLoading[tabId]; |
+ if (!opener) |
return; |
- } |
if ("url" in changeInfo) |
- checkPotentialPopup(tabId, tab.url, tabsLoading[tabId]); |
+ checkPotentialPopup(tabId, tab.url, opener.page, opener.host); |
if ("status" in changeInfo && changeInfo.status == "complete" && tab.url != "about:blank") |
delete tabsLoading[tabId]; |
}); |
} |
-function checkPotentialPopup(tabId, url, documentHost) |
+function checkPotentialPopup(tabId, url, sourcePage, documentHost) |
{ |
url = new URL(url || "about:blank"); |
- var filter = defaultMatcher.matchesAny( |
- stringifyURL(url), "POPUP", |
- documentHost, isThirdParty(url, documentHost) |
- ); |
+ var urlString = stringifyURL(url); |
+ var thirdParty = isThirdParty(url, documentHost); |
+ var filter = defaultMatcher.matchesAny(urlString, "POPUP", documentHost, thirdParty); |
if (filter instanceof BlockingFilter) |
chrome.tabs.remove(tabId); |
+ |
+ logRequest(sourcePage, urlString, "POPUP", documentHost, thirdParty, null, filter); |
} |