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

Unified Diff: lib/stats.js

Issue 29680693: [$csp3 adblockpluschrome] Issue 5241 - Avoid setting badge text before navigation is committed (Closed)
Patch Set: Created Jan. 26, 2018, 6:03 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/stats.js
diff --git a/lib/stats.js b/lib/stats.js
index f64c2cee9f5835610f8e08da253473a32ea9c895..24aef8a407dcba7a56e483735a7cedf1bb93269f 100644
--- a/lib/stats.js
+++ b/lib/stats.js
@@ -93,3 +93,21 @@ Prefs.on("show_statsinicon", () =>
port.on("stats.getBlockedPerPage",
message => getBlockedPerPage(new ext.Page(message.tab)));
+
+// We sometimes set the badge text before Chrome considers the tab to have been
+// updated. In those cases Chrome automatically clears the text again, so the
+// blocked count will only flash for a second. To work around that we wait for
+// the navigation to be committed and then update the text again.
+browser.webNavigation.onCommitted.addListener(details =>
+{
+ let page = new ext.Page({id: details.tabId});
+ let blocked = blockedPerPage.get(page);
+
+ if (blocked)
+ {
+ page.browserAction.setBadge({
+ color: badgeColor,
+ number: blocked
+ });
+ }
+});
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld