diff --git a/src/background/main.background.ts b/src/background/main.background.ts index a3e076c433..255dc5edb4 100644 --- a/src/background/main.background.ts +++ b/src/background/main.background.ts @@ -15,8 +15,8 @@ import ApiService from '../services/api.service'; import AppIdService from '../services/appId.service'; import AutofillService from '../services/autofill.service'; import BrowserMessagingService from '../services/browserMessaging.service'; +import BrowserStorageService from '../services/browserStorage.service'; import BrowserUtilsService from '../services/browserUtils.service'; -import ChromeStorageService from '../services/chromeStorage.service'; import CipherService from '../services/cipher.service'; import CollectionService from '../services/collection.service'; import ConstantsService from '../services/constants.service'; @@ -82,7 +82,7 @@ export default class MainBackground { this.utilsService = new UtilsService(); this.browserUtilsService = new BrowserUtilsService(); this.messagingService = new BrowserMessagingService(this.browserUtilsService); - this.storageService = new ChromeStorageService(); + this.storageService = new BrowserStorageService(this.browserUtilsService); this.i18nService = i18nService(this.browserUtilsService); this.constantsService = new ConstantsService(this.i18nService, this.browserUtilsService); this.cryptoService = ContainerService.cryptoService = new CryptoService(this.storageService, diff --git a/src/services/chromeStorage.service.ts b/src/services/browserStorage.service.ts similarity index 73% rename from src/services/chromeStorage.service.ts rename to src/services/browserStorage.service.ts index ade42fa5e7..d7ff69f5f9 100644 --- a/src/services/chromeStorage.service.ts +++ b/src/services/browserStorage.service.ts @@ -1,7 +1,12 @@ +import { BrowserUtilsService } from './abstractions/browserUtils.service'; import { StorageService as StorageServiceInterface } from './abstractions/storage.service'; -export default class ChromeStorageService implements StorageServiceInterface { +export default class BrowserStorageService implements StorageServiceInterface { + constructor(private browserUtilsService: BrowserUtilsService) { + } + get(key: string): Promise { + // if safari, else return new Promise((resolve) => { chrome.storage.local.get(key, (obj: any) => { if (obj && (typeof obj[key] !== 'undefined') && obj[key] !== null) { @@ -14,6 +19,7 @@ export default class ChromeStorageService implements StorageServiceInterface { } save(key: string, obj: any): Promise { + // if safari, else return new Promise((resolve) => { chrome.storage.local.set({ [key]: obj }, () => { resolve(); @@ -22,6 +28,7 @@ export default class ChromeStorageService implements StorageServiceInterface { } remove(key: string): Promise { + // if safari, else return new Promise((resolve) => { chrome.storage.local.remove(key, () => { resolve();