aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
authorStephen Blott2014-12-31 20:52:27 +0000
committerStephen Blott2015-01-01 09:37:20 +0000
commitacefe43cef5a216cb2504e85799699c359b6b4d8 (patch)
tree280e4d312cab11eb3b825b1fde73fc0654955e82 /background_scripts
parentf2b428b4fe1eecd66ee95513da779470f7c621aa (diff)
downloadvimium-acefe43cef5a216cb2504e85799699c359b6b4d8.tar.bz2
Modes; incorporate three test modes.
As a proof of concept, this incorporates normal mode, passkeys mode and insert mode.
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/main.coffee10
1 files changed, 10 insertions, 0 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index 4c1b9ae7..7d7359b8 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -339,6 +339,13 @@ updateOpenTabs = (tab) ->
setBrowserActionIcon = (tabId,path) ->
chrome.browserAction.setIcon({ tabId: tabId, path: path })
+# This color should match the blue of the Vimium browser popup (although it looks a little darker, to me?).
+chrome.browserAction.setBadgeBackgroundColor {color: [102, 176, 226, 255]}
+
+setBadge = (response) ->
+ badge = response?.badge || ""
+ chrome.browserAction.setBadgeText {text: badge}
+
# Updates the browserAction icon to indicate whether Vimium is enabled or disabled on the current page.
# Also propagates new enabled/disabled/passkeys state to active window, if necessary.
# This lets you disable Vimium on a page without needing to reload.
@@ -349,6 +356,7 @@ root.updateActiveState = updateActiveState = (tabId) ->
partialIcon = "icons/browser_action_partial.png"
chrome.tabs.get tabId, (tab) ->
chrome.tabs.sendMessage tabId, { name: "getActiveState" }, (response) ->
+ setBadge response
if response
isCurrentlyEnabled = response.enabled
currentPasskeys = response.passKeys
@@ -602,6 +610,7 @@ unregisterFrame = (request, sender) ->
frameIdsForTab[tabId] = frameIdsForTab[tabId].filter (id) -> id != request.frameId
handleFrameFocused = (request, sender) ->
+ setBadge request
tabId = sender.tab.id
if frameIdsForTab[tabId]?
frameIdsForTab[tabId] =
@@ -633,6 +642,7 @@ sendRequestHandlers =
refreshCompleter: refreshCompleter
createMark: Marks.create.bind(Marks)
gotoMark: Marks.goto.bind(Marks)
+ setBadge: setBadge
# Convenience function for development use.
window.runTests = -> open(chrome.runtime.getURL('tests/dom_tests/dom_tests.html'))