diff options
| author | Stephen Blott | 2015-04-25 09:47:49 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-04-25 10:12:42 +0100 |
| commit | 7b3b3b4b7e9b9b39cf583e857c4f384a4fff7fb1 (patch) | |
| tree | aed331da03230c14ce50b1ecfbe1f5cfeb05131d | |
| parent | b1c27ca32fd3aa365990b959f22888c1d8d802ca (diff) | |
| download | vimium-7b3b3b4b7e9b9b39cf583e857c4f384a4fff7fb1.tar.bz2 | |
Remove requirement for Chrome 41.
| -rw-r--r-- | background_scripts/main.coffee | 10 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 48 | ||||
| -rw-r--r-- | manifest.json | 1 |
3 files changed, 29 insertions, 30 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 6fac032c..f11b3b4a 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -96,14 +96,12 @@ root.isEnabledForUrl = isEnabledForUrl = (request) -> passKeys: rule?.passKeys or "" } -isEnabledForUpdatedUrl = (details) -> - message = isEnabledForUrl details - message.name = "updateEnabledForUrlState" - chrome.tabs.sendMessage details.tabId, message, {frameId: details.frameId} +onURLChange = (details) -> + chrome.tabs.sendMessage details.tabId, name: "checkEnabledAfterURLChange" # Re-check whether Vimium is enabled for a frame when the url changes without a reload. -chrome.webNavigation.onHistoryStateUpdated.addListener isEnabledForUpdatedUrl # history.pushState. -chrome.webNavigation.onReferenceFragmentUpdated.addListener isEnabledForUpdatedUrl # Hash changed. +chrome.webNavigation.onHistoryStateUpdated.addListener onURLChange # history.pushState. +chrome.webNavigation.onReferenceFragmentUpdated.addListener onURLChange # Hash changed. # Retrieves the help dialog HTML template from a file, and populates it with the latest keybindings. # This is called by options.coffee. diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index c41ca62f..2b90fe95 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -189,7 +189,7 @@ initializePreDomReady = -> handlerStack.bubbleEvent "registerKeyQueue", { keyQueue: keyQueue } # A frame has received the focus. We don't care here (the Vomnibar/UI-component handles this). frameFocused: -> - updateEnabledForUrlState: updateEnabledForUrlState + checkEnabledAfterURLChange: checkEnabledAfterURLChange chrome.runtime.onMessage.addListener (request, sender, sendResponse) -> # In the options page, we will receive requests from both content and background scripts. ignore those @@ -199,7 +199,7 @@ initializePreDomReady = -> return if request.handler in [ "registerFrame", "frameFocused", "unregisterFrame" ] shouldHandleRequest = isEnabledForUrl # We always handle the message if it's one of these listed message types. - shouldHandleRequest ||= request.name in [ "executePageCommand", "updateEnabledForUrlState" ] + shouldHandleRequest ||= request.name in [ "executePageCommand", "checkEnabledAfterURLChange" ] # Requests with a frameId of zero should always and only be handled in the main/top frame (regardless of # whether Vimium is enabled there). if request.frameId == 0 and DomUtils.isTopFrame() @@ -587,27 +587,29 @@ onKeyup = (event) -> checkIfEnabledForUrl = -> url = window.location.toString() - chrome.runtime.sendMessage { handler: "isEnabledForUrl", url: url }, updateEnabledForUrlState - -updateEnabledForUrlState = (response) -> - { isEnabledForUrl, passKeys } = response - installListeners() - if HUD.isReady() and not isEnabledForUrl - # Quickly hide any HUD we might already be showing, e.g. if we entered insert mode on page load. - HUD.hide() - handlerStack.bubbleEvent "registerStateChange", - enabled: isEnabledForUrl - passKeys: passKeys - # Update the page icon, if necessary. - if document.hasFocus() - chrome.runtime.sendMessage - handler: "setIcon" - icon: - if isEnabledForUrl and not passKeys then "enabled" - else if isEnabledForUrl then "partial" - else "disabled" - null - + chrome.runtime.sendMessage { handler: "isEnabledForUrl", url: url }, (response) -> + { isEnabledForUrl, passKeys } = response + installListeners() # But only if they have not been installed already. + if HUD.isReady() and not isEnabledForUrl + # Quickly hide any HUD we might already be showing, e.g. if we entered insert mode on page load. + HUD.hide() + handlerStack.bubbleEvent "registerStateChange", + enabled: isEnabledForUrl + passKeys: passKeys + # Update the page icon, if necessary. + if windowIsFocused() + chrome.runtime.sendMessage + handler: "setIcon" + icon: + if isEnabledForUrl and not passKeys then "enabled" + else if isEnabledForUrl then "partial" + else "disabled" + null + +# When we're informed by the background page that a URL in this tab has changed, we check if we have the +# correct enabled state (but only if this frame has the focus). +checkEnabledAfterURLChange = -> + checkIfEnabledForUrl() if windowIsFocused() # Exported to window, but only for DOM tests. window.refreshCompletionKeys = (response) -> diff --git a/manifest.json b/manifest.json index f0c297c2..e8e51407 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,6 @@ "manifest_version": 2, "name": "Vimium", "version": "1.49", - "minimum_chrome_version": "41", "description": "The Hacker's Browser. Vimium provides keyboard shortcuts for navigation and control in the spirit of Vim.", "icons": { "16": "icons/icon16.png", "48": "icons/icon48.png", |
