mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
fix: save indication of browser installation to storage (#13743)
This commit is contained in:
@@ -267,6 +267,7 @@ import { OffscreenDocumentService } from "../platform/offscreen-document/abstrac
|
||||
import { DefaultOffscreenDocumentService } from "../platform/offscreen-document/offscreen-document.service";
|
||||
import { BrowserTaskSchedulerService } from "../platform/services/abstractions/browser-task-scheduler.service";
|
||||
import { BrowserEnvironmentService } from "../platform/services/browser-environment.service";
|
||||
import BrowserInitialInstallService from "../platform/services/browser-initial-install.service";
|
||||
import BrowserLocalStorageService from "../platform/services/browser-local-storage.service";
|
||||
import BrowserMemoryStorageService from "../platform/services/browser-memory-storage.service";
|
||||
import { BrowserScriptInjectorService } from "../platform/services/browser-script-injector.service";
|
||||
@@ -390,6 +391,7 @@ export default class MainBackground {
|
||||
kdfConfigService: KdfConfigService;
|
||||
offscreenDocumentService: OffscreenDocumentService;
|
||||
syncServiceListener: SyncServiceListener;
|
||||
browserInitialInstallService: BrowserInitialInstallService;
|
||||
|
||||
webPushConnectionService: WorkerWebPushConnectionService | UnsupportedWebPushConnectionService;
|
||||
themeStateService: DefaultThemeStateService;
|
||||
@@ -1043,6 +1045,8 @@ export default class MainBackground {
|
||||
this.organizationVaultExportService,
|
||||
);
|
||||
|
||||
this.browserInitialInstallService = new BrowserInitialInstallService(this.stateProvider);
|
||||
|
||||
if (BrowserApi.isManifestVersion(3)) {
|
||||
const registration = (self as unknown as { registration: ServiceWorkerRegistration })
|
||||
?.registration;
|
||||
@@ -1146,6 +1150,7 @@ export default class MainBackground {
|
||||
this.accountService,
|
||||
lockService,
|
||||
this.billingAccountProfileStateService,
|
||||
this.browserInitialInstallService,
|
||||
);
|
||||
this.nativeMessagingBackground = new NativeMessagingBackground(
|
||||
this.keyService,
|
||||
|
||||
@@ -28,6 +28,7 @@ import { LockedVaultPendingNotificationsData } from "../autofill/background/abst
|
||||
import { AutofillService } from "../autofill/services/abstractions/autofill.service";
|
||||
import { BrowserApi } from "../platform/browser/browser-api";
|
||||
import { BrowserEnvironmentService } from "../platform/services/browser-environment.service";
|
||||
import BrowserInitialInstallService from "../platform/services/browser-initial-install.service";
|
||||
import { BrowserPlatformUtilsService } from "../platform/services/platform-utils/browser-platform-utils.service";
|
||||
|
||||
import MainBackground from "./main.background";
|
||||
@@ -53,6 +54,7 @@ export default class RuntimeBackground {
|
||||
private accountService: AccountService,
|
||||
private readonly lockService: LockService,
|
||||
private billingAccountProfileStateService: BillingAccountProfileStateService,
|
||||
private browserInitialInstallService: BrowserInitialInstallService,
|
||||
) {
|
||||
// onInstalled listener must be wired up before anything else, so we do it in the ctor
|
||||
chrome.runtime.onInstalled.addListener((details: any) => {
|
||||
@@ -382,7 +384,10 @@ export default class RuntimeBackground {
|
||||
void this.autofillService.loadAutofillScriptsOnInstall();
|
||||
|
||||
if (this.onInstalledReason != null) {
|
||||
if (this.onInstalledReason === "install") {
|
||||
if (
|
||||
this.onInstalledReason === "install" &&
|
||||
!(await firstValueFrom(this.browserInitialInstallService.extensionInstalled$))
|
||||
) {
|
||||
if (!devFlagEnabled("skipWelcomeOnInstall")) {
|
||||
void BrowserApi.createNewTab("https://bitwarden.com/browser-start/");
|
||||
}
|
||||
@@ -394,6 +399,7 @@ export default class RuntimeBackground {
|
||||
if (await this.environmentService.hasManagedEnvironment()) {
|
||||
await this.environmentService.setUrlsToManagedEnvironment();
|
||||
}
|
||||
await this.browserInitialInstallService.setExtensionInstalled(true);
|
||||
}
|
||||
|
||||
this.onInstalledReason = null;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { Observable, map } from "rxjs";
|
||||
|
||||
import {
|
||||
GlobalState,
|
||||
EXTENSION_INITIAL_INSTALL_DISK,
|
||||
KeyDefinition,
|
||||
StateProvider,
|
||||
} from "@bitwarden/common/platform/state";
|
||||
|
||||
const EXTENSION_INSTALLED = new KeyDefinition<boolean>(
|
||||
EXTENSION_INITIAL_INSTALL_DISK,
|
||||
"extensionInstalled",
|
||||
{
|
||||
deserializer: (obj) => obj,
|
||||
},
|
||||
);
|
||||
|
||||
export default class BrowserInitialInstallService {
|
||||
private extensionInstalled: GlobalState<boolean> =
|
||||
this.stateProvider.getGlobal(EXTENSION_INSTALLED);
|
||||
|
||||
readonly extensionInstalled$: Observable<boolean> = this.extensionInstalled.state$.pipe(
|
||||
map((x) => x ?? false),
|
||||
);
|
||||
|
||||
constructor(private stateProvider: StateProvider) {}
|
||||
|
||||
async setExtensionInstalled(value: boolean) {
|
||||
await this.extensionInstalled.update(() => value);
|
||||
}
|
||||
}
|
||||
@@ -131,6 +131,10 @@ export const THEMING_DISK = new StateDefinition("theming", "disk", { web: "disk-
|
||||
export const TRANSLATION_DISK = new StateDefinition("translation", "disk", { web: "disk-local" });
|
||||
export const ANIMATION_DISK = new StateDefinition("animation", "disk");
|
||||
export const TASK_SCHEDULER_DISK = new StateDefinition("taskScheduler", "disk");
|
||||
export const EXTENSION_INITIAL_INSTALL_DISK = new StateDefinition(
|
||||
"extensionInitialInstall",
|
||||
"disk",
|
||||
);
|
||||
|
||||
// Design System
|
||||
|
||||
|
||||
Reference in New Issue
Block a user