diff options
Diffstat (limited to 'background_scripts/completion_engines.coffee')
| -rw-r--r-- | background_scripts/completion_engines.coffee | 7 | 
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.  | 
