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

Unified Diff: popupBlocker.js

Issue 5564089086509056: Issue 1801 - Use URL objects to process URLs in the background page (Closed)
Patch Set: Rebased and addressed comments Created Feb. 11, 2015, 5:06 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 | « popup.js ('k') | qunit/index.html » ('j') | 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
@@ -27,15 +27,12 @@
if (!sourceFrame || isFrameWhitelisted(sourcePage, sourceFrame))
return;
- var openerUrl = sourceFrame.url;
- if (!openerUrl)
- {
- // We don't know the opener tab
+ var documentHost = extractHostFromFrame(sourceFrame);
+ if (!documentHost)
return;
- }
- tabsLoading[details.tabId] = openerUrl;
- checkPotentialPopup(details.tabId, details.url, openerUrl);
+ tabsLoading[details.tabId] = documentHost;
+ checkPotentialPopup(details.tabId, details.url, documentHost);
});
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab)
@@ -54,12 +51,15 @@
});
}
-function checkPotentialPopup(tabId, url, opener)
+function checkPotentialPopup(tabId, url, documentHost)
{
- var requestHost = extractHostFromURL(url);
- var documentHost = extractHostFromURL(opener);
- var thirdParty = isThirdParty(requestHost, documentHost);
- var filter = defaultMatcher.matchesAny(url || "about:blank", "POPUP", documentHost, thirdParty);
+ url = new URL(url || "about:blank");
+
+ var filter = defaultMatcher.matchesAny(
+ stringifyURL(url), "POPUP",
+ documentHost, isThirdParty(url, documentHost)
+ );
+
if (filter instanceof BlockingFilter)
chrome.tabs.remove(tabId);
}
« no previous file with comments | « popup.js ('k') | qunit/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld