From 3cb15e256474bc424f43615f53455edda5bbf4c5 Mon Sep 17 00:00:00 2001 From: Jared Hirsch Date: Tue, 22 Oct 2024 00:52:49 +0000 Subject: [PATCH] Bug 1925084 - Lazily init the selectable profiles DB and import the toolkit profile on first load of about:profilemanager. r=niklas Differential Revision: https://phabricator.services.mozilla.com/D225906 --- .../profiles/SelectableProfileService.sys.mjs | 21 ++++++++++++++++--- .../profiles/content/profile-selector.mjs | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/browser/components/profiles/SelectableProfileService.sys.mjs b/browser/components/profiles/SelectableProfileService.sys.mjs index 43209a5808ad..1f9954658253 100644 --- a/browser/components/profiles/SelectableProfileService.sys.mjs +++ b/browser/components/profiles/SelectableProfileService.sys.mjs @@ -588,10 +588,11 @@ class SelectableProfileServiceClass { } /** - * Create and launch a new SelectableProfile and add it to the group datastore. - * This is an unmanaged profile from the nsToolkitProfile perspective. + * If the user has never created a SelectableProfile before, the group + * datastore will be created and the currently running toolkit profile will + * be added to the datastore. */ - async createNewProfile() { + async maybeSetupDataStore() { // Create the profiles db and set the storeID on the toolkit profile if it // doesn't exist so we can init the service. await this.maybeCreateProfilesStorePath(); @@ -605,6 +606,20 @@ class SelectableProfileServiceClass { let originalProfile = await this.#createProfile(path); this.#currentProfile = originalProfile; } + } + + /** + * Create and launch a new SelectableProfile and add it to the group datastore. + * This is an unmanaged profile from the nsToolkitProfile perspective. + * + * If the user has never created a SelectableProfile before, the group + * datastore will be lazily created and the currently running toolkit profile + * will be added to the datastore along with the newly created profile. + * + * Launches the new SelectableProfile in a new instance after creating it. + */ + async createNewProfile() { + await this.maybeSetupDataStore(); let profile = await this.#createProfile(); this.launchInstance(profile); diff --git a/browser/components/profiles/content/profile-selector.mjs b/browser/components/profiles/content/profile-selector.mjs index 0af37bae69ec..4106dd66e673 100644 --- a/browser/components/profiles/content/profile-selector.mjs +++ b/browser/components/profiles/content/profile-selector.mjs @@ -43,7 +43,7 @@ export class ProfileSelector extends MozLitElement { this.selectableProfileService = SelectableProfileService; - await this.selectableProfileService.init(); + await this.selectableProfileService.maybeSetupDataStore(); this.profiles = await this.selectableProfileService.getAllProfiles(); if (!this.profiles.length) {