From 1dff60dc3b50607685f2cf60ce576838836fef43 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Sat, 7 Nov 2020 16:20:50 +0100 Subject: [PATCH] #32 Preparing storage provider --- src/javascript/settings/storageProvider.js | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/javascript/settings/storageProvider.js diff --git a/src/javascript/settings/storageProvider.js b/src/javascript/settings/storageProvider.js new file mode 100644 index 0000000..ade62c1 --- /dev/null +++ b/src/javascript/settings/storageProvider.js @@ -0,0 +1,53 @@ +const { assigned } = require("../utils/helpers") + +class StorageProviderChromium { + + storeData(key, value, callback) { + } + + getData(key, defaultValue, callback) { + } + + getStorage() { + if (assigned(chrome.storage.sync)) { + return chrome.storage.sync; + } + + return chrome.storage.local; + } +} + + +class StorageProviderFirefox { + + storeData(key, value, callback) { + } + + getData(key, defaultValue, callback) { + } + + getStorage() { + } +} + +let __storageProvieder = undefined; + +function createStorageProvider() { + // chrome based browser + if (assigned(chrome?.app)) { + __storageProvieder = new StorageProviderChromium(); + } + // firefox + else { + __storageProvieder = new StorageProviderFirefox(); + } + +} + +export function globalStorageProvider() { + if (!assigned(__storageProvieder)) { + createStorageProvider(); + } + + return __storageProvieder; +} \ No newline at end of file