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

Delta Between Two Patch Sets: lib/requestBlocker.js

Issue 29680696: [$csp4 adblockpluschrome] Issue 5241 - Add support for Content Security Policy filters (Closed)
Left Patch Set: Addressed some final nits Created March 20, 2018, 9:01 a.m.
Right Patch Set: Rebased Created March 26, 2018, 6:22 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/devtools.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 exports.filterTypes = new Set(function*() 56 exports.filterTypes = new Set(function*()
57 { 57 {
58 // Microsoft Edge does not have webRequest.ResourceType or the devtools panel. 58 // Microsoft Edge does not have webRequest.ResourceType or the devtools panel.
59 // Since filterTypes is only used by devtools, we can just bail out here. 59 // Since filterTypes is only used by devtools, we can just bail out here.
60 if (!(browser.webRequest.ResourceType)) 60 if (!(browser.webRequest.ResourceType))
61 return; 61 return;
62 62
63 for (let type in browser.webRequest.ResourceType) 63 for (let type in browser.webRequest.ResourceType)
64 yield resourceTypes.get(browser.webRequest.ResourceType[type]) || "OTHER"; 64 yield resourceTypes.get(browser.webRequest.ResourceType[type]) || "OTHER";
65 65
66 // WEBSOCKET and WEBRTC get addressed through workarounds, even if the 66 // WEBRTC gets addressed through a workaround, even if the webRequest API is
67 // webRequest API is lacking support to block these kind of requests. 67 // lacking support to block this kind of a request.
68 yield "WEBSOCKET";
69 yield "WEBRTC"; 68 yield "WEBRTC";
70 69
71 // POPUP, CSP and ELEMHIDE filters aren't mapped to resource types. 70 // POPUP, CSP and ELEMHIDE filters aren't mapped to resource types.
72 yield "POPUP"; 71 yield "POPUP";
73 yield "ELEMHIDE"; 72 yield "ELEMHIDE";
74 yield "CSP"; 73 yield "CSP";
75 }()); 74 }());
76 75
77 function onBeforeRequestAsync(page, url, type, docDomain, 76 function onBeforeRequestAsync(page, url, type, docDomain,
78 thirdParty, sitekey, 77 thirdParty, sitekey,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 197
199 FilterNotifier.on("subscription.added", onFilterChange); 198 FilterNotifier.on("subscription.added", onFilterChange);
200 FilterNotifier.on("subscription.removed", onFilterChange); 199 FilterNotifier.on("subscription.removed", onFilterChange);
201 FilterNotifier.on("subscription.updated", onFilterChange); 200 FilterNotifier.on("subscription.updated", onFilterChange);
202 FilterNotifier.on("subscription.disabled", arg => onFilterChange(arg, true)); 201 FilterNotifier.on("subscription.disabled", arg => onFilterChange(arg, true));
203 FilterNotifier.on("filter.added", onFilterChange); 202 FilterNotifier.on("filter.added", onFilterChange);
204 FilterNotifier.on("filter.removed", onFilterChange); 203 FilterNotifier.on("filter.removed", onFilterChange);
205 FilterNotifier.on("filter.disabled", arg => onFilterChange(arg, true)); 204 FilterNotifier.on("filter.disabled", arg => onFilterChange(arg, true));
206 FilterNotifier.on("load", onFilterChange); 205 FilterNotifier.on("load", onFilterChange);
207 206
208 port.on("request.blockedByWrapper", (msg, sender) => 207 port.on("request.blockedByRTCWrapper", (msg, sender) =>
209 { 208 {
210 // Chrome 58 onwards directly supports WebSocket blocking, so we can ignore
211 // messages from the wrapper here (see https://crbug.com/129353). Hopefully
212 // WebRTC will be supported soon too (see https://crbug.com/707683).
213 // Edge supports neither webRequest.ResourceType nor WebSocket blocking yet:
214 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/102973 76/
215 if (browser.webRequest.ResourceType &&
216 (msg.requestType.toUpperCase() in browser.webRequest.ResourceType))
217 {
218 return false;
219 }
220
221 return ext.webRequest.onBeforeRequest._dispatch( 209 return ext.webRequest.onBeforeRequest._dispatch(
222 new URL(msg.url), 210 new URL(msg.url),
223 msg.requestType, 211 "webrtc",
224 sender.page, 212 sender.page,
225 sender.frame 213 sender.frame
226 ).includes(false); 214 ).includes(false);
227 }); 215 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld