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

Delta Between Two Patch Sets: lib/requestBlocker.js

Issue 29421712: Issue 5184 - Support Firefox-specific webRequest types (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Use generator to populate map Created May 19, 2017, 11:41 p.m.
Right Patch Set: Use for..in Created May 20, 2017, 6:54 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 | « ext/background.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-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 19 matching lines...) Expand all
30 const devtools = require("devtools"); 30 const devtools = require("devtools");
31 31
32 // Chrome and Firefox (WebExtensions) can't distinguish between 32 // Chrome and Firefox (WebExtensions) can't distinguish between
33 // OBJECT_SUBREQUEST and OBJECT requests. 33 // OBJECT_SUBREQUEST and OBJECT requests.
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 of Object.keys(RegExpFilter.typeMap)) 40 for (let type in RegExpFilter.typeMap)
Manish Jethani 2017/05/19 23:44:15 This by the way could just be: yield* Object.ke
Sebastian Noack 2017/05/20 06:42:37 It seems all versions of Chrome that support gener
Manish Jethani 2017/05/20 18:50:47 Done.
41 yield [type.toLowerCase(), type]; 41 yield [type.toLowerCase(), type];
42 42
43 yield ["sub_frame", "SUBDOCUMENT"]; 43 yield ["sub_frame", "SUBDOCUMENT"];
44 44
45 // Treat navigator.sendBeacon() the same as <a ping>, it's essentially the 45 // Treat navigator.sendBeacon() the same as <a ping>, it's essentially the
46 // same concept - merely generalized. 46 // same concept - merely generalized.
47 yield ["beacon", "PING"]; 47 yield ["beacon", "PING"];
48 48
49 // Treat <img srcset> and <picture> the same as other images. 49 // Treat <img srcset> and <picture> the same as other images.
50 yield ["imageset", "IMAGE"]; 50 yield ["imageset", "IMAGE"];
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 if (msg.requestType in chrome.webRequest.ResourceType) 182 if (msg.requestType in chrome.webRequest.ResourceType)
183 return false; 183 return false;
184 184
185 return ext.webRequest.onBeforeRequest._dispatch( 185 return ext.webRequest.onBeforeRequest._dispatch(
186 new URL(msg.url), 186 new URL(msg.url),
187 msg.requestType, 187 msg.requestType,
188 sender.page, 188 sender.page,
189 sender.frame 189 sender.frame
190 ).includes(false); 190 ).includes(false);
191 }); 191 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld