diff options
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'; |
