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

Delta Between Two Patch Sets: lib/requestBlocker.js

Issue 29418679: Issue 5042 - Adds handling for requests which are not associated with browser tab (Closed)
Left Patch Set: rebase Created May 30, 2017, 9:04 a.m.
Right Patch Set: fix whitespace, add comment abut null page, remove redundancies Created June 2, 2017, 5:01 a.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-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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 thirdParty, sitekey, 64 thirdParty, sitekey,
65 specificOnly, filter 65 specificOnly, filter
66 ); 66 );
67 } 67 }
68 } 68 }
69 69
70 ext.webRequest.onBeforeRequest.addListener((url, type, page, frame) => 70 ext.webRequest.onBeforeRequest.addListener((url, type, page, frame) =>
71 { 71 {
72 let docDomain = null; 72 let docDomain = null;
73 let sitekey = null; 73 let sitekey = null;
74
75 let specificOnly = false; 74 let specificOnly = false;
Sebastian Noack 2017/05/30 11:10:49 Nit: The blank line above looks redundant, but ins
Jon Sonesen 2017/05/31 08:28:18 Acknowledged.
76 let thirdParty = false; 75 let thirdParty = false;
77 let urlString = stringifyURL(url); 76 let urlString = stringifyURL(url);
77
78 78
79 if (frame && page) 79 if (frame && page)
80 { 80 {
81 if (checkWhitelisted(page, frame)) 81 if (checkWhitelisted(page, frame))
82 return true; 82 return true;
83 83
84 docDomain = extractHostFromFrame(frame); 84 docDomain = extractHostFromFrame(frame);
85 sitekey = getKey(page, frame); 85 sitekey = getKey(page, frame);
86 thirdParty = isThirdParty(url, docDomain); 86 thirdParty = isThirdParty(url, docDomain);
87 specificOnly = !!checkWhitelisted( 87 specificOnly = !!checkWhitelisted(page, frame,
88 page, frame, RegExpFilter.typeMap.GENERICBLOCK 88 RegExpFilter.typeMap.GENERICBLOCK);
89 );
90 } 89 }
91
92
93 90
94 let mappedType = resourceTypes.get(type) || "OTHER"; 91 let mappedType = resourceTypes.get(type) || "OTHER";
95 92
96 let filter = defaultMatcher.matchesAny( 93 let filter = defaultMatcher.matchesAny(
97 urlString, RegExpFilter.typeMap[mappedType], 94 urlString, RegExpFilter.typeMap[mappedType],
98 docDomain, thirdParty, sitekey, specificOnly 95 docDomain, thirdParty, sitekey, specificOnly
99 ); 96 );
100 97
101 setTimeout(onBeforeRequestAsync, 0, page, urlString, 98 setTimeout(onBeforeRequestAsync, 0, page, urlString,
102 mappedType, docDomain, 99 mappedType, docDomain,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 if (msg.requestType.toUpperCase() in chrome.webRequest.ResourceType) 189 if (msg.requestType.toUpperCase() in chrome.webRequest.ResourceType)
193 return false; 190 return false;
194 191
195 return ext.webRequest.onBeforeRequest._dispatch( 192 return ext.webRequest.onBeforeRequest._dispatch(
196 new URL(msg.url), 193 new URL(msg.url),
197 msg.requestType, 194 msg.requestType,
198 sender.page, 195 sender.page,
199 sender.frame 196 sender.frame
200 ).includes(false); 197 ).includes(false);
201 }); 198 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld