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

Unified Diff: webrequest.js

Issue 6393086494113792: Issue 154 - Added devtools panel showing blocked and blockable items (Closed)
Patch Set: Addressed comments, fixed popup blocking detection, log whitelisted documents Created Feb. 2, 2016, 10:38 a.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
« lib/whitelisting.js ('K') | « popupBlocker.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrequest.js
===================================================================
--- a/webrequest.js
+++ b/webrequest.js
@@ -18,6 +18,7 @@
var FilterNotifier = require("filterNotifier").FilterNotifier;
var RegExpFilter = require("filterClasses").RegExpFilter;
var platform = require("info").platform;
+var devtools = require("devtools");
ext.webRequest.getIndistinguishableTypes().forEach(function(types)
{
@@ -46,30 +47,44 @@
}
});
-function onBeforeRequestAsync(url, type, page, filter)
+function onBeforeRequestAsync(page, url, type, docDomain,
+ thirdParty, key, specificOnly,
+ filter)
{
if (filter)
FilterNotifier.triggerListeners("filter.hitCount", filter, 0, 0, page);
+
+ if (devtools)
+ devtools.logRequest(
+ page, url, type, docDomain,
+ thirdParty, key, specificOnly,
+ filter
+ );
}
function onBeforeRequest(url, type, page, frame)
{
- if (isFrameWhitelisted(page, frame))
+ if (checkWhitelisted(page, frame))
return true;
+ var urlString = stringifyURL(url);
var docDomain = extractHostFromFrame(frame);
+ var thirdParty = isThirdParty(url, docDomain);
var key = getKey(page, frame);
- var specificOnly = isFrameWhitelisted(page, frame,
- RegExpFilter.typeMap.GENERICBLOCK);
- var filter = defaultMatcher.matchesAny(
- stringifyURL(url),
- RegExpFilter.typeMap[type], docDomain,
- isThirdParty(url, docDomain),
- key,
- specificOnly
+
+ var specificOnly = checkWhitelisted(
+ page, frame, RegExpFilter.typeMap.GENERICBLOCK
);
- setTimeout(onBeforeRequestAsync, 0, url, type, page, filter);
+ var filter = defaultMatcher.matchesAny(
+ urlString, RegExpFilter.typeMap[type],
+ docDomain, thirdParty, key, specificOnly
+ );
+
+ setTimeout(onBeforeRequestAsync, 0, page, urlString,
+ type, docDomain,
+ thirdParty, key,
+ specificOnly, filter);
return !(filter instanceof BlockingFilter);
}
« lib/whitelisting.js ('K') | « popupBlocker.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld