diff options
| author | ilya | 2009-11-09 01:48:39 -0800 |
|---|---|---|
| committer | ilya | 2009-11-09 01:49:57 -0800 |
| commit | be17ec68f6038e176b8a72e674697861228dfb56 (patch) | |
| tree | 97ba92a1fc2a0a6ad71ece4b34b6abe5ea2b2b2f /background_page.html | |
| parent | 961354e28460ccff349c314f689330442f217605 (diff) | |
| download | vimium-be17ec68f6038e176b8a72e674697861228dfb56.tar.bz2 | |
Implement 'gf' -- toggle view source for the current page.
Diffstat (limited to 'background_page.html')
| -rw-r--r-- | background_page.html | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/background_page.html b/background_page.html index d15c3331..df63632a 100644 --- a/background_page.html +++ b/background_page.html @@ -6,7 +6,8 @@ // Port handler mapping var portHandlers = { "keyDown": handleKeyDown, - "returnScrollPosition": handleReturnScrollPosition }; + "returnScrollPosition": handleReturnScrollPosition, + "getCurrentTabUrl": getCurrentTabUrl }; // Event handlers var selectionChangedHandlers = []; @@ -38,6 +39,17 @@ } } + /* + * Used by the content scripts to get their full URL. This is needed for URLs like "view-source:http:// .." + * because window.location doesn't know anything about the Chrome-specific "view-source:". + */ + function getCurrentTabUrl(args) { + chrome.tabs.getSelected(null, function (tab) { + var returnPort = chrome.tabs.connect(tab.id, { name: "returnCurrentTabUrl" }); + returnPort.postMessage({ url: tab.url }); + }); + } + chrome.tabs.onSelectionChanged.addListener(function (tabId, selectionInfo) { if (selectionChangedHandlers.length > 0) { selectionChangedHandlers.pop().call(); } }); @@ -138,6 +150,7 @@ keyToCommandRegistry['<c-d>'] = "scrollPageDown"; keyToCommandRegistry['<c-u>'] = "scrollPageUp"; keyToCommandRegistry['r'] = 'reload'; + keyToCommandRegistry['gf'] = 'toggleViewSource'; keyToCommandRegistry['ba'] = 'goBack'; keyToCommandRegistry['H'] = 'goBack'; |
