aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2014-11-02 13:27:41 +0000
committerStephen Blott2014-11-02 13:27:41 +0000
commit01608ce7047e3ff0e53c44842697dded489a60f0 (patch)
treecfe6fd39fe8e1a37baec39137d49244d7aeb9637
parent01d9e2021c2520630185f5346d4b4c92c5564ba8 (diff)
parent7e51e97faa4bc407ec411dd47572b1e36ad2be1e (diff)
downloadvimium-01608ce7047e3ff0e53c44842697dded489a60f0.tar.bz2
Merge branch 'master' into customNewTabPage
-rw-r--r--background_scripts/main.coffee7
-rw-r--r--content_scripts/vimium_frontend.coffee16
2 files changed, 7 insertions, 16 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index 5c5d3180..b40907fb 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -393,10 +393,9 @@ chrome.tabs.onUpdated.addListener (tabId, changeInfo, tab) ->
allFrames: true
code: Settings.get("userDefinedLinkHintCss")
runAt: "document_start"
- chrome.tabs.insertCSS tabId, cssConf, ->
- if not chrome.runtime.lastError
- updateOpenTabs(tab)
- updateActiveState(tabId)
+ chrome.tabs.insertCSS tabId, cssConf, -> chrome.runtime.lastError
+ updateOpenTabs(tab)
+ updateActiveState(tabId)
chrome.tabs.onAttached.addListener (tabId, attachedInfo) ->
# We should update all the tabs in the old window and the new window.
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index 8f4c0f2a..118f985e 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -135,8 +135,6 @@ initializePreDomReady = ->
# Ensure the sendResponse callback is freed.
false
- installEventListeners()
-
# Wrapper to install event listeners. Syntactic sugar.
installListener = (element, event, callback) ->
element.addEventListener(event, ->
@@ -144,20 +142,14 @@ installListener = (element, event, callback) ->
, true)
#
-# This is called once the background page has told us that Vimium should be enabled for the current URL.
-# We enable/disable Vimium by toggling isEnabledForUrl.
-#
-initializeWhenEnabled = (newPassKeys) ->
- isEnabledForUrl = true
- passKeys = newPassKeys
-
-#
# Installing or uninstalling listeners is error prone. Instead we elect to check isEnabledForUrl each time so
# we know whether the listener should run or not.
# Run this as early as possible, so the page can't register any event handlers before us.
#
installedListeners = false
-installEventListeners = ->
+initializeWhenEnabled = (newPassKeys) ->
+ isEnabledForUrl = true
+ passKeys = newPassKeys
if (!installedListeners)
# Key event handlers fire on window before they do on document. Prefer window for key events so the page
# can't set handlers to grab the keys before us.
@@ -171,9 +163,9 @@ installEventListeners = ->
installedListeners = true
setState = (request) ->
+ initializeWhenEnabled(request.passKeys) if request.enabled
isEnabledForUrl = request.enabled
passKeys = request.passKeys
- initializeWhenEnabled(passKeys) if isEnabledForUrl
#
# The backend needs to know which frame has focus.