From b883af74450faf3683b8077d6ba09864f5632b26 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 5 Mar 2016 08:41:43 +0000 Subject: 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. --- content_scripts/vimium_frontend.coffee | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'content_scripts') 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) -> -- cgit v1.2.3