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

Delta Between Two Patch Sets: lib/stats.js

Issue 29317001: Relocated icon and redesigned icon popup (Closed)
Left Patch Set: Created Dec. 11, 2013, 1:08 p.m.
Right Patch Set: Merged setBadgeNumber and setBadgeBackgroundColor Created Dec. 13, 2013, 10:36 a.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 | « lib/prefs.js ('k') | metadata.chrome » ('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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 { 61 {
62 if ("blocked" in frameData) 62 if ("blocked" in frameData)
63 frameData.blocked++; 63 frameData.blocked++;
64 else 64 else
65 frameData.blocked = 1; 65 frameData.blocked = 1;
66 } 66 }
67 67
68 // Update number in icon 68 // Update number in icon
69 if (Prefs.show_statsinicon) 69 if (Prefs.show_statsinicon)
70 { 70 {
71 tab.browserAction.setBadgeBackgroundColor(badgeColor); 71 tab.browserAction.setBadge({
72 tab.browserAction.setBadgeNumber(frameData.blocked); 72 color: badgeColor,
73 number: frameData.blocked
74 });
73 } 75 }
74 } 76 }
75 }); 77 });
76 78
77 /** 79 /**
78 * Execute function for each tab in any window 80 * Execute function for each tab in any window
79 * @param {Function} func function to be executed 81 * @param {Function} func function to be executed
Felix Dahlke 2013/12/13 13:57:20 s/ / / s'il vous plaît.
80 */ 82 */
81 function forEachTab(func) 83 function forEachTab(func)
82 { 84 {
83 ext.windows.getAll(function(windows) 85 ext.windows.getAll(function(windows)
84 { 86 {
85 for each (let window in windows) 87 for each (let window in windows)
86 { 88 {
87 window.getAllTabs(function(tabs) 89 window.getAllTabs(function(tabs)
88 { 90 {
89 for (let i = 0; i < tabs.length; i++) 91 for (let i = 0; i < tabs.length; i++)
90 func(tabs[i]); 92 func(tabs[i]);
91 }); 93 });
92 } 94 }
93 }); 95 });
94 } 96 }
95 97
96 Prefs.addListener(function(name) 98 Prefs.addListener(function(name)
97 { 99 {
98 if (name != "show_statsinicon") 100 if (name != "show_statsinicon")
99 return; 101 return;
100 102
101 forEachTab(function(tab) 103 forEachTab(function(tab)
102 { 104 {
103 let badgeNumber = null; 105 let badge = null;
104 if (Prefs.show_statsinicon) 106 if (Prefs.show_statsinicon)
105 { 107 {
106 let frameData = getFrameData(tab, 0); 108 let frameData = getFrameData(tab, 0);
107 if (frameData && "blocked" in frameData) 109 if (frameData && "blocked" in frameData)
108 { 110 {
109 badgeNumber = frameData.blocked; 111 badge = {
110 tab.browserAction.setBadgeBackgroundColor(badgeColor); 112 color: badgeColor,
113 number: frameData.blocked
114 };
111 } 115 }
112 } 116 }
113 tab.browserAction.setBadgeNumber(badgeNumber); 117 tab.browserAction.setBadge(badge);
114 }); 118 });
115 }); 119 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld