aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel MacDougall2012-04-01 12:50:40 -0700
committerDaniel MacDougall2012-04-01 12:50:40 -0700
commitd9a2b6f8cd2b3992a92d3eaf372e129c9cef408f (patch)
tree896bbe5c9f52bc025aefd529b8afc7539bba5597
parent2c4fef6c24b07d70479e6ae19d24aa0a86b53e8b (diff)
downloadvimium-d9a2b6f8cd2b3992a92d3eaf372e129c9cef408f.tar.bz2
Fix buggy icon update states
This requires not depending on the openTabs array, since the onUpdated event is not always fired when a new page is loaded (from a new tab, for example).
-rw-r--r--background_page.html12
1 files changed, 7 insertions, 5 deletions
diff --git a/background_page.html b/background_page.html
index 8467672e..06662cf7 100644
--- a/background_page.html
+++ b/background_page.html
@@ -352,13 +352,15 @@
* 3. Active tab is enabled but should be disabled -> disable icon and disable vimium
*/
function updateActiveState(tabId) {
- if (openTabs[tabId]) {
+ var enabledIcon = "icons/icon48.png";
+ var disabledIcon = "icons/icon48disabled.png";
+ chrome.tabs.get(tabId, function(tab) {
+ // Default to disabled state in case we can't connect to Vimium, primarily for the "New Tab" page.
+ chrome.browserAction.setIcon({ path: disabledIcon });
var returnPort = chrome.tabs.connect(tabId, { name: "getActiveState" });
returnPort.onMessage.addListener(function(response) {
var isCurrentlyEnabled = response.enabled;
- var shouldBeEnabled = isEnabledForUrl({url: openTabs[tabId].url}).isEnabledForUrl;
- var enabledIcon = "icons/icon48.png";
- var disabledIcon = "icons/icon48disabled.png";
+ var shouldBeEnabled = isEnabledForUrl({url: tab.url}).isEnabledForUrl;
if (isCurrentlyEnabled) {
if (shouldBeEnabled) {
@@ -372,7 +374,7 @@
}
});
returnPort.postMessage();
- }
+ });
}
function handleUpdateScrollPosition(request, sender) {