aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authormrmr19932017-04-18 02:18:14 +0100
committermrmr19932017-04-18 02:18:14 +0100
commitb0fc681480da40ec0bdb43773275ef7181c78cf1 (patch)
treecfb8826b7dc2e3e2522cf0e0151de551ac40d5d8 /lib
parent93a07e4c4ccc64b5939adbf71a12bfad403845ad (diff)
downloadvimium-b0fc681480da40ec0bdb43773275ef7181c78cf1.tar.bz2
Check whether chrome.storage.sync is enabled, fall back to .local if not
Diffstat (limited to 'lib')
-rw-r--r--lib/settings.coffee8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/settings.coffee b/lib/settings.coffee
index 51bb8bc4..51f6b504 100644
--- a/lib/settings.coffee
+++ b/lib/settings.coffee
@@ -27,6 +27,14 @@ Settings =
@cache = if Utils.isBackgroundPage() then localStorage else extend {}, localStorage
@runOnLoadedCallbacks()
+ # Test chrome.storage.sync to see if it is enabled.
+ # NOTE(mrmr1993, 2017-04-18): currently the API is defined in FF, but it is disabled behind a flag in
+ # about:config. Every use sets chrome.runtime.lastError, so we use that to check whether we can use it.
+ chrome.storage.sync.get null, =>
+ if chrome.runtime.lastError
+ storageArea = "local"
+ @storage = chrome.storage[storageArea]
+
chrome.storage.local.get null, (localItems) =>
localItems = {} if chrome.runtime.lastError
@storage.get null, (syncedItems) =>