diff options
| -rw-r--r-- | background_scripts/marks.coffee | 4 | ||||
| -rw-r--r-- | content_scripts/marks.coffee | 2 | ||||
| -rw-r--r-- | lib/settings.coffee | 10 |
3 files changed, 9 insertions, 7 deletions
diff --git a/background_scripts/marks.coffee b/background_scripts/marks.coffee index 33c467a7..a6491b9e 100644 --- a/background_scripts/marks.coffee +++ b/background_scripts/marks.coffee @@ -30,7 +30,7 @@ Marks = saveMark: (markInfo) -> item = {} item[@getLocationKey markInfo.markName] = markInfo - chrome.storage.sync.set item + Settings.storage.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 @@ -39,7 +39,7 @@ Marks = chrome.storage.local.get "vimiumSecret", (items) => vimiumSecret = items.vimiumSecret key = @getLocationKey req.markName - chrome.storage.sync.get key, (items) => + Settings.storage.get key, (items) => markInfo = items[key] if markInfo.vimiumSecret != vimiumSecret # This is a different Vimium instantiation, so markInfo.tabId is definitely out of date. diff --git a/content_scripts/marks.coffee b/content_scripts/marks.coffee index 808f0a1d..37b062ba 100644 --- a/content_scripts/marks.coffee +++ b/content_scripts/marks.coffee @@ -64,7 +64,7 @@ Marks = if @isGlobalMark event, markName # This key must match @getLocationKey() in the back end. key = "vimiumGlobalMark|#{markName}" - chrome.storage.sync.get key, (items) -> + Settings.storage.get key, (items) -> if key of items chrome.runtime.sendMessage handler: 'gotoMark', markName: markName HUD.showForDuration "Jumped to global mark '#{markName}'", 1000 diff --git a/lib/settings.coffee b/lib/settings.coffee index e16261d0..65e097ea 100644 --- a/lib/settings.coffee +++ b/lib/settings.coffee @@ -10,9 +10,11 @@ # # In all cases except Settings.defaults, values are stored as jsonified strings. +storageArea = if chrome.storage.sync? then "sync" else "local" + Settings = debug: false - storage: chrome.storage.sync + storage: chrome.storage[storageArea] cache: {} isLoaded: false onLoadedCallbacks: [] @@ -32,7 +34,7 @@ Settings = @handleUpdateFromChromeStorage key, value for own key, value of extend localItems, syncedItems chrome.storage.onChanged.addListener (changes, area) => - @propagateChangesFromChromeStorage changes if area == "sync" + @propagateChangesFromChromeStorage changes if area == storageArea @runOnLoadedCallbacks() @@ -71,7 +73,7 @@ Settings = if @shouldSyncKey key if shouldSetInSyncedStorage setting = {}; setting[key] = @cache[key] - @log " chrome.storage.sync.set(#{key})" + @log " chrome.storage.#{storageArea}.set(#{key})" @storage.set setting if Utils.isBackgroundPage() # Remove options installed by the "copyNonDefaultsToChromeStorage-20150717" migration; see below. @@ -98,7 +100,7 @@ Settings = nuke: (key) -> delete localStorage[key] chrome.storage.local.remove key - chrome.storage.sync.remove key + chrome.storage.sync?.remove key # For development only. log: (args...) -> |
