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 = {}; |
@@ -33,33 +35,37 @@ |
// We don't know the opener tab |
return; |
} |
- tabsLoading[details.tabId] = openerUrl; |
+ tabsLoading[details.tabId] = {tabId: details.sourceTabId, url: openerUrl}; |
- checkPotentialPopup(details.tabId, details.url, openerUrl); |
+ checkPotentialPopup(details.tabId, details.url, details.sourceTabId, openerUrl); |
}); |
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.tabId, opener.url); |
if ("status" in changeInfo && changeInfo.status == "complete" && tab.url != "about:blank") |
delete tabsLoading[tabId]; |
}); |
} |
-function checkPotentialPopup(tabId, url, opener) |
+function checkPotentialPopup(tabId, url, openerTabId, openerUrl) |
{ |
var requestHost = extractHostFromURL(url); |
- var documentHost = extractHostFromURL(opener); |
+ var documentHost = extractHostFromURL(openerUrl); |
var thirdParty = isThirdParty(requestHost, documentHost); |
- var filter = defaultMatcher.matchesAny(url || "about:blank", "POPUP", documentHost, thirdParty); |
+ |
+ if (!url) |
+ url = "about:blank"; |
+ |
+ var filter = defaultMatcher.matchesAny(url, "POPUP", documentHost, thirdParty); |
if (filter instanceof BlockingFilter) |
chrome.tabs.remove(tabId); |
+ |
+ logRequest(openerTabId, url, "POPUP", documentHost, null, filter); |
} |