From 4de8e668be6ff09637fbaa5e2eff2825e13f1fd6 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 23 Nov 2014 16:36:56 +0000 Subject: Frames; more cleanup and simplification. --- background_scripts/main.coffee | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'background_scripts/main.coffee') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 722091a4..10e6121f 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -600,23 +600,21 @@ openOptionsPageInNewTab = -> chrome.tabs.create({ url: chrome.runtime.getURL("pages/options.html"), index: tab.index + 1 })) registerFrame = (request, sender) -> - frameIdsForTab[sender.tab.id] ?= [] - # Don't store frameset containers; focusing them is no use. - frameIdsForTab[sender.tab.id].push request.frameId unless request.is_frameset + (frameIdsForTab[sender.tab.id] ?= []).push request.frameId unregisterFrame = (request, sender) -> tabId = sender.tab.id - return unless frameIdsForTab[tabId]? - - if request.is_top # The whole tab is closing, so we can drop the frames list. - updateOpenTabs sender.tab - else - frameIdsForTab[tabId] = frameIdsForTab[tabId].filter (id) -> id != request.frameId + if frameIdsForTab[tabId]? + if request.tab_is_closing + updateOpenTabs sender.tab + else + frameIdsForTab[tabId] = frameIdsForTab[tabId].filter (id) -> id != request.frameId handleFrameFocused = (request, sender) -> tabId = sender.tab.id - frameIdsForTab[tabId] = - [request.frameId, (frameIdsForTab[tabId].filter (id) -> id != request.frameId)...] + if frameIdsForTab[tabId]? + frameIdsForTab[tabId] = + [request.frameId, (frameIdsForTab[tabId].filter (id) -> id != request.frameId)...] # Port handler mapping portHandlers = -- cgit v1.2.3