| Index: background.js | 
| =================================================================== | 
| --- a/background.js | 
| +++ b/background.js | 
| @@ -100,25 +100,52 @@ | 
|  | 
| var activeNotification = null; | 
|  | 
| -// Adds or removes browser action icon according to options. | 
| +function getTabStatus(tab) | 
| +{ | 
| +  var whitelisted = isWhitelisted(tab.url); | 
| +  var animated = iconAnimation.tabs.has(tab); | 
| + | 
| +  var icon; | 
| +  if (require("info").platform == "safari") | 
| +    // pick an icon with approtiate size for Safari. However since | 
| +    // toolbar item icons can't use different colors, we don't have | 
| +    // different versions indicating whether the page is whitelisted | 
| +    icon = "icons/abp-16"; | 
| +  else | 
| +  { | 
| +    // pick an icon with the approtiate size for Chrome/Opera | 
| +    // that indicates whether the page is whitelisted | 
| +    if (whitelisted && (!animated || iconAnimation.step < 10)) | 
| +      icon = "icons/abp-19-whitelisted"; | 
| +    else | 
| +      icon = "icons/abp-19"; | 
| +  } | 
| + | 
| +  // pick the current frame if the icon is currently animating | 
| +  // in order to indicate a pending notification | 
| +  if (animated && iconAnimation.step > 0) | 
| +  { | 
| +    icon += "-notification-" + iconAnimation.severity; | 
| + | 
| +    if (iconAnimation.step < 10) | 
| +      icon += "-" + iconAnimation.step; | 
| +  } | 
| + | 
| +  icon += ".png"; | 
| + | 
| +  return {icon: icon, whitelisted: whitelisted}; | 
| +} | 
| + | 
| function refreshIconAndContextMenu(tab) | 
| { | 
| -  var whitelisted = isWhitelisted(tab.url); | 
| +  var status = getTabStatus(tab); | 
|  | 
| -  var iconFilename; | 
| -  if (require("info").platform == "safari") | 
| -    // There is no grayscale version of the icon for whitelisted tabs | 
| -    // when using Safari, because icons are grayscale already and icons | 
| -    // aren't per tab in Safari. | 
| -    iconFilename = "icons/abp-16.png" | 
| -  else | 
| -    iconFilename = whitelisted ? "icons/abp-19-whitelisted.png" : "icons/abp-19.png"; | 
| +  // update icon indicating whether the page is whitelisted. | 
| +  tab.browserAction.setIcon(status.icon); | 
|  | 
| -  tab.browserAction.setIcon(iconFilename); | 
| -  iconAnimation.registerTab(tab, iconFilename); | 
| - | 
| -  // Set context menu status according to whether current tab has whitelisted domain | 
| -  if (whitelisted || !/^https?:/.test(tab.url)) | 
| +  // show or hide the context menu entry dependent on whether | 
| +  // adblocking is active in that tab | 
| +  if (status.whitelisted || !/^https?:/.test(tab.url)) | 
| ext.contextMenus.hideMenuItems(); | 
| else | 
| ext.contextMenus.showMenuItems(); | 
|  |