1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 09:13:33 +00:00

[AC-2008] [AC-2122] [Pt 1] Transition PolicyService to use StateProvider (#7959)

* Delete unnecessary StateDefinition

* Add StateProvider to PolicyService

* Add new getters using StateProvider (not exposed or used yet)
This commit is contained in:
Thomas Rittson
2024-02-27 08:51:10 +10:00
committed by GitHub
parent 996823169a
commit 0a5c9d3525
10 changed files with 363 additions and 22 deletions

View File

@@ -5,6 +5,10 @@ import {
factory,
FactoryOptions,
} from "../../../platform/background/service-factories/factory-options";
import {
stateProviderFactory,
StateProviderInitOptions,
} from "../../../platform/background/service-factories/state-provider.factory";
import {
stateServiceFactory as stateServiceFactory,
StateServiceInitOptions,
@@ -20,6 +24,7 @@ type PolicyServiceFactoryOptions = FactoryOptions;
export type PolicyServiceInitOptions = PolicyServiceFactoryOptions &
StateServiceInitOptions &
StateProviderInitOptions &
OrganizationServiceInitOptions;
export function policyServiceFactory(
@@ -33,6 +38,7 @@ export function policyServiceFactory(
async () =>
new BrowserPolicyService(
await stateServiceFactory(cache, opts),
await stateProviderFactory(cache, opts),
await organizationServiceFactory(cache, opts),
),
);

View File

@@ -473,7 +473,11 @@ export default class MainBackground {
this.stateService,
this.stateProvider,
);
this.policyService = new BrowserPolicyService(this.stateService, this.organizationService);
this.policyService = new BrowserPolicyService(
this.stateService,
this.stateProvider,
this.organizationService,
);
this.autofillSettingsService = new AutofillSettingsService(
this.stateProvider,
this.policyService,

View File

@@ -326,11 +326,12 @@ function getBgService<T>(service: keyof MainBackground) {
provide: PolicyService,
useFactory: (
stateService: StateServiceAbstraction,
stateProvider: StateProvider,
organizationService: OrganizationService,
) => {
return new BrowserPolicyService(stateService, organizationService);
return new BrowserPolicyService(stateService, stateProvider, organizationService);
},
deps: [StateServiceAbstraction, OrganizationService],
deps: [StateServiceAbstraction, StateProvider, OrganizationService],
},
{
provide: PolicyApiServiceAbstraction,

View File

@@ -375,7 +375,11 @@ export class Main {
this.organizationUserService = new OrganizationUserServiceImplementation(this.apiService);
this.policyService = new PolicyService(this.stateService, this.organizationService);
this.policyService = new PolicyService(
this.stateService,
this.stateProvider,
this.organizationService,
);
this.policyApiService = new PolicyApiService(
this.policyService,