aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/main.coffee37
1 files changed, 21 insertions, 16 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index 07bb1f47..33425d90 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -251,7 +251,8 @@ BackgroundCommands =
restoreTab: (callback) ->
# TODO: remove if-else -block when adopted into stable
if chrome.sessions
- chrome.sessions.restore(null, (restoredSession) -> callback())
+ chrome.sessions.restore(null, (restoredSession) ->
+ callback() unless chrome.runtime.lastError)
else
# TODO(ilya): Should this be getLastFocused instead?
chrome.windows.getCurrent((window) ->
@@ -388,12 +389,14 @@ updateScrollPosition = (tab, scrollX, scrollY) ->
chrome.tabs.onUpdated.addListener (tabId, changeInfo, tab) ->
return unless changeInfo.status == "loading" # only do this once per URL change
- chrome.tabs.insertCSS tabId,
+ cssConf =
allFrames: true
code: Settings.get("userDefinedLinkHintCss")
runAt: "document_start"
- updateOpenTabs(tab)
- updateActiveState(tabId)
+ chrome.tabs.insertCSS tabId, cssConf, ->
+ if not chrome.runtime.lastError
+ updateOpenTabs(tab)
+ updateActiveState(tabId)
chrome.tabs.onAttached.addListener (tabId, attachedInfo) ->
# We should update all the tabs in the old window and the new window.
@@ -411,16 +414,17 @@ chrome.tabs.onRemoved.addListener (tabId) ->
# If we restore pages that content scripts can't run on, they'll ignore Vimium keystrokes when they
# reappear. Pretend they never existed and adjust tab indices accordingly. Could possibly expand this into
# a blacklist in the future.
- if (/^(chrome|view-source:)[^:]*:\/\/.*/.test(openTabInfo.url))
- for i of tabQueue[openTabInfo.windowId]
- if (tabQueue[openTabInfo.windowId][i].positionIndex > openTabInfo.positionIndex)
- tabQueue[openTabInfo.windowId][i].positionIndex--
- return
-
- if (tabQueue[openTabInfo.windowId])
- tabQueue[openTabInfo.windowId].push(openTabInfo)
- else
- tabQueue[openTabInfo.windowId] = [openTabInfo]
+ unless chrome.sessions
+ if (/^(chrome|view-source:)[^:]*:\/\/.*/.test(openTabInfo.url))
+ for i of tabQueue[openTabInfo.windowId]
+ if (tabQueue[openTabInfo.windowId][i].positionIndex > openTabInfo.positionIndex)
+ tabQueue[openTabInfo.windowId][i].positionIndex--
+ return
+
+ if (tabQueue[openTabInfo.windowId])
+ tabQueue[openTabInfo.windowId].push(openTabInfo)
+ else
+ tabQueue[openTabInfo.windowId] = [openTabInfo]
# keep the reference around for a while to wait for the last messages from the closed tab (e.g. for updating
# scroll position)
@@ -430,7 +434,8 @@ chrome.tabs.onRemoved.addListener (tabId) ->
chrome.tabs.onActiveChanged.addListener (tabId, selectInfo) -> updateActiveState(tabId)
-chrome.windows.onRemoved.addListener (windowId) -> delete tabQueue[windowId]
+unless chrome.sessions
+ chrome.windows.onRemoved.addListener (windowId) -> delete tabQueue[windowId]
# End action functions
@@ -608,7 +613,7 @@ registerFrame = (request, sender) ->
focusedFrame = request.frameId
framesForTab[sender.tab.id].total = request.total
- framesForTab[sender.tab.id].frames.push({ id: request.frameId, area: request.area })
+ framesForTab[sender.tab.id].frames.push({ id: request.frameId })
handleFrameFocused = (request, sender) -> focusedFrame = request.frameId