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

Side by Side Diff: lib/stats.js

Issue 29737602: Issue 4580 - Make filter/request logging use plain tabIds, prepare for multi-tab requests (Closed)
Patch Set: Removed outdated comment Created April 4, 2018, 1:48 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/requestBlocker.js ('k') | lib/whitelisting.js » ('j') | 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-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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 let page = new ext.Page({id: details.tabId}); 46 let page = new ext.Page({id: details.tabId});
47 let blocked = blockedPerPage.get(page); 47 let blocked = blockedPerPage.get(page);
48 48
49 page.browserAction.setBadge(blocked && { 49 page.browserAction.setBadge(blocked && {
50 color: badgeColor, 50 color: badgeColor,
51 number: blocked 51 number: blocked
52 }); 52 });
53 } 53 }
54 }); 54 });
55 55
56 FilterNotifier.on("filter.hitCount", (filter, newValue, oldValue, page) => 56 FilterNotifier.on("filter.hitCount", (filter, newValue, oldValue, tabIds) =>
57 { 57 {
58 if (!(filter instanceof BlockingFilter) || !page) 58 if (!(filter instanceof BlockingFilter))
59 return; 59 return;
60 60
61 for (let tabId of tabIds)
62 {
63 let page = new ext.Page({id: tabId});
64 let blocked = blockedPerPage.get(page) || 0;
65 blockedPerPage.set(page, ++blocked);
66
67 // Update number in icon
68 if (Prefs.show_statsinicon)
69 {
70 page.browserAction.setBadge({
71 color: badgeColor,
72 number: blocked
73 });
74 }
75 }
76
61 Prefs.blocked_total++; 77 Prefs.blocked_total++;
62
63 let blocked = blockedPerPage.get(page) || 0;
64 blockedPerPage.set(page, ++blocked);
65
66 // Update number in icon
67 if (Prefs.show_statsinicon)
68 {
69 page.browserAction.setBadge({
70 color: badgeColor,
71 number: blocked
72 });
73 }
74 }); 78 });
75 79
76 Prefs.on("show_statsinicon", () => 80 Prefs.on("show_statsinicon", () =>
77 { 81 {
78 browser.tabs.query({}, tabs => 82 browser.tabs.query({}, tabs =>
79 { 83 {
80 for (let tab of tabs) 84 for (let tab of tabs)
81 { 85 {
82 let page = new ext.Page(tab); 86 let page = new ext.Page(tab);
83 let badge = null; 87 let badge = null;
(...skipping 10 matching lines...) Expand all
94 } 98 }
95 } 99 }
96 100
97 page.browserAction.setBadge(badge); 101 page.browserAction.setBadge(badge);
98 } 102 }
99 }); 103 });
100 }); 104 });
101 105
102 port.on("stats.getBlockedPerPage", 106 port.on("stats.getBlockedPerPage",
103 message => getBlockedPerPage(new ext.Page(message.tab))); 107 message => getBlockedPerPage(new ext.Page(message.tab)));
OLDNEW
« no previous file with comments | « lib/requestBlocker.js ('k') | lib/whitelisting.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld