From 847f86f947bd86a0f495653f538c73ed19b29d79 Mon Sep 17 00:00:00 2001 From: Deathamns Date: Fri, 26 Dec 2014 21:41:44 +0100 Subject: [PATCH] Make vAPI.setIcon less Chromium specific --- platform/chromium/vapi-background.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index b63fa19..d8d39e1 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -245,7 +245,7 @@ vAPI.tabs.injectScript = function(tabId, details, callback) { // Since we may be called asynchronously, the tab id may not exist // anymore, so this ensures it does still exist. -vAPI.setIcon = function(tabId, img, badge) { +vAPI.setIcon = function(tabId, iconStatus, badge) { tabId = parseInt(tabId, 10); var onIconReady = function() { if ( vAPI.lastError() ) { @@ -253,10 +253,18 @@ vAPI.setIcon = function(tabId, img, badge) { } chrome.browserAction.setBadgeText({ tabId: tabId, text: badge }); if ( badge !== '' ) { - chrome.browserAction.setBadgeBackgroundColor({ tabId: tabId, color: '#666' }); + chrome.browserAction.setBadgeBackgroundColor({ + tabId: tabId, + color: '#666' + }); } }; - chrome.browserAction.setIcon({ tabId: tabId, path: img }, onIconReady); + + var iconPaths = iconStatus === 'on' ? + { '19': 'img/browsericons/icon19.png', '38': 'img/browsericons/icon38.png' } : + { '19': 'img/browsericons/icon19-off.png', '38': 'img/browsericons/icon38-off.png' }; + + chrome.browserAction.setIcon({ tabId: tabId, path: iconPaths }, onIconReady); }; /******************************************************************************/