diff options
| author | Phil Crosby | 2012-05-05 15:00:09 -0700 | 
|---|---|---|
| committer | Phil Crosby | 2012-05-05 18:32:13 -0700 | 
| commit | 8bbdcd53d87f3504853405d6e20c11759666e487 (patch) | |
| tree | beed29f2fce2713d1d4b2c7a4056d5ef1fb3a5e8 /fuzzyMode.js | |
| parent | ce46b9486e1842fe9002b9dcd04afbe06bdedd57 (diff) | |
| download | vimium-8bbdcd53d87f3504853405d6e20c11759666e487.tar.bz2 | |
Move backgroundCompleter into fuzzymode.js
This is the first step in an attempt to split background js from frontend.
Diffstat (limited to 'fuzzyMode.js')
| -rw-r--r-- | fuzzyMode.js | 30 | 
1 files changed, 29 insertions, 1 deletions
diff --git a/fuzzyMode.js b/fuzzyMode.js index 8667d467..2d53431e 100644 --- a/fuzzyMode.js +++ b/fuzzyMode.js @@ -4,7 +4,7 @@ var fuzzyMode = (function() {    function getCompleter(name) {      if (!(name in completers)) -      completers[name] = new completion.BackgroundCompleter(name); +      completers[name] = new BackgroundCompleter(name);      return completers[name];    } @@ -167,6 +167,34 @@ var fuzzyMode = (function() {      },    } +  /* +   * Sends filter and refresh requests to a Vomnibar completer on the background page. +   */ +  var BackgroundCompleter = Class.extend({ +    /* +     * - name: The name of the background page completer that you want to interface with. One of [omni, tabs]. +     */ +    init: function(name) { +      this.name = name; +      this.filterPort = chrome.extension.connect({ name: "filterCompleter" }); +    }, + +    refresh: function() { chrome.extension.sendRequest({ handler: "refreshCompleter", name: this.name }); }, + +    filter: function(query, maxResults, callback) { +      var id = utils.createUniqueId(); +      this.filterPort.onMessage.addListener(function(msg) { +        if (msg.id != id) return; +        callback(msg.results.map(function(result) { +          var action = result.action; +          result.action = eval(action.func).apply(null, action.args); +          return result; +        })); +      }); +      this.filterPort.postMessage({ id: id, name: this.name, query: query, maxResults: maxResults }); +    } +  }); +    // public interface    return {      activateAll:       function() { start("omni", false, 100); },  | 
