Index: popupBlocker.js |
=================================================================== |
--- a/popupBlocker.js |
+++ b/popupBlocker.js |
@@ -17,46 +17,45 @@ |
if (require("info").platform == "chromium" && "webNavigation" in chrome) |
{ |
- var tabsLoading = {}; |
+ var tabsLoading = new TabMap(); |
- chrome.webNavigation.onCreatedNavigationTarget.addListener(function(details) |
+ ext.webNavigation.onCreatedNavigationTarget.addListener(function(details) |
{ |
- if (isFrameWhitelisted(details.sourceTabId, details.sourceFrameId)) |
+ if (isFrameWhitelisted(details.sourceTab, details.sourceFrameId)) |
return; |
- var openerUrl = getFrameUrl(details.sourceTabId, details.sourceFrameId); |
+ var openerUrl = getFrameUrl(details.sourceTab, details.sourceFrameId); |
if (!openerUrl) |
{ |
// We don't know the opener tab |
return; |
} |
- tabsLoading[details.tabId] = openerUrl; |
+ tabsLoading.set(details.tab, openerUrl); |
- checkPotentialPopup(details.tabId, details.url, openerUrl); |
+ checkPotentialPopup(details.tab, openerUrl); |
}); |
- chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) |
+ ext.tabs.onCompleted.addListener(function(tab) |
{ |
- if (!(tabId in tabsLoading)) |
+ if (!tabsLoading.has(tab)) |
{ |
// Not a pop-up we've previously seen |
return; |
} |
- if ("url" in changeInfo) |
- checkPotentialPopup(tabId, tab.url, tabsLoading[tabId]); |
+ checkPotentialPopup(tab, tabsLoading.get(tab)); |
- if ("status" in changeInfo && changeInfo.status == "complete" && tab.url != "about:blank") |
- delete tabsLoading[tabId]; |
+ if (tab.url != "about:blank") |
+ tabsLoading.delete(tab); |
}); |
} |
-function checkPotentialPopup(tabId, url, opener) |
+function checkPotentialPopup(tab, openerUrl) |
{ |
- var requestHost = extractHostFromURL(url); |
- var documentHost = extractHostFromURL(opener); |
+ var requestHost = extractHostFromURL(tab.url); |
+ var documentHost = extractHostFromURL(openerUrl); |
var thirdParty = isThirdParty(requestHost, documentHost); |
- var filter = defaultMatcher.matchesAny(url || "about:blank", "POPUP", documentHost, thirdParty); |
+ var filter = defaultMatcher.matchesAny(tab.url || "about:blank", "POPUP", documentHost, thirdParty); |
if (filter instanceof BlockingFilter) |
- chrome.tabs.remove(tabId); |
+ tab.close(); |
} |