aboutsummaryrefslogtreecommitdiffstats
path: root/background_page.html
diff options
context:
space:
mode:
authorPhil Crosby2009-11-07 23:59:58 -0800
committerPhil Crosby2009-11-07 23:59:58 -0800
commit5e472a0ace4515936bce4b7330be391f0dfb10cb (patch)
tree81a0057539be546ac6b733a08dbe82ced9a5f0ee /background_page.html
parent9e37412a2bb7710a898c0732ca46f33a4b608afb (diff)
downloadvimium-5e472a0ace4515936bce4b7330be391f0dfb10cb.tar.bz2
Set the scroll position of a restored tab once the content script is ready.
Previously we did this only when the tab's status changed to "complete", which could take awhile.
Diffstat (limited to 'background_page.html')
-rw-r--r--background_page.html25
1 files changed, 12 insertions, 13 deletions
diff --git a/background_page.html b/background_page.html
index 5ad8c2e6..c6d963ce 100644
--- a/background_page.html
+++ b/background_page.html
@@ -14,10 +14,19 @@
var tabLoadedHandlers = {}; // tabId -> function ()
chrome.extension.onConnect.addListener(function(port, name) {
+ var senderTabId = port.sender.tab ? port.sender.tab.id : null;
+ // If this is a tab we've been waiting to open, execute any "tab loaded" handlers, e.g. to restore
+ // the tab's scroll position.
+ if (senderTabId && tabLoadedHandlers[senderTabId]) {
+ var toCall = tabLoadedHandlers[senderTabId];
+ // Delete first to be sure there's no circular events.
+ delete tabLoadedHandlers[senderTabId];
+ toCall.call();
+ }
+
if (portHandlers[port.name])
- {
port.onMessage.addListener(portHandlers[port.name]);
- }
+
});
function handleReturnScrollPosition(args) {
@@ -30,16 +39,6 @@
}
}
- chrome.tabs.onUpdated.addListener(function (tabId, changeInfo) {
- if (changeInfo.status == "complete" && tabLoadedHandlers[tabId])
- {
- // Delete first to be sure there's no circular events.
- var toCall = tabLoadedHandlers[tabId];
- delete tabLoadedHandlers[tabId];
- toCall.call();
- }
- });
-
chrome.tabs.onSelectionChanged.addListener(function (tabId, selectionInfo) {
if (selectionChangedHandlers.length > 0) { selectionChangedHandlers.pop().call(); }
});
@@ -141,7 +140,7 @@
});
}
else { repeatFunction(registryEntry, count, 0); }
-
+
keyQueue = "";
}
else if (command.length > 1)