mirror of
https://github.com/bitwarden/browser.git
synced 2024-09-23 03:22:50 +02:00
Deduplicate background storage service in browser mv2 (#10241)
This commit is contained in:
parent
b6aadaa255
commit
a9ba7d8d25
@ -462,16 +462,21 @@ export default class MainBackground {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.secureStorageService = this.storageService; // secure storage is not supported in browsers, so we use local storage and warn users when it is used
|
this.secureStorageService = this.storageService; // secure storage is not supported in browsers, so we use local storage and warn users when it is used
|
||||||
this.memoryStorageForStateProviders = BrowserApi.isManifestVersion(3)
|
|
||||||
? new BrowserMemoryStorageService() // mv3 stores to storage.session
|
if (BrowserApi.isManifestVersion(3)) {
|
||||||
: popupOnlyContext
|
// manifest v3 can reuse the same storage. They are split for v2 due to lacking a good sync mechanism, which isn't true for v3
|
||||||
? new ForegroundMemoryStorageService()
|
this.memoryStorageForStateProviders = new BrowserMemoryStorageService(); // mv3 stores to storage.session
|
||||||
: new BackgroundMemoryStorageService(); // mv2 stores to memory
|
this.memoryStorageService = this.memoryStorageForStateProviders;
|
||||||
this.memoryStorageService = BrowserApi.isManifestVersion(3)
|
} else {
|
||||||
? this.memoryStorageForStateProviders // manifest v3 can reuse the same storage. They are split for v2 due to lacking a good sync mechanism, which isn't true for v3
|
if (popupOnlyContext) {
|
||||||
: popupOnlyContext
|
this.memoryStorageForStateProviders = new ForegroundMemoryStorageService();
|
||||||
? new ForegroundMemoryStorageService()
|
this.memoryStorageService = new ForegroundMemoryStorageService();
|
||||||
: new BackgroundMemoryStorageService();
|
} else {
|
||||||
|
this.memoryStorageForStateProviders = new BackgroundMemoryStorageService(); // mv2 stores to memory
|
||||||
|
this.memoryStorageService = this.memoryStorageForStateProviders;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.largeObjectMemoryStorageForStateProviders = BrowserApi.isManifestVersion(3)
|
this.largeObjectMemoryStorageForStateProviders = BrowserApi.isManifestVersion(3)
|
||||||
? mv3MemoryStorageCreator() // mv3 stores to local-backed session storage
|
? mv3MemoryStorageCreator() // mv3 stores to local-backed session storage
|
||||||
: this.memoryStorageForStateProviders; // mv2 stores to the same location
|
: this.memoryStorageForStateProviders; // mv2 stores to the same location
|
||||||
|
Loading…
Reference in New Issue
Block a user