aboutsummaryrefslogtreecommitdiffstats
path: root/background_page.html
diff options
context:
space:
mode:
authorilya2009-11-09 01:48:39 -0800
committerilya2009-11-09 01:49:57 -0800
commitbe17ec68f6038e176b8a72e674697861228dfb56 (patch)
tree97ba92a1fc2a0a6ad71ece4b34b6abe5ea2b2b2f /background_page.html
parent961354e28460ccff349c314f689330442f217605 (diff)
downloadvimium-be17ec68f6038e176b8a72e674697861228dfb56.tar.bz2
Implement 'gf' -- toggle view source for the current page.
Diffstat (limited to 'background_page.html')
-rw-r--r--background_page.html15
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';