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

Unified Diff: lib/requestBlocker.js

Issue 29418679: Issue 5042 - Adds handling for requests which are not associated with browser tab (Closed)
Patch Set: address errors, style, new map object for panels Created April 28, 2017, 12:28 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 | « lib/devtools.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/requestBlocker.js
===================================================================
--- a/lib/requestBlocker.js
+++ b/lib/requestBlocker.js
@@ -20,17 +20,18 @@
"use strict";
const {Filter, RegExpFilter, BlockingFilter} = require("filterClasses");
const {Subscription} = require("subscriptionClasses");
const {defaultMatcher} = require("matcher");
const {FilterNotifier} = require("filterNotifier");
const {Prefs} = require("prefs");
const {checkWhitelisted, getKey} = require("whitelisting");
-const {stringifyURL, extractHostFromFrame, isThirdParty} = require("url");
+const {stringifyURL, getDecodedHostname,
Sebastian Noack 2017/04/29 23:07:59 It seems the newly imported function (i.e. getDeco
Jon Sonesen 2017/05/04 10:26:05 Done.
+ extractHostFromFrame, isThirdParty} = require("url");
const {port} = require("messaging");
const devtools = require("devtools");
// Chrome can't distinguish between OBJECT_SUBREQUEST and OBJECT requests.
RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT;
function onBeforeRequestAsync(page, url, type, docDomain,
thirdParty, sitekey,
@@ -46,27 +47,36 @@
thirdParty, sitekey,
specificOnly, filter
);
}
}
ext.webRequest.onBeforeRequest.addListener((url, type, page, frame) =>
{
- if (checkWhitelisted(page, frame))
- return true;
+ let docDomain = null;
+ let sitekey = null;
+ let specificOnly = false;
+ let thirdParty = false;
let urlString = stringifyURL(url);
- let docDomain = extractHostFromFrame(frame);
- let thirdParty = isThirdParty(url, docDomain);
- let sitekey = getKey(page, frame);
- let specificOnly = !!checkWhitelisted(
- page, frame, RegExpFilter.typeMap.GENERICBLOCK
+ if (frame && page)
+ {
+ if (checkWhitelisted(page, frame))
+ return true;
Sebastian Noack 2017/04/29 23:08:00 Nit: I'd always add a blank line when returning be
Jon Sonesen 2017/05/04 10:26:06 Done.
+ docDomain = extractHostFromFrame(frame);
+ sitekey = getKey(page, frame);
+ isThirdParty(url, docDomain);
Sebastian Noack 2017/04/29 23:07:59 As this code stands, this call is redundant. Did y
Jon Sonesen 2017/05/04 10:26:05 Yeah that's what happened there. Thanks. Done.
+ specificOnly = !!checkWhitelisted(
+ page, frame, RegExpFilter.typeMap.GENERICBLOCK
);
+ }
+
+
let filter = defaultMatcher.matchesAny(
urlString, RegExpFilter.typeMap[type],
docDomain, thirdParty, sitekey, specificOnly
);
setTimeout(onBeforeRequestAsync, 0, page, urlString,
type, docDomain,
« no previous file with comments | « lib/devtools.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld