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

Delta Between Two Patch Sets: lib/requestBlocker.js

Issue 29752559: Issue 6586 - Fixed WebRTC wrapper after removing ext.webRequest.onBeforeRequest (Closed)
Left Patch Set: Created April 14, 2018, 11:54 a.m.
Right Patch Set: Moved request.blockedByRTCWrapper message listener below other message listener Created April 14, 2018, 12:15 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 | « no previous file | 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // can just use the request's frame ID, but for subdocument requests 188 // can just use the request's frame ID, but for subdocument requests
189 // (e.g. iframes) we must instead use the request's parent frame ID. 189 // (e.g. iframes) we must instead use the request's parent frame ID.
190 details.type == "sub_frame" ? details.parentFrameId : details.frameId 190 details.type == "sub_frame" ? details.parentFrameId : details.frameId
191 ); 191 );
192 } 192 }
193 193
194 if (checkWhitelisted(page, frame, originUrl)) 194 if (checkWhitelisted(page, frame, originUrl))
195 return; 195 return;
196 196
197 let type = resourceTypes.get(details.type) || "OTHER"; 197 let type = resourceTypes.get(details.type) || "OTHER";
198 let [docDomain, sitekey, specificOnly] = getDocumentInfo(page, frame, 198 let [docDomain, sitekey, specificOnly] = getDocumentInfo(page, frame,
kzar 2018/04/17 12:46:39 Perhaps it would be a nicer abstraction to have a
Sebastian Noack 2018/04/17 12:56:47 FWIW, I'm not too happy with this abstraction (jus
kzar 2018/04/17 13:54:06 Yea, fair enough.
199 originUrl); 199 originUrl);
200 let [filter, urlString, thirdParty] = matchRequest(url, type, docDomain, 200 let [filter, urlString, thirdParty] = matchRequest(url, type, docDomain,
201 sitekey, specificOnly); 201 sitekey, specificOnly);
202 202
203 getRelatedTabIds(details).then(tabIds => 203 getRelatedTabIds(details).then(tabIds =>
204 { 204 {
205 logRequest(tabIds, urlString, type, docDomain, 205 logRequest(tabIds, urlString, type, docDomain,
206 thirdParty, sitekey, specificOnly, filter); 206 thirdParty, sitekey, specificOnly, filter);
207 }); 207 });
208 208
(...skipping 21 matching lines...) Expand all
230 { 230 {
231 if (filter.collapse != null) 231 if (filter.collapse != null)
232 return filter.collapse; 232 return filter.collapse;
233 blocked = true; 233 blocked = true;
234 } 234 }
235 } 235 }
236 236
237 return blocked && Prefs.hidePlaceholders; 237 return blocked && Prefs.hidePlaceholders;
238 }); 238 });
239 239
240 port.on("request.blockedByRTCWrapper", (msg, sender) =>
241 {
242 let {page, frame} = sender;
243
244 if (checkWhitelisted(page, frame))
245 return false;
246
247 let [docDomain, sitekey, specificOnly] = getDocumentInfo(page, frame);
248 let [filter, url, thirdParty] = matchRequest(new URL(msg.url),
249 "WEBRTC", docDomain,
250 sitekey, specificOnly);
251
252 logRequest([sender.page.id], url, "WEBRTC", docDomain,
253 thirdParty, sitekey, specificOnly, filter);
254
255 return filter instanceof BlockingFilter;
256 });
257
240 let ignoreFilterNotifications = false; 258 let ignoreFilterNotifications = false;
241 259
242 function onFilterChange(arg, isDisabledAction) 260 function onFilterChange(arg, isDisabledAction)
243 { 261 {
244 // Avoid triggering filters.behaviorChanged multiple times 262 // Avoid triggering filters.behaviorChanged multiple times
245 // when multiple filter hanges happen at the same time. 263 // when multiple filter hanges happen at the same time.
246 if (ignoreFilterNotifications) 264 if (ignoreFilterNotifications)
247 return; 265 return;
248 266
249 // Ignore disabled subscriptions and filters, unless they just got 267 // Ignore disabled subscriptions and filters, unless they just got
(...skipping 21 matching lines...) Expand all
271 } 289 }
272 290
273 FilterNotifier.on("subscription.added", onFilterChange); 291 FilterNotifier.on("subscription.added", onFilterChange);
274 FilterNotifier.on("subscription.removed", onFilterChange); 292 FilterNotifier.on("subscription.removed", onFilterChange);
275 FilterNotifier.on("subscription.updated", onFilterChange); 293 FilterNotifier.on("subscription.updated", onFilterChange);
276 FilterNotifier.on("subscription.disabled", arg => onFilterChange(arg, true)); 294 FilterNotifier.on("subscription.disabled", arg => onFilterChange(arg, true));
277 FilterNotifier.on("filter.added", onFilterChange); 295 FilterNotifier.on("filter.added", onFilterChange);
278 FilterNotifier.on("filter.removed", onFilterChange); 296 FilterNotifier.on("filter.removed", onFilterChange);
279 FilterNotifier.on("filter.disabled", arg => onFilterChange(arg, true)); 297 FilterNotifier.on("filter.disabled", arg => onFilterChange(arg, true));
280 FilterNotifier.on("load", onFilterChange); 298 FilterNotifier.on("load", onFilterChange);
281
282 port.on("request.blockedByRTCWrapper", (msg, sender) =>
283 {
284 let {page, frame} = sender;
285
286 if (checkWhitelisted(page, frame))
287 return false;
288
289 let [docDomain, sitekey, specificOnly] = getDocumentInfo(page, frame);
290 let [filter, url, thirdParty] = matchRequest(new URL(msg.url),
291 "WEBRTC", docDomain,
292 sitekey, specificOnly);
293
294 logRequest([sender.page.id], url, "WEBRTC", docDomain,
295 thirdParty, sitekey, specificOnly, filter);
296
297 return filter instanceof BlockingFilter;
298 });
LEFTRIGHT
« no previous file | 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