From 2d92b45b28146e1ea46f87038827027ce1e00b51 Mon Sep 17 00:00:00 2001 From: Daniel MacDougall Date: Wed, 28 Mar 2012 02:01:24 -0700 Subject: Add browser icon that displays enabled/disabled state --- background_page.html | 13 +++++++++++++ icons/icon48.png | Bin 4222 -> 4254 bytes icons/icon48disabled.png | Bin 0 -> 3648 bytes manifest.json | 5 ++++- 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 icons/icon48disabled.png diff --git a/background_page.html b/background_page.html index aed9617b..881024c3 100644 --- a/background_page.html +++ b/background_page.html @@ -332,6 +332,14 @@ delete framesForTab[tab.id]; } + function updateIconState(tabId) { + if (openTabs[tabId]) { + var isEnabled = isEnabledForUrl({url: openTabs[tabId].url}).isEnabledForUrl; + var iconPath = isEnabled ? "icons/icon48.png" : "icons/icon48disabled.png"; + chrome.browserAction.setIcon({path: iconPath}); + } + } + function handleUpdateScrollPosition(request, sender) { updateScrollPosition(sender.tab, request.scrollX, request.scrollY); } @@ -345,6 +353,7 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { if (changeInfo.status != "loading") { return; } // only do this once per URL change updateOpenTabs(tab); + updateIconState(tabId); }); chrome.tabs.onAttached.addListener(function(tabId, attachedInfo) { @@ -383,6 +392,10 @@ delete framesForTab[tabId]; }); + chrome.tabs.onActiveChanged.addListener(function(tabId, selectInfo) { + updateIconState(tabId); + }); + chrome.windows.onRemoved.addListener(function(windowId) { delete tabQueue[windowId]; }); diff --git a/icons/icon48.png b/icons/icon48.png index 6a3202f0..9eb94d4f 100644 Binary files a/icons/icon48.png and b/icons/icon48.png differ diff --git a/icons/icon48disabled.png b/icons/icon48disabled.png new file mode 100644 index 00000000..fa6279d3 Binary files /dev/null and b/icons/icon48disabled.png differ diff --git a/manifest.json b/manifest.json index 085caaed..31b9e976 100644 --- a/manifest.json +++ b/manifest.json @@ -29,5 +29,8 @@ "run_at": "document_start", "all_frames": true } - ] + ], + "browser_action": { + "default_icon": "icons/icon48disabled.png" + } } -- cgit v1.2.3