diff options
| author | Stephen Blott | 2016-02-27 16:05:23 +0000 |
|---|---|---|
| committer | Stephen Blott | 2016-03-05 05:37:40 +0000 |
| commit | 6487c09d98b791b3211679d2f1bf970394a696e6 (patch) | |
| tree | 0af7e0b9aa282e3ee733bb6f477de6cc8d3d5227 | |
| parent | 320dfd5419b4a7e676f8690a87b275b305440dc3 (diff) | |
| download | vimium-6487c09d98b791b3211679d2f1bf970394a696e6.tar.bz2 | |
Key bindings; rewire vomnibar.
| -rw-r--r-- | background_scripts/commands.coffee | 14 | ||||
| -rw-r--r-- | background_scripts/main.coffee | 11 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 10 | ||||
| -rw-r--r-- | content_scripts/vomnibar.coffee | 1 |
4 files changed, 21 insertions, 15 deletions
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index 7e02047c..a62c674e 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -374,13 +374,13 @@ commandDescriptions = moveTabLeft: ["Move tab to the left", { background: true, passCountToFunction: true }] moveTabRight: ["Move tab to the right", { background: true, passCountToFunction: true }] - "Vomnibar.activate": ["Open URL, bookmark, or history entry", { noRepeat: true }] - "Vomnibar.activateInNewTab": ["Open URL, bookmark, history entry, in a new tab", { noRepeat: true }] - "Vomnibar.activateTabSelection": ["Search through your open tabs", { noRepeat: true }] - "Vomnibar.activateBookmarks": ["Open a bookmark", { noRepeat: true }] - "Vomnibar.activateBookmarksInNewTab": ["Open a bookmark in a new tab", { noRepeat: true }] - "Vomnibar.activateEditUrl": ["Edit the current URL", { noRepeat: true }] - "Vomnibar.activateEditUrlInNewTab": ["Edit the current URL and open in a new tab", { noRepeat: true }] + "Vomnibar.activate": ["Open URL, bookmark, or history entry", { background: true, noRepeat: true }] + "Vomnibar.activateInNewTab": ["Open URL, bookmark, history entry, in a new tab", { background: true, noRepeat: true }] + "Vomnibar.activateTabSelection": ["Search through your open tabs", { background: true, noRepeat: true }] + "Vomnibar.activateBookmarks": ["Open a bookmark", { background: true, noRepeat: true }] + "Vomnibar.activateBookmarksInNewTab": ["Open a bookmark in a new tab", { background: true, noRepeat: true }] + "Vomnibar.activateEditUrl": ["Edit the current URL", { background: true, noRepeat: true }] + "Vomnibar.activateEditUrlInNewTab": ["Edit the current URL and open in a new tab", { background: true, noRepeat: true }] nextFrame: ["Cycle forward to the next frame on the page", { background: true, passCountToFunction: true }] mainFrame: ["Select the tab's main/top frame", { background: true, noRepeat: true }] diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 60c161f9..8d2b4248 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -369,7 +369,16 @@ chrome.tabs.onUpdated.addListener (tabId, changeInfo, tab) -> # End action functions -runBackgroundCommand = ({frameId, registryEntry, count}) -> +# Open Vomnibar in tab's main frame. +openVomnibar = (tabId, frameId, registryEntry) -> + chrome.tabs.sendMessage tabId, + name: "openVomnibar" + sourceFrameId: frameId + registryEntry: registryEntry + +runBackgroundCommand = ({frameId, registryEntry, count}, sender) -> + if registryEntry.command.split(".")[0] == "Vomnibar" + openVomnibar sender.tab.id, frameId, registryEntry if registryEntry.passCountToFunction BackgroundCommands[registryEntry.command] count, frameId else if registryEntry.noRepeat diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 0cb402b8..4acac352 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -120,7 +120,6 @@ window.initializeModes = -> You have asked Vimium to perform #{count} repeats of the command: #{registryEntry.description}.\n Are you sure you want to continue? """ - # TODO: Special handling of Vomnibar. if registryEntry.isBackgroundCommand chrome.runtime.sendMessage { handler: "runBackgroundCommand", frameId, registryEntry, count} else @@ -136,6 +135,9 @@ window.initializeModes = -> new InsertMode permanent: true Scroller.init() +openVomnibar = ({sourceFrameId, registryEntry}) -> + Utils.invokeCommandString registryEntry.command, [sourceFrameId, registryEntry] if DomUtils.isTopFrame() + # # Complete initialization work that sould be done prior to DOMReady. # @@ -151,6 +153,7 @@ initializePreDomReady = -> # A frame has received the focus. We don't care here (the Vomnibar/UI-component handles this). frameFocused: -> checkEnabledAfterURLChange: checkEnabledAfterURLChange + openVomnibar: openVomnibar chrome.runtime.onMessage.addListener (request, sender, sendResponse) -> # In the options page, we will receive requests from both content and background scripts. ignore those @@ -162,11 +165,6 @@ initializePreDomReady = -> shouldHandleRequest = isEnabledForUrl # We always handle the message if it's one of these listed message types. shouldHandleRequest ||= request.name in [ "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() - request.frameId = frameId - shouldHandleRequest = true sendResponse requestHandlers[request.name](request, sender) if shouldHandleRequest # Ensure the sendResponse callback is freed. false diff --git a/content_scripts/vomnibar.coffee b/content_scripts/vomnibar.coffee index 55a46777..67a79ff4 100644 --- a/content_scripts/vomnibar.coffee +++ b/content_scripts/vomnibar.coffee @@ -7,7 +7,6 @@ Vomnibar = # Parse any additional options from the command's registry entry. Currently, this only includes a flag of # the form "keyword=X", for direct activation of a custom search engine. parseRegistryEntry: (registryEntry = { options: [] }, callback = null) -> - options = {} searchEngines = Settings.get("searchEngines") ? "" SearchEngines.refreshAndUse searchEngines, (engines) -> callback? registryEntry.options |
