From 2c5b91634f7748e70730265c0fe7bb54d91fd213 Mon Sep 17 00:00:00 2001 From: Niklas Baumstark Date: Sun, 22 Jan 2012 22:10:31 +0100 Subject: use background page to open URLs --- lib/completion.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'lib/completion.js') diff --git a/lib/completion.js b/lib/completion.js index 67d8b219..d0e9e32a 100644 --- a/lib/completion.js +++ b/lib/completion.js @@ -170,10 +170,20 @@ var completion = (function() { /** Creates an action that opens :url in the current tab by default or in a new tab as an alternative. */ function createActionOpenUrl(url) { - return [ - function() { window.location = url; }, - function() { window.open(url); }, - ] + var open = function(newTab, selected) { + return function() { + chrome.extension.sendRequest({ + handler: newTab ? "openUrlInNewTab" : "openUrlInCurrentTab", + url: url, + selected: selected + }); + } + } + + if (url.indexOf("javascript:") == 0) + return [ open(false), open(false), open(false) ]; + else + return [ open(false), open(true, true), open(true, false) ]; } /** Creates a completion that renders by marking fuzzy-matched parts. */ -- cgit v1.2.3