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

Side by Side Diff: lib/requestBlocker.js

Issue 29680696: [$csp4 adblockpluschrome] Issue 5241 - Add support for Content Security Policy filters (Closed)
Patch Set: Rebased, ignored requests cached by ServiceWorkers and addressed Sebastian's feedback Created March 13, 2018, 6:08 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // WEBSOCKET and WEBRTC get addressed through workarounds, even if the
67 // webRequest API is lacking support to block these kind of requests. 67 // webRequest API is lacking support to block these kind of requests.
68 yield "WEBSOCKET"; 68 yield "WEBSOCKET";
69 yield "WEBRTC"; 69 yield "WEBRTC";
70 70
71 // POPUP and ELEMHIDE filters aren't blocked on the request level but by other 71 // POPUP, CSP and ELEMHIDE filters aren't blocked on the request level but by
72 // means. They don't have a corresponding value in webRequest.ResourceType. 72 // other means. They don't have a corresponding value in
73 // webRequest.ResourceType.
73 yield "POPUP"; 74 yield "POPUP";
74 yield "ELEMHIDE"; 75 yield "ELEMHIDE";
76 yield "CSP";
75 }()); 77 }());
76 78
77 function onBeforeRequestAsync(page, url, type, docDomain, 79 function onBeforeRequestAsync(page, url, type, docDomain,
78 thirdParty, sitekey, 80 thirdParty, sitekey,
79 specificOnly, filter) 81 specificOnly, filter)
80 { 82 {
81 if (filter) 83 if (filter)
82 FilterNotifier.emit("filter.hitCount", filter, 0, 0, page); 84 FilterNotifier.emit("filter.hitCount", filter, 0, 0, page);
83 85
84 if (devtools) 86 if (devtools)
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 return false; 220 return false;
219 } 221 }
220 222
221 return ext.webRequest.onBeforeRequest._dispatch( 223 return ext.webRequest.onBeforeRequest._dispatch(
222 new URL(msg.url), 224 new URL(msg.url),
223 msg.requestType, 225 msg.requestType,
224 sender.page, 226 sender.page,
225 sender.frame 227 sender.frame
226 ).includes(false); 228 ).includes(false);
227 }); 229 });
OLDNEW

Powered by Google App Engine
This is Rietveld