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: addresses comments, nits, redundancies, white space Created May 31, 2017, 8:43 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 let specificOnly = false; 74 let specificOnly = false;
75 let thirdParty = false; 75 let thirdParty = false;
76 let urlString = stringifyURL(url); 76 let urlString = stringifyURL(url);
77 77
78
78 if (frame && page) 79 if (frame && page)
Sebastian Noack 2017/06/01 17:32:21 Nit: As mentioned before, I'd add a blank line abo
Jon Sonesen 2017/06/02 05:02:58 Acknowledged.
79 { 80 {
80 if (checkWhitelisted(page, frame)) 81 if (checkWhitelisted(page, frame))
81 return true; 82 return true;
82 83
83 docDomain = extractHostFromFrame(frame); 84 docDomain = extractHostFromFrame(frame);
84 sitekey = getKey(page, frame); 85 sitekey = getKey(page, frame);
85 thirdParty = isThirdParty(url, docDomain); 86 thirdParty = isThirdParty(url, docDomain);
86 specificOnly = !!checkWhitelisted(page, frame, 87 specificOnly = !!checkWhitelisted(page, frame,
87 RegExpFilter.typeMap.GENERICBLOCK); 88 RegExpFilter.typeMap.GENERICBLOCK);
88 } 89 }
89
Sebastian Noack 2017/06/01 17:32:21 Nit: One blank line is sufficient here.
Jon Sonesen 2017/06/02 05:02:58 Acknowledged.
90
91 90
92 let mappedType = resourceTypes.get(type) || "OTHER"; 91 let mappedType = resourceTypes.get(type) || "OTHER";
93 92
94 let filter = defaultMatcher.matchesAny( 93 let filter = defaultMatcher.matchesAny(
95 urlString, RegExpFilter.typeMap[mappedType], 94 urlString, RegExpFilter.typeMap[mappedType],
96 docDomain, thirdParty, sitekey, specificOnly 95 docDomain, thirdParty, sitekey, specificOnly
97 ); 96 );
98 97
99 setTimeout(onBeforeRequestAsync, 0, page, urlString, 98 setTimeout(onBeforeRequestAsync, 0, page, urlString,
100 mappedType, docDomain, 99 mappedType, docDomain,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if (msg.requestType.toUpperCase() in chrome.webRequest.ResourceType) 189 if (msg.requestType.toUpperCase() in chrome.webRequest.ResourceType)
191 return false; 190 return false;
192 191
193 return ext.webRequest.onBeforeRequest._dispatch( 192 return ext.webRequest.onBeforeRequest._dispatch(
194 new URL(msg.url), 193 new URL(msg.url),
195 msg.requestType, 194 msg.requestType,
196 sender.page, 195 sender.page,
197 sender.frame 196 sender.frame
198 ).includes(false); 197 ).includes(false);
199 }); 198 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld