aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/completion_engines.coffee
diff options
context:
space:
mode:
authorStephen Blott2015-05-08 14:02:21 +0100
committerStephen Blott2015-05-08 14:15:21 +0100
commitb882213019792a7fb47352a920a54d468d352c86 (patch)
tree3d74271999b209af9a0c015434e40e2d3be452b6 /background_scripts/completion_engines.coffee
parent44378220093ee5bd873b553f5be556921c778663 (diff)
downloadvimium-b882213019792a7fb47352a920a54d468d352c86.tar.bz2
Search completion; exclusivity.
If we have a custom search engine with a completer, then exclude suggestions from other completion engines.
Diffstat (limited to 'background_scripts/completion_engines.coffee')
-rw-r--r--background_scripts/completion_engines.coffee7
1 files changed, 6 insertions, 1 deletions
diff --git a/background_scripts/completion_engines.coffee b/background_scripts/completion_engines.coffee
index 52db90d0..ff10f4b5 100644
--- a/background_scripts/completion_engines.coffee
+++ b/background_scripts/completion_engines.coffee
@@ -100,6 +100,7 @@ class DuckDuckGo extends RegexpEngine
# A dummy search engine which is guaranteed to match any search URL, but never produces completions. This
# allows the rest of the logic to be written knowing that there will always be a completion engine match.
class DummyCompletionEngine
+ dummy: true
match: -> true
# We return a useless URL which we know will succeed, but which won't generate any network traffic.
getUrl: -> chrome.runtime.getURL "content_scripts/vimium.css"
@@ -140,7 +141,7 @@ CompletionEngines =
# Look up the completion engine for this searchUrl. Because of DummyCompletionEngine, above, we know there
# will always be a match. Imagining that there may be many completion engines, and knowing that this is
- # called for every input event in the vomnibar, we cache the result.
+ # called for every query, we cache the result.
lookupEngine: (searchUrl) ->
@engineCache ?= new SimpleCache 30 * 60 * 60 * 1000 # 30 hours (these are small, we can keep them longer).
if @engineCache.has searchUrl
@@ -150,6 +151,10 @@ CompletionEngines =
engine = new engine()
return @engineCache.set searchUrl, engine if engine.match searchUrl
+ # True if we have a completion engine for this search URL, undefined otherwise.
+ haveCompletionEngine: (searchUrl) ->
+ not @lookupEngine(searchUrl).dummy
+
# This is the main entry point.
# - searchUrl is the search engine's URL, e.g. Settings.get("searchUrl"), or a custome search engine's URL.
# This is only used as a key for determining the relevant completion engine.