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

Side by Side Diff: lib/requestBlocker.js

Issue 29705719: Issue 6402 - Split filter hit / request logging out into own API (Closed)
Patch Set: Nightmarish rebase Created April 13, 2018, 3:20 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 10 matching lines...) Expand all
21 21
22 const {Filter, RegExpFilter, BlockingFilter} = 22 const {Filter, RegExpFilter, BlockingFilter} =
23 require("../adblockpluscore/lib/filterClasses"); 23 require("../adblockpluscore/lib/filterClasses");
24 const {Subscription} = require("../adblockpluscore/lib/subscriptionClasses"); 24 const {Subscription} = require("../adblockpluscore/lib/subscriptionClasses");
25 const {defaultMatcher} = require("../adblockpluscore/lib/matcher"); 25 const {defaultMatcher} = require("../adblockpluscore/lib/matcher");
26 const {FilterNotifier} = require("../adblockpluscore/lib/filterNotifier"); 26 const {FilterNotifier} = require("../adblockpluscore/lib/filterNotifier");
27 const {Prefs} = require("./prefs"); 27 const {Prefs} = require("./prefs");
28 const {checkWhitelisted, getKey} = require("./whitelisting"); 28 const {checkWhitelisted, getKey} = require("./whitelisting");
29 const {stringifyURL, extractHostFromFrame, isThirdParty} = require("./url"); 29 const {stringifyURL, extractHostFromFrame, isThirdParty} = require("./url");
30 const {port} = require("./messaging"); 30 const {port} = require("./messaging");
31 const devtools = require("./devtools"); 31 const {logRequest: hitLoggerLogRequest} = require("./hitLogger");
32 32
33 const extensionProtocol = new URL(browser.extension.getURL("")).protocol; 33 const extensionProtocol = new URL(browser.extension.getURL("")).protocol;
34 34
35 // Chrome can't distinguish between OBJECT_SUBREQUEST and OBJECT requests. 35 // Chrome can't distinguish between OBJECT_SUBREQUEST and OBJECT requests.
36 if (!browser.webRequest.ResourceType || 36 if (!browser.webRequest.ResourceType ||
37 !("OBJECT_SUBREQUEST" in browser.webRequest.ResourceType)) 37 !("OBJECT_SUBREQUEST" in browser.webRequest.ResourceType))
38 { 38 {
39 RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT; 39 RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT;
40 } 40 }
41 41
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 function logRequest(details, url, type, docDomain, thirdParty, 102 function logRequest(details, url, type, docDomain, thirdParty,
103 sitekey, specificOnly, filter) 103 sitekey, specificOnly, filter)
104 { 104 {
105 getRelatedTabIds(details).then(tabIds => 105 getRelatedTabIds(details).then(tabIds =>
106 { 106 {
107 if (filter) 107 if (filter)
108 FilterNotifier.emit("filter.hitCount", filter, 0, 0, tabIds); 108 FilterNotifier.emit("filter.hitCount", filter, 0, 0, tabIds);
109 109
110 devtools.logRequest( 110 hitLoggerLogRequest(
111 tabIds, url, type, docDomain, 111 tabIds, url, type, docDomain,
112 thirdParty, sitekey, 112 thirdParty, sitekey,
113 specificOnly, filter 113 specificOnly, filter
114 ); 114 );
115 }); 115 });
116 } 116 }
117 117
118 browser.webRequest.onBeforeRequest.addListener(details => 118 browser.webRequest.onBeforeRequest.addListener(details =>
119 { 119 {
120 // Never block top-level documents. 120 // Never block top-level documents.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 port.on("request.blockedByRTCWrapper", (msg, sender) => 275 port.on("request.blockedByRTCWrapper", (msg, sender) =>
276 { 276 {
277 return ext.webRequest.onBeforeRequest._dispatch( 277 return ext.webRequest.onBeforeRequest._dispatch(
278 new URL(msg.url), 278 new URL(msg.url),
279 "webrtc", 279 "webrtc",
280 sender.page, 280 sender.page,
281 sender.frame 281 sender.frame
282 ).includes(false); 282 ).includes(false);
283 }); 283 });
OLDNEW

Powered by Google App Engine
This is Rietveld