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: Rebased Created April 30, 2018, 1:01 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
« no previous file with comments | « lib/popupBlocker.js ('k') | lib/whitelisting.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 return browser.tabs.query({url}).then(tabs => tabs.map(tab => tab.id)); 122 return browser.tabs.query({url}).then(tabs => tabs.map(tab => tab.id));
123 } 123 }
124 124
125 function logRequest(tabIds, url, type, docDomain, thirdParty, 125 function logRequest(tabIds, url, type, docDomain, thirdParty,
126 sitekey, specificOnly, filter) 126 sitekey, specificOnly, filter)
127 { 127 {
128 if (filter) 128 if (filter)
129 FilterNotifier.emit("filter.hitCount", filter, 0, 0, tabIds); 129 FilterNotifier.emit("filter.hitCount", filter, 0, 0, tabIds);
130 130
131 devtools.logRequest( 131 hitLoggerLogRequest(
132 tabIds, url, type, docDomain, 132 tabIds, url, type, docDomain,
133 thirdParty, sitekey, 133 thirdParty, sitekey,
134 specificOnly, filter 134 specificOnly, filter
135 ); 135 );
136 } 136 }
137 137
138 browser.webRequest.onBeforeRequest.addListener(details => 138 browser.webRequest.onBeforeRequest.addListener(details =>
139 { 139 {
140 // Never block top-level documents. 140 // Never block top-level documents.
141 if (details.type == "main_frame") 141 if (details.type == "main_frame")
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 } 309 }
310 310
311 FilterNotifier.on("subscription.added", onFilterChange); 311 FilterNotifier.on("subscription.added", onFilterChange);
312 FilterNotifier.on("subscription.removed", onFilterChange); 312 FilterNotifier.on("subscription.removed", onFilterChange);
313 FilterNotifier.on("subscription.updated", onFilterChange); 313 FilterNotifier.on("subscription.updated", onFilterChange);
314 FilterNotifier.on("subscription.disabled", arg => onFilterChange(arg, true)); 314 FilterNotifier.on("subscription.disabled", arg => onFilterChange(arg, true));
315 FilterNotifier.on("filter.added", onFilterChange); 315 FilterNotifier.on("filter.added", onFilterChange);
316 FilterNotifier.on("filter.removed", onFilterChange); 316 FilterNotifier.on("filter.removed", onFilterChange);
317 FilterNotifier.on("filter.disabled", arg => onFilterChange(arg, true)); 317 FilterNotifier.on("filter.disabled", arg => onFilterChange(arg, true));
318 FilterNotifier.on("load", onFilterChange); 318 FilterNotifier.on("load", onFilterChange);
OLDNEW
« no previous file with comments | « lib/popupBlocker.js ('k') | lib/whitelisting.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld