aboutsummaryrefslogtreecommitdiffstats
path: root/pages
diff options
context:
space:
mode:
authorStephen Blott2015-05-06 05:18:59 +0100
committerStephen Blott2015-05-06 05:46:20 +0100
commit1f97221aef5cfe28200df81a68a139a3f2b07784 (patch)
tree62b6031f5d384d69d353976b6eb5e3a246c4fd81 /pages
parent7d11b1699454366bf99e8e5033ba39b127687fcb (diff)
downloadvimium-1f97221aef5cfe28200df81a68a139a3f2b07784.tar.bz2
Search completion; move all filter messages to a single port.
Diffstat (limited to 'pages')
-rw-r--r--pages/vomnibar.coffee24
1 files changed, 10 insertions, 14 deletions
diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee
index d9a86a3f..a2d4df85 100644
--- a/pages/vomnibar.coffee
+++ b/pages/vomnibar.coffee
@@ -220,15 +220,14 @@ class VomnibarUI
document.body.addEventListener "click", => @hide()
#
-# Sends filter and refresh requests to a Vomnibox completer on the background page.
+# Sends requests to a Vomnibox completer on the background page.
#
class BackgroundCompleter
- # - name: The background page completer that you want to interface with. Either "omni", "tabs", or
- # "bookmarks". */
+ # name is background-page completer to connect to: "omni", "tabs", or "bookmarks".
constructor: (@name) ->
@messageId = null
- @filterPort = chrome.runtime.connect name: "filterCompleter"
- @filterPort.onMessage.addListener handler = @messageHandler
+ @port = chrome.runtime.connect name: "completions"
+ @port.onMessage.addListener handler = @messageHandler
messageHandler: (msg) =>
# We ignore messages which arrive too late.
@@ -236,29 +235,26 @@ class BackgroundCompleter
# The result objects coming from the background page will be of the form:
# { html: "", type: "", url: "" }
# type will be one of [tab, bookmark, history, domain].
- results = msg.results.map (result) ->
+ results = msg.results.map (result) =>
functionToCall = if result.type == "tab"
- BackgroundCompleter.completionActions.switchToTab.curry result.tabId
+ @completionActions.switchToTab.curry result.tabId
else
- BackgroundCompleter.completionActions.navigateToUrl.curry result.url
+ @completionActions.navigateToUrl.curry result.url
result.performAction = functionToCall
result
@mostRecentCallback results
filter: (query, @mostRecentCallback) ->
@messageId = Utils.createUniqueId()
- @filterPort.postMessage id: @messageId, name: @name, query: query
+ @port.postMessage name: @name, handler: "filter", id: @messageId, query: query
refresh: ->
- chrome.runtime.sendMessage handler: "refreshCompleter", name: @name
+ @port.postMessage name: @name, handler: "refreshCompleter"
userIsTyping: ->
- @filterPort.postMessage name: @name, userIsTyping: true
+ @port.postMessage name: @name, handler: "userIsTyping"
-extend BackgroundCompleter,
- #
# These are the actions we can perform when the user selects a result in the Vomnibox.
- #
completionActions:
navigateToUrl: (url, openInNewTab) ->
# If the URL is a bookmarklet prefixed with javascript:, we shouldn't open that in a new tab.