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

Unified Diff: lib/csp.js

Issue 29705719: Issue 6402 - Split filter hit / request logging out into own API (Closed)
Patch Set: Addressed Manish's feedback Created May 1, 2018, 10:49 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
« no previous file with comments | « include.preload.js ('k') | lib/cssInjection.js » ('j') | lib/devtools.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/csp.js
diff --git a/lib/csp.js b/lib/csp.js
index 1e9a3670ee8dddb31fea270bb105615a7b881bc4..698d973fc377b6498daee97741c7dae9a706976b 100644
--- a/lib/csp.js
+++ b/lib/csp.js
@@ -24,7 +24,7 @@ const {extractHostFromFrame, getDecodedHostname,
isThirdParty, stringifyURL} = require("./url");
const {checkWhitelisted} = require("./whitelisting");
const {FilterNotifier} = require("filterNotifier");
-const devtools = require("./devtools");
+const {logRequest} = require("./hitLogger");
const {typeMap} = RegExpFilter;
@@ -33,10 +33,10 @@ browser.webRequest.onHeadersReceived.addListener(details =>
let url = new URL(details.url);
let urlString = stringifyURL(url);
let parentFrame = ext.getFrame(details.tabId, details.parentFrameId);
- let hostname = extractHostFromFrame(parentFrame) || getDecodedHostname(url);
- let thirdParty = isThirdParty(url, hostname);
+ let docDomain = extractHostFromFrame(parentFrame) || getDecodedHostname(url);
kzar 2018/05/01 10:53:09 I renamed this in order to use the Object shorthan
Manish Jethani 2018/05/02 13:25:14 Acknowledged. Maybe rename urlString to url and a
kzar 2018/05/02 15:41:50 I think I prefer it like it is, I find the name ur
Sebastian Noack 2018/05/02 16:11:32 Agreed with kzar (also in favor to avoid wrapping
+ let thirdParty = isThirdParty(url, docDomain);
- let cspMatch = defaultMatcher.matchesAny(urlString, typeMap.CSP, hostname,
+ let cspMatch = defaultMatcher.matchesAny(urlString, typeMap.CSP, docDomain,
thirdParty, null, false);
if (cspMatch)
{
@@ -54,14 +54,17 @@ browser.webRequest.onHeadersReceived.addListener(details =>
typeMap.GENERICBLOCK);
if (specificOnly)
{
- cspMatch = defaultMatcher.matchesAny(urlString, typeMap.CSP, hostname,
+ cspMatch = defaultMatcher.matchesAny(urlString, typeMap.CSP, docDomain,
thirdParty, null, specificOnly);
if (!cspMatch)
return;
}
- devtools.logRequest([details.tabId], urlString, "CSP", hostname,
- thirdParty, null, specificOnly, cspMatch);
+ logRequest(
+ [details.tabId],
+ {url: urlString, type: "CSP", docDomain, thirdParty, specificOnly},
+ cspMatch
+ );
FilterNotifier.emit("filter.hitCount", cspMatch, 0, 0, [details.tabId]);
if (cspMatch instanceof WhitelistFilter)
« no previous file with comments | « include.preload.js ('k') | lib/cssInjection.js » ('j') | lib/devtools.js » ('J')

Powered by Google App Engine
This is Rietveld