diff options
| author | Niklas Baumstark | 2012-01-22 22:10:31 +0100 |
|---|---|---|
| committer | Niklas Baumstark | 2012-04-10 23:54:37 +0200 |
| commit | 2c5b91634f7748e70730265c0fe7bb54d91fd213 (patch) | |
| tree | 754ada1190f74e68cd82896f70df6159857c7751 /lib | |
| parent | 469147824fd2fb8d83d16a28f3d3c613e69b4573 (diff) | |
| download | vimium-2c5b91634f7748e70730265c0fe7bb54d91fd213.tar.bz2 | |
use background page to open URLs
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/completion.js | 18 |
1 files changed, 14 insertions, 4 deletions
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. */ |
