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

Side by Side Diff: lib/requestBlocker.js

Issue 29458601: Issue 5315 - Add support for Microsoft Edge (Closed)
Patch Set: Handle webRequest.ResourceType (#5321) and RTCPeerConnection.generateCertificate, address comments Created June 15, 2017, 11:18 a.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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 11 matching lines...) Expand all
22 const {Filter, RegExpFilter, BlockingFilter} = require("filterClasses"); 22 const {Filter, RegExpFilter, BlockingFilter} = require("filterClasses");
23 const {Subscription} = require("subscriptionClasses"); 23 const {Subscription} = require("subscriptionClasses");
24 const {defaultMatcher} = require("matcher"); 24 const {defaultMatcher} = require("matcher");
25 const {FilterNotifier} = require("filterNotifier"); 25 const {FilterNotifier} = require("filterNotifier");
26 const {Prefs} = require("prefs"); 26 const {Prefs} = require("prefs");
27 const {checkWhitelisted, getKey} = require("whitelisting"); 27 const {checkWhitelisted, getKey} = require("whitelisting");
28 const {stringifyURL, extractHostFromFrame, isThirdParty} = require("url"); 28 const {stringifyURL, extractHostFromFrame, isThirdParty} = require("url");
29 const {port} = require("messaging"); 29 const {port} = require("messaging");
30 const devtools = require("devtools"); 30 const devtools = require("devtools");
31 31
32 // Chrome can't distinguish between OBJECT_SUBREQUEST and OBJECT requests. 32 // Chrome and Firefox (WebExtensions) can't distinguish between
33 if (!("OBJECT_SUBREQUEST" in chrome.webRequest.ResourceType)) 33 // OBJECT_SUBREQUEST and OBJECT requests.
Sebastian Noack 2017/06/19 11:07:02 This check was necessary to account for Firefox wh
Oleksandr 2017/06/21 23:38:35 This was just accidental reverting of a patch. Fix
34 RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT; 34 RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT;
35 35
36 // Map of content types reported by the browser to the respecitve content types 36 // Map of content types reported by the browser to the respecitve content types
37 // used by Adblock Plus. Other content types are simply mapped to OTHER. 37 // used by Adblock Plus. Other content types are simply mapped to OTHER.
38 let resourceTypes = new Map(function*() 38 let resourceTypes = new Map(function*()
39 { 39 {
40 for (let type in RegExpFilter.typeMap) 40 for (let type in RegExpFilter.typeMap)
41 yield [type.toLowerCase(), type]; 41 yield [type.toLowerCase(), type];
42 42
43 yield ["sub_frame", "SUBDOCUMENT"]; 43 yield ["sub_frame", "SUBDOCUMENT"];
44 44
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 FilterNotifier.on("filter.added", onFilterChange); 179 FilterNotifier.on("filter.added", onFilterChange);
180 FilterNotifier.on("filter.removed", onFilterChange); 180 FilterNotifier.on("filter.removed", onFilterChange);
181 FilterNotifier.on("filter.disabled", arg => onFilterChange(arg, true)); 181 FilterNotifier.on("filter.disabled", arg => onFilterChange(arg, true));
182 FilterNotifier.on("load", onFilterChange); 182 FilterNotifier.on("load", onFilterChange);
183 183
184 port.on("request.blockedByWrapper", (msg, sender) => 184 port.on("request.blockedByWrapper", (msg, sender) =>
185 { 185 {
186 // Chrome 58 onwards directly supports WebSocket blocking, so we can ignore 186 // Chrome 58 onwards directly supports WebSocket blocking, so we can ignore
187 // messages from the wrapper here (see https://crbug.com/129353). Hopefully 187 // messages from the wrapper here (see https://crbug.com/129353). Hopefully
188 // WebRTC will be supported soon too (see https://crbug.com/707683). 188 // WebRTC will be supported soon too (see https://crbug.com/707683).
189 if (msg.requestType.toUpperCase() in chrome.webRequest.ResourceType) 189 // Edge supports neither webRequest.ResourceType nor WebSocket blocking yet:
190 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/102973 76/
191 if (chrome.webRequest.ResourceType &&
192 (msg.requestType.toUpperCase() in chrome.webRequest.ResourceType))
190 return false; 193 return false;
191 194
192 return ext.webRequest.onBeforeRequest._dispatch( 195 return ext.webRequest.onBeforeRequest._dispatch(
193 new URL(msg.url), 196 new URL(msg.url),
194 msg.requestType, 197 msg.requestType,
195 sender.page, 198 sender.page,
196 sender.frame 199 sender.frame
197 ).includes(false); 200 ).includes(false);
198 }); 201 });
OLDNEW
« inject.preload.js ('K') | « lib/csp.js ('k') | metadata.edge » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld