diff options
| author | Stephen Blott | 2015-06-05 07:07:02 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2015-06-05 07:07:04 +0100 | 
| commit | 8eda31fb236b9506d577a25908d4e5334d3289d5 (patch) | |
| tree | 85cfc27b6156d3833c9fd21f7177097a7f6d054e /background_scripts/marks.coffee | |
| parent | a143d2c81a9faaf383a05b0dae2f232db85959a2 (diff) | |
| download | vimium-8eda31fb236b9506d577a25908d4e5334d3289d5.tar.bz2 | |
Global marks; global marks are always recorded for the top frame only.
With global marks, we may later create a new tab when the mark is used.
When doing so, we should always be using the URL and scroll position of
the top frame within the tab.  For example, if a global mark is created
from within the Hangouts frame of Google's Inbox and the mark is later
used, then we should create a new tab for Inbox's URL and scroll
position, not for the Hangout's URL and scroll position.
Diffstat (limited to 'background_scripts/marks.coffee')
| -rw-r--r-- | background_scripts/marks.coffee | 18 | 
1 files changed, 15 insertions, 3 deletions
diff --git a/background_scripts/marks.coffee b/background_scripts/marks.coffee index 3a5af130..6e5f08ba 100644 --- a/background_scripts/marks.coffee +++ b/background_scripts/marks.coffee @@ -11,15 +11,27 @@ Marks =    # tabId can be considered valid.    create: (req, sender) ->      chrome.storage.local.get "vimiumSecret", (items) => -      item = {} -      item[@getLocationKey req.markName] = +      markInfo =          vimiumSecret: items.vimiumSecret          markName: req.markName          url: @getBaseUrl sender.tab.url          tabId: sender.tab.id          scrollX: req.scrollX          scrollY: req.scrollY -      chrome.storage.sync.set item + +      if markInfo.scrollX? and markInfo.scrollY? +        @saveMark markInfo +      else +        # The front-end frame hasn't provided the scroll position (because it's not the top frame within its +        # tab).  We need to ask the top frame what its scroll position is. (With the frame Id set to 0, below, +        # the request will only be handled by the top frame within the tab.) +        chrome.tabs.sendMessage sender.tab.id, name: "getScrollPosition", frameId: 0, (response) => +          @saveMark extend markInfo, scrollX: response.scrollX, scrollY: response.scrollY + +  saveMark: (markInfo) -> +    item = {} +    item[@getLocationKey markInfo.markName] = markInfo +    chrome.storage.sync.set item    # Goto a global mark.  We try to find the original tab.  If we can't find that, then we try to find another    # tab with the original URL, and use that.  And if we can't find such an existing tab, then we create a new  | 
