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

Unified Diff: popupBlocker.js

Issue 6393086494113792: Issue 154 - Added devtools panel showing blocked and blockable items (Closed)
Patch Set: Added some newlines for better legibility Created Jan. 5, 2015, 7:35 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 | « metadata.common ('k') | webrequest.js » ('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
@@ -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);
}
« no previous file with comments | « metadata.common ('k') | webrequest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld