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

Delta Between Two Patch Sets: lib/requestBlocker.js

Issue 29522656: Issue 5316 - Adds supported filter types export value to requestBlocker (Closed)
Left Patch Set: Created Sept. 5, 2017, 5:24 p.m.
Right Patch Set: update dependency file Created Sept. 19, 2017, 1:45 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 | « dependencies ('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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // Treat navigator.sendBeacon() the same as <a ping>, it's essentially the 48 // Treat navigator.sendBeacon() the same as <a ping>, it's essentially the
49 // same concept - merely generalized. 49 // same concept - merely generalized.
50 yield ["beacon", "PING"]; 50 yield ["beacon", "PING"];
51 51
52 // Treat <img srcset> and <picture> the same as other images. 52 // Treat <img srcset> and <picture> the same as other images.
53 yield ["imageset", "IMAGE"]; 53 yield ["imageset", "IMAGE"];
54 }()); 54 }());
55 55
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.
59 // Since filterTypes is only used by devtools, we can just bail out here.
58 if (!(chrome.webRequest.ResourceType)) 60 if (!(chrome.webRequest.ResourceType))
Sebastian Noack 2017/09/05 18:08:10 Please add a comment like this: "Microsoft Edge d
Jon Sonesen 2017/09/06 12:55:43 Acknowledged.
59 return; 61 return;
62
60 for (let type in chrome.webRequest.ResourceType) 63 for (let type in chrome.webRequest.ResourceType)
61 yield resourceTypes.get(chrome.webRequest.ResourceType[type]) || "OTHER"; 64 yield resourceTypes.get(chrome.webRequest.ResourceType[type]) || "OTHER";
65
66 // WEBSOCKET and WEBRTC get addressed through workarounds, even if the
67 // webRequest API is lacking support to block these kind of requests.
62 yield "WEBSOCKET"; 68 yield "WEBSOCKET";
Sebastian Noack 2017/09/05 18:08:11 Please add a comment like this: "WEBSOCKET and WE
Jon Sonesen 2017/09/06 12:55:43 Acknowledged.
63 yield "WEBRTC"; 69 yield "WEBRTC";
70
71 // POPUP and ELEMHIDE filters aren't blocked on the request level but by other
72 // means. They don't have a corresponding value in webRequest.ResourceType.
64 yield "POPUP"; 73 yield "POPUP";
Sebastian Noack 2017/09/05 18:08:10 Please add a comment like this: "POPUP and ELEMHI
Jon Sonesen 2017/09/06 12:55:43 Acknowledged.
65 yield "ELEMHIDE"; 74 yield "ELEMHIDE";
66 }()); 75 }());
67 76
68 function onBeforeRequestAsync(page, url, type, docDomain, 77 function onBeforeRequestAsync(page, url, type, docDomain,
69 thirdParty, sitekey, 78 thirdParty, sitekey,
70 specificOnly, filter) 79 specificOnly, filter)
71 { 80 {
72 if (filter) 81 if (filter)
73 FilterNotifier.emit("filter.hitCount", filter, 0, 0, page); 82 FilterNotifier.emit("filter.hitCount", filter, 0, 0, page);
74 83
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 return false; 218 return false;
210 } 219 }
211 220
212 return ext.webRequest.onBeforeRequest._dispatch( 221 return ext.webRequest.onBeforeRequest._dispatch(
213 new URL(msg.url), 222 new URL(msg.url),
214 msg.requestType, 223 msg.requestType,
215 sender.page, 224 sender.page,
216 sender.frame 225 sender.frame
217 ).includes(false); 226 ).includes(false);
218 }); 227 });
LEFTRIGHT
« dependencies ('k') | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld