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

Side by Side Diff: lib/stats.js

Issue 29721684: Issue 5241 - Don't update the badge text again for frame navigations (Closed)
Patch Set: Created March 13, 2018, 3:28 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 23 matching lines...) Expand all
34 * @param {Page} page 34 * @param {Page} page
35 * @return {Number} 35 * @return {Number}
36 */ 36 */
37 exports.getBlockedPerPage = page => blockedPerPage.get(page) || 0; 37 exports.getBlockedPerPage = page => blockedPerPage.get(page) || 0;
38 38
39 // Once nagivation for the tab has been committed to (e.g. it's no longer 39 // Once nagivation for the tab has been committed to (e.g. it's no longer
40 // being prerendered) we clear its badge, or if some requests were already 40 // being prerendered) we clear its badge, or if some requests were already
41 // blocked beforehand we display those on the badge now. 41 // blocked beforehand we display those on the badge now.
42 browser.webNavigation.onCommitted.addListener(details => 42 browser.webNavigation.onCommitted.addListener(details =>
43 { 43 {
44 let page = new ext.Page({id: details.tabId}); 44 if (details.frameId == 0)
45 let blocked = blockedPerPage.get(page); 45 {
46 let page = new ext.Page({id: details.tabId});
47 let blocked = blockedPerPage.get(page);
46 48
47 page.browserAction.setBadge(blocked && { 49 page.browserAction.setBadge(blocked && {
48 color: badgeColor, 50 color: badgeColor,
49 number: blocked 51 number: blocked
50 }); 52 });
53 }
51 }); 54 });
52 55
53 FilterNotifier.on("filter.hitCount", (filter, newValue, oldValue, page) => 56 FilterNotifier.on("filter.hitCount", (filter, newValue, oldValue, page) =>
54 { 57 {
55 if (!(filter instanceof BlockingFilter) || !page) 58 if (!(filter instanceof BlockingFilter) || !page)
56 return; 59 return;
57 60
58 Prefs.blocked_total++; 61 Prefs.blocked_total++;
59 62
60 let blocked = blockedPerPage.get(page) || 0; 63 let blocked = blockedPerPage.get(page) || 0;
(...skipping 30 matching lines...) Expand all
91 } 94 }
92 } 95 }
93 96
94 page.browserAction.setBadge(badge); 97 page.browserAction.setBadge(badge);
95 } 98 }
96 }); 99 });
97 }); 100 });
98 101
99 port.on("stats.getBlockedPerPage", 102 port.on("stats.getBlockedPerPage",
100 message => getBlockedPerPage(new ext.Page(message.tab))); 103 message => getBlockedPerPage(new ext.Page(message.tab)));
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