Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: popupBlocker.js

Issue 5133183649579008: Fixed: Popup blocking functionality broken (Closed)
Patch Set: Created Dec. 20, 2013, 3:08 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/background.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « chrome/background.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld