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

Side by Side Diff: background.js

Issue 5196306347720704: Issue 1965 - Simplified and fixed missing image for icon animation (Closed)
Patch Set: Created March 7, 2014, 5: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 | iconAnimation.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 <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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 if (option in localStorage) 93 if (option in localStorage)
94 delete localStorage[option]; 94 delete localStorage[option];
95 }); 95 });
96 } 96 }
97 97
98 // Remove deprecated options before we do anything else. 98 // Remove deprecated options before we do anything else.
99 removeDeprecatedOptions(); 99 removeDeprecatedOptions();
100 100
101 var activeNotification = null; 101 var activeNotification = null;
102 102
103 // Adds or removes browser action icon according to options. 103 function getTabStatus(tab)
104 {
105 var whitelisted = isWhitelisted(tab.url);
106 var animated = iconAnimation.tabs.has(tab);
107
108 var icon;
109 if (require("info").platform == "safari")
110 // pick an icon with approtiate size for Safari. However since
111 // toolbar item icons can't use different colors, we don't have
112 // different versions indicating whether the page is whitelisted
113 icon = "icons/abp-16";
114 else
115 {
116 // pick an icon with the approtiate size for Chrome/Opera
117 // that indicates whether the page is whitelisted
118 if (whitelisted && (!animated || iconAnimation.step < 10))
119 icon = "icons/abp-19-whitelisted";
120 else
121 icon = "icons/abp-19";
122 }
123
124 // pick the current frame if the icon is currently animating
125 // in order to indicate a pending notification
126 if (animated && iconAnimation.step > 0)
127 {
128 icon += "-notification-" + iconAnimation.severity;
129
130 if (iconAnimation.step < 10)
131 icon += "-" + iconAnimation.step;
132 }
133
134 icon += ".png";
135
136 return {icon: icon, whitelisted: whitelisted};
137 }
138
104 function refreshIconAndContextMenu(tab) 139 function refreshIconAndContextMenu(tab)
105 { 140 {
106 var whitelisted = isWhitelisted(tab.url); 141 var status = getTabStatus(tab);
107 142
108 var iconFilename; 143 // update icon indicating whether the page is whitelisted.
109 if (require("info").platform == "safari") 144 tab.browserAction.setIcon(status.icon);
110 // There is no grayscale version of the icon for whitelisted tabs
111 // when using Safari, because icons are grayscale already and icons
112 // aren't per tab in Safari.
113 iconFilename = "icons/abp-16.png"
114 else
115 iconFilename = whitelisted ? "icons/abp-19-whitelisted.png" : "icons/abp-19. png";
116 145
117 tab.browserAction.setIcon(iconFilename); 146 // show or hide the context menu entry dependent on whether
118 iconAnimation.registerTab(tab, iconFilename); 147 // adblocking is active in that tab
119 148 if (status.whitelisted || !/^https?:/.test(tab.url))
120 // Set context menu status according to whether current tab has whitelisted do main
121 if (whitelisted || !/^https?:/.test(tab.url))
122 ext.contextMenus.hideMenuItems(); 149 ext.contextMenus.hideMenuItems();
123 else 150 else
124 ext.contextMenus.showMenuItems(); 151 ext.contextMenus.showMenuItems();
125 } 152 }
126 153
127 /** 154 /**
128 * Old versions for Opera stored patterns.ini in the localStorage object, this 155 * Old versions for Opera stored patterns.ini in the localStorage object, this
129 * will import it into FilterStorage properly. 156 * will import it into FilterStorage properly.
130 * @return {Boolean} true if data import is in progress 157 * @return {Boolean} true if data import is in progress
131 */ 158 */
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 tab.sendMessage({type: "clickhide-deactivate"}); 523 tab.sendMessage({type: "clickhide-deactivate"});
497 refreshIconAndContextMenu(tab); 524 refreshIconAndContextMenu(tab);
498 }); 525 });
499 526
500 setTimeout(function() 527 setTimeout(function()
501 { 528 {
502 var notificationToShow = Notification.getNextToShow(); 529 var notificationToShow = Notification.getNextToShow();
503 if (notificationToShow) 530 if (notificationToShow)
504 showNotification(notificationToShow); 531 showNotification(notificationToShow);
505 }, 3 * 60 * 1000); 532 }, 3 * 60 * 1000);
OLDNEW
« no previous file with comments | « no previous file | iconAnimation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld