diff options
| author | Stephen Blott | 2015-05-31 09:52:50 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-05-31 09:52:50 +0100 |
| commit | bd07321766056cccd083aa69254abc8146bd5266 (patch) | |
| tree | 59a9300cd4a0806f2f6072db406e00edf80674b4 /content_scripts | |
| parent | 8b0c610fb68573dbd839133fbc315521db6161f6 (diff) | |
| parent | 5930a6e3510f2bd052771601581aa410728d68e3 (diff) | |
| download | vimium-bd07321766056cccd083aa69254abc8146bd5266.tar.bz2 | |
Merge pull request #1697 from smblott-github/vomnibar-map-with-prepopulated-text
Direct keyboard access to custom-search engines via keyword flag
Diffstat (limited to 'content_scripts')
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 5 | ||||
| -rw-r--r-- | content_scripts/vomnibar.coffee | 34 |
2 files changed, 31 insertions, 8 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index b7acf433..c8c83029 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -62,6 +62,7 @@ settings = helpDialog_showAdvancedCommands: null smoothScroll: null grabBackFocus: null + searchEngines: null init: -> @port = chrome.runtime.connect name: "settings" @@ -307,14 +308,14 @@ executePageCommand = (request) -> if DomUtils.isTopFrame() # We pass the frameId from request. That's the frame which originated the request, so that's the frame # which should receive the focus when the vomnibar closes. - Utils.invokeCommandString request.command, [ request.frameId ] + Utils.invokeCommandString request.command, [ request.frameId, request.registryEntry ] refreshCompletionKeys request return # All other commands are handled in their frame (but only if Vimium is enabled). return unless frameId == request.frameId and isEnabledForUrl - if (request.passCountToFunction) + if request.registryEntry.passCountToFunction Utils.invokeCommandString(request.command, [request.count]) else Utils.invokeCommandString(request.command) for i in [0...request.count] diff --git a/content_scripts/vomnibar.coffee b/content_scripts/vomnibar.coffee index 2529c077..4bd8e8fd 100644 --- a/content_scripts/vomnibar.coffee +++ b/content_scripts/vomnibar.coffee @@ -4,14 +4,36 @@ Vomnibar = vomnibarUI: null + # 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) -> + for option in registryEntry.options + [ key, value ] = option.split "=" + switch key + when "keyword" + if value? and engines[value]? + options.keyword = value + else + console.log "Vimium configuration error: no such custom search engine: #{option}." + else + console.log "Vimium configuration error: unused flag: #{option}." + + callback? options + # sourceFrameId here (and below) is the ID of the frame from which this request originates, which may be different # from the current frame. - activate: (sourceFrameId) -> @open sourceFrameId, {completer:"omni"} - activateInNewTab: (sourceFrameId) -> @open sourceFrameId, { - completer: "omni" - selectFirst: false - newTab: true - } + + activate: (sourceFrameId, registryEntry) -> + @parseRegistryEntry registryEntry, (options) => + @open sourceFrameId, extend options, completer:"omni" + + activateInNewTab: (sourceFrameId, registryEntry) -> + @parseRegistryEntry registryEntry, (options) => + @open sourceFrameId, extend options, completer:"omni", newTab: true + activateTabSelection: (sourceFrameId) -> @open sourceFrameId, { completer: "tabs" selectFirst: true |
