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

Delta Between Two Patch Sets: lib/contentFiltering.js

Issue 29865587: Issue 6843 - Log snippet filter hits (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Fixed nits Created Aug. 27, 2018, 4:41 p.m.
Right Patch Set: rebased on top of issue 6889 Created Aug. 28, 2018, 3:14 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 | « dependencies ('k') | lib/hitLogger.js » ('j') | 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 return; 206 return;
207 207
208 throw error; 208 throw error;
209 }); 209 });
210 } 210 }
211 catch (error) 211 catch (error)
212 { 212 {
213 // See the comment in the catch block associated with the call to 213 // See the comment in the catch block associated with the call to
214 // tabs.insertCSS for why we catch any error here and simply 214 // tabs.insertCSS for why we catch any error here and simply
215 // return a rejected promise. 215 // return a rejected promise.
216 return Promise.reject(error); 216 return Promise.reject(error);
Sebastian Noack 2018/08/27 17:37:34 It appears I'm missing something here. But what is
hub 2018/08/27 19:45:24 Promise.catch(f) with call Promise.then(undefined,
Manish Jethani 2018/08/27 20:07:54 If the call to `tabs.executeScript` throws, the fu
Sebastian Noack 2018/08/27 20:15:11 Acknowledged. I misread the code and thought we ar
217 } 217 }
218 } 218 }
219 219
220 port.on("content.applyFilters", (message, sender) => 220 port.on("content.applyFilters", (message, sender) =>
221 { 221 {
222 let selectors = []; 222 let selectors = [];
223 let emulatedPatterns = []; 223 let emulatedPatterns = [];
224 let trace = HitLogger.hasListener(sender.page.id); 224 let trace = HitLogger.hasListener(sender.page.id);
225 let inline = !userStyleSheetsSupported; 225 let inline = !userStyleSheetsSupported;
226 226
227 let {elemhide, snippets} = message.filterTypes || 227 let {elemhide, snippets} = message.filterTypes ||
228 {elemhide: true, snippets: true}; 228 {elemhide: true, snippets: true};
229 229
230 if (!checkWhitelisted(sender.page, sender.frame, null, 230 if (!checkWhitelisted(sender.page, sender.frame, null,
231 RegExpFilter.typeMap.DOCUMENT)) 231 RegExpFilter.typeMap.DOCUMENT))
232 { 232 {
233 let docDomain = extractHostFromFrame(sender.frame); 233 let docDomain = extractHostFromFrame(sender.frame);
234 234
235 if (snippets) 235 if (snippets)
236 { 236 {
237 for (let filter of Snippets.getFiltersForDomain(docDomain)) 237 for (let filter of Snippets.getFiltersForDomain(docDomain))
238 { 238 {
239 executeScript(filter.script, sender.page.id, sender.frame.id) 239 executeScript(filter.script, sender.page.id, sender.frame.id).then(() =>
240 .then(() =>
Sebastian Noack 2018/08/27 17:37:34 Nit: Wrapping here appears unnecessary.
hub 2018/08/27 19:45:24 without wrapping the `>` reach column 80 so I felt
Sebastian Noack 2018/08/27 20:15:11 Yes, the line may have up to 80 characters, not mo
241 { 240 {
242 let tabIds = [sender.page.id]; 241 let tabIds = [sender.page.id];
243 if (filter) 242 if (filter)
244 FilterNotifier.emit("filter.hitCount", filter, 0, 0, tabIds); 243 FilterNotifier.emit("filter.hitCount", filter, 0, 0, tabIds);
245 244
246 logRequest(tabIds, { 245 logRequest(tabIds, {
247 url: sender.frame.url.href, 246 url: sender.frame.url.href,
248 type: "SNIPPET", 247 type: "SNIPPET",
249 docDomain 248 docDomain
250 }, filter); 249 }, filter);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 updateFrameStyles(sender.page.id, sender.frame.id, message.selectors, 288 updateFrameStyles(sender.page.id, sender.frame.id, message.selectors,
290 message.groupName, message.appendOnly); 289 message.groupName, message.appendOnly);
291 }); 290 });
292 291
293 fetch(browser.extension.getURL("/snippets.js"), {cache: "no-cache"}) 292 fetch(browser.extension.getURL("/snippets.js"), {cache: "no-cache"})
294 .then(response => response.ok ? response.text() : "") 293 .then(response => response.ok ? response.text() : "")
295 .then(text => 294 .then(text =>
296 { 295 {
297 snippetsLibrarySource = text; 296 snippetsLibrarySource = text;
298 }); 297 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld