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

Side by Side Diff: lib/stats.js

Issue 29532772: Issue 5588 - Clear badge text only if zero hits (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created Aug. 31, 2017, 5:46 p.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 | « no previous file | 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-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 21 matching lines...) Expand all
32 * @param {Page} page 32 * @param {Page} page
33 * @return {Number} 33 * @return {Number}
34 */ 34 */
35 exports.getBlockedPerPage = page => blockedPerPage.get(page) || 0; 35 exports.getBlockedPerPage = page => blockedPerPage.get(page) || 0;
36 36
37 // Chrome automatically clears the browser action badge text when the URL of 37 // Chrome automatically clears the browser action badge text when the URL of
38 // the tab is updated, but Firefox doesn't. 38 // the tab is updated, but Firefox doesn't.
39 // https://bugzilla.mozilla.org/show_bug.cgi?id=1395074 39 // https://bugzilla.mozilla.org/show_bug.cgi?id=1395074
40 ext.pages.onLoading.addListener(page => 40 ext.pages.onLoading.addListener(page =>
41 { 41 {
42 page.browserAction.setBadge(); 42 if (!blockedPerPage.get(page))
43 page.browserAction.setBadge();
43 }); 44 });
44 45
45 FilterNotifier.on("filter.hitCount", (filter, newValue, oldValue, page) => 46 FilterNotifier.on("filter.hitCount", (filter, newValue, oldValue, page) =>
46 { 47 {
47 if (!(filter instanceof BlockingFilter) || !page) 48 if (!(filter instanceof BlockingFilter) || !page)
48 return; 49 return;
49 50
50 Prefs.blocked_total++; 51 Prefs.blocked_total++;
51 52
52 let blocked = blockedPerPage.get(page) || 0; 53 let blocked = blockedPerPage.get(page) || 0;
(...skipping 26 matching lines...) Expand all
79 color: badgeColor, 80 color: badgeColor,
80 number: blocked 81 number: blocked
81 }; 82 };
82 } 83 }
83 } 84 }
84 85
85 page.browserAction.setBadge(badge); 86 page.browserAction.setBadge(badge);
86 } 87 }
87 }); 88 });
88 }); 89 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld