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

Side by Side Diff: lib/requestBlocker.js

Issue 29418679: Issue 5042 - Adds handling for requests which are not associated with browser tab (Closed)
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:
View unified diff | Download patch
« no previous file with comments | « lib/devtools.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 devtools.logRequest( 62 devtools.logRequest(
63 page, url, type, docDomain, 63 page, url, type, docDomain,
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 if (checkWhitelisted(page, frame)) 72 let docDomain = null;
73 return true; 73 let sitekey = null;
74 let specificOnly = false;
75 let thirdParty = false;
76 let urlString = stringifyURL(url);
74 77
75 let urlString = stringifyURL(url);
76 let docDomain = extractHostFromFrame(frame);
77 let thirdParty = isThirdParty(url, docDomain);
78 let sitekey = getKey(page, frame);
79 78
80 let specificOnly = !!checkWhitelisted( 79 if (frame && page)
81 page, frame, RegExpFilter.typeMap.GENERICBLOCK 80 {
82 ); 81 if (checkWhitelisted(page, frame))
82 return true;
83
84 docDomain = extractHostFromFrame(frame);
85 sitekey = getKey(page, frame);
86 thirdParty = isThirdParty(url, docDomain);
87 specificOnly = !!checkWhitelisted(page, frame,
88 RegExpFilter.typeMap.GENERICBLOCK);
89 }
83 90
84 let mappedType = resourceTypes.get(type) || "OTHER"; 91 let mappedType = resourceTypes.get(type) || "OTHER";
85 92
86 let filter = defaultMatcher.matchesAny( 93 let filter = defaultMatcher.matchesAny(
87 urlString, RegExpFilter.typeMap[mappedType], 94 urlString, RegExpFilter.typeMap[mappedType],
88 docDomain, thirdParty, sitekey, specificOnly 95 docDomain, thirdParty, sitekey, specificOnly
89 ); 96 );
90 97
91 setTimeout(onBeforeRequestAsync, 0, page, urlString, 98 setTimeout(onBeforeRequestAsync, 0, page, urlString,
92 mappedType, docDomain, 99 mappedType, docDomain,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 if (msg.requestType.toUpperCase() in chrome.webRequest.ResourceType) 189 if (msg.requestType.toUpperCase() in chrome.webRequest.ResourceType)
183 return false; 190 return false;
184 191
185 return ext.webRequest.onBeforeRequest._dispatch( 192 return ext.webRequest.onBeforeRequest._dispatch(
186 new URL(msg.url), 193 new URL(msg.url),
187 msg.requestType, 194 msg.requestType,
188 sender.page, 195 sender.page,
189 sender.frame 196 sender.frame
190 ).includes(false); 197 ).includes(false);
191 }); 198 });
OLDNEW
« no previous file with comments | « lib/devtools.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld