From 7f87e2031be72d8e1cc04056d26590181e18778b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 Apr 2010 17:03:43 +0800 Subject: Ensure Restore Tab works immediately upon extension install --- background_page.html | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/background_page.html b/background_page.html index 0e56409f..da803e99 100644 --- a/background_page.html +++ b/background_page.html @@ -307,10 +307,21 @@ selectionChangedHandlers.push(callback); }); } + + function updateOpenTabs(tab) { + openTabs[tab.id] = { url: tab.url, positionIndex: tab.index, windowId: tab.windowId }; + } + + // this ensures that Restore Tab works immediately upon extension install + chrome.windows.getAll({ populate: true }, function(windows) { + for (var i in windows) for (var j in windows[i].tabs) { + updateOpenTabs(windows[i].tabs[j]); + } + }); chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { if (changeInfo.status != "loading") { return; } // only do this once per URL change - openTabs[tabId] = { url: tab.url, positionIndex: tab.index, windowId: tab.windowId }; + updateOpenTabs(tab); }); chrome.tabs.onAttached.addListener(function(tabId, attachedInfo) { -- cgit v1.2.3