aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2016-03-05 08:41:43 +0000
committerStephen Blott2016-03-05 08:41:45 +0000
commitb883af74450faf3683b8077d6ba09864f5632b26 (patch)
treea0148f4aa71bbea69dd7c0db7f138a695cc20c07
parentfbf7791894cb2708774e8870f623a8211e3a0790 (diff)
downloadvimium-b883af74450faf3683b8077d6ba09864f5632b26.tar.bz2
Generalise topFrame commands.
This generalises the mechanism by which commands are always run in the tab's main/top frame. Currently, that's just the Vomnibar. This is a precursor to moving other UI components to the main/top frame. It should be fairly trivial to move the help page to the main frame. The HUD might be trickier. Mention: @mrmr1993.
-rw-r--r--background_scripts/commands.coffee14
-rw-r--r--content_scripts/vimium_frontend.coffee7
2 files changed, 10 insertions, 11 deletions
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee
index c13a09ba..55cb60d2 100644
--- a/background_scripts/commands.coffee
+++ b/background_scripts/commands.coffee
@@ -376,13 +376,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", { topFrame: true }]
+ "Vomnibar.activateInNewTab": ["Open URL, bookmark, history entry, in a new tab", { topFrame: true }]
+ "Vomnibar.activateTabSelection": ["Search through your open tabs", { topFrame: true }]
+ "Vomnibar.activateBookmarks": ["Open a bookmark", { topFrame: true }]
+ "Vomnibar.activateBookmarksInNewTab": ["Open a bookmark in a new tab", { topFrame: true }]
+ "Vomnibar.activateEditUrl": ["Edit the current URL", { topFrame: true }]
+ "Vomnibar.activateEditUrlInNewTab": ["Edit the current URL and open in a new tab", { topFrame: 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/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index 71535b19..972911c5 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -116,10 +116,9 @@ class NormalMode extends KeyHandlerMode
You have asked Vimium to perform #{count} repetitions of the command: #{registryEntry.description}.\n
Are you sure you want to continue?"""
- # The Vomnibar needs special handling because it is always activated in the tab's main frame.
- if registryEntry.command.startsWith "Vomnibar."
+ if registryEntry.topFrame
chrome.runtime.sendMessage
- handler: "sendMessageToFrames", message: {name: "openVomnibar", sourceFrameId: frameId, registryEntry}
+ handler: "sendMessageToFrames", message: {name: "runInTopFrame", sourceFrameId: frameId, registryEntry}
else if registryEntry.background
chrome.runtime.sendMessage {handler: "runBackgroundCommand", frameId, registryEntry, count}
else if registryEntry.passCountToFunction
@@ -150,7 +149,7 @@ initializePreDomReady = ->
# A frame has received the focus. We don't care here (the Vomnibar/UI-component handles this).
frameFocused: ->
checkEnabledAfterURLChange: checkEnabledAfterURLChange
- openVomnibar: ({sourceFrameId, registryEntry}) ->
+ runInTopFrame: ({sourceFrameId, registryEntry}) ->
Utils.invokeCommandString registryEntry.command, [sourceFrameId, registryEntry] if DomUtils.isTopFrame()
chrome.runtime.onMessage.addListener (request, sender, sendResponse) ->