From cb3d18a8068063050dd25f0db03777b564f1a548 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Thu, 4 Jun 2015 12:16:06 +0100 Subject: Global marks; create a new tab, if necessary. --- background_scripts/main.coffee | 3 ++- background_scripts/marks.coffee | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'background_scripts') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 980f8e18..cbb70c6c 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -35,7 +35,8 @@ namedKeyRegex = /^(<(?:[amc]-.|(?:[amc]-)?[a-z0-9]{2,5})>)(.*)$/ # Event handlers selectionChangedHandlers = [] -tabLoadedHandlers = {} # tabId -> function() +# Note. tabLoadedHandlers handlers is exported for use also by "marks.coffee". +root.tabLoadedHandlers = {} # tabId -> function() # A secret, available only within the current instantiation of Vimium. The secret is big, likely unguessable # in practice, but less than 2^31. diff --git a/background_scripts/marks.coffee b/background_scripts/marks.coffee index 05c8e579..94633c36 100644 --- a/background_scripts/marks.coffee +++ b/background_scripts/marks.coffee @@ -59,6 +59,11 @@ Marks = if baseUrl == @getBaseUrl tab.url # We have a matching tab. We'll use it. return @gotoPositionInTab extend markInfo, tabId: tab.id + # There is no existing matching tab, we'll have to create one. + chrome.tabs.create { url: @getBaseUrl(markInfo.url) }, (tab) => + # Note. tabLoadedHandlers is defined in "main.coffee". This handler will be called when the tab has + # is loaded, its DOM is ready and it registers with the background page. + tabLoadedHandlers[tab.id] = => @gotoPositionInTab extend markInfo, tabId: tab.id getBaseUrl: (url) -> url.split("#")[0] -- cgit v1.2.3