Skip to content

Commit 89f0630

Browse files
committed
read extensions resource from userDataProfileService
1 parent b4525a7 commit 89f0630

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
7+
import { IFileService } from 'vs/platform/files/common/files';
8+
import { ILogService } from 'vs/platform/log/common/log';
9+
import { IUserDataProfilesService, UserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
10+
11+
export class BrowserUserDataProfilesService extends UserDataProfilesService implements IUserDataProfilesService {
12+
13+
constructor(
14+
@IEnvironmentService environmentService: IEnvironmentService,
15+
@IFileService fileService: IFileService,
16+
@ILogService logService: ILogService,
17+
) {
18+
super(environmentService, fileService, logService);
19+
this._profiles = [this.createDefaultUserDataProfile(true)];
20+
}
21+
22+
}

src/vs/platform/userDataProfile/electron-sandbox/userDataProfile.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ export class UserDataProfilesNativeService extends UserDataProfilesService imple
1616

1717
private readonly channel: IChannel;
1818

19-
override get profiles(): IUserDataProfile[] { return this._profiles; }
20-
2119
constructor(
2220
profiles: UriDto<IUserDataProfile>[],
2321
@IMainProcessService mainProcessService: IMainProcessService,

src/vs/workbench/browser/web.main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,14 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
7373
import { IProgressService } from 'vs/platform/progress/common/progress';
7474
import { DelayedLogChannel } from 'vs/workbench/services/output/common/delayedLogChannel';
7575
import { dirname, joinPath } from 'vs/base/common/resources';
76-
import { IUserDataProfilesService, UserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
76+
import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
7777
import { NullPolicyService } from 'vs/platform/policy/common/policy';
7878
import { IRemoteExplorerService, TunnelSource } from 'vs/workbench/services/remote/common/remoteExplorerService';
7979
import { DisposableTunnel } from 'vs/platform/tunnel/common/tunnel';
8080
import { ILabelService } from 'vs/platform/label/common/label';
8181
import { UserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfileService';
8282
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
83+
import { BrowserUserDataProfilesService } from 'vs/platform/userDataProfile/browser/userDataProfile';
8384

8485
export class BrowserMain extends Disposable {
8586

@@ -260,7 +261,7 @@ export class BrowserMain extends Disposable {
260261
await this.registerFileSystemProviders(environmentService, fileService, remoteAgentService, logService, logsPath);
261262

262263
// User Data Profiles
263-
const userDataProfilesService = new UserDataProfilesService(environmentService, fileService, logService);
264+
const userDataProfilesService = new BrowserUserDataProfilesService(environmentService, fileService, logService);
264265
serviceCollection.set(IUserDataProfilesService, userDataProfilesService);
265266

266267
const userDataProfileService = new UserDataProfileService(userDataProfilesService.defaultProfile, userDataProfilesService);

src/vs/workbench/services/extensionManagement/browser/webExtensionsScannerService.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { IProductService } from 'vs/platform/product/common/productService';
4040
import { validateExtensionManifest } from 'vs/platform/extensions/common/extensionValidator';
4141
import Severity from 'vs/base/common/severity';
4242
import { IStringDictionary } from 'vs/base/common/collections';
43+
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
4344

4445
type GalleryExtensionInfo = { readonly id: string; preRelease?: boolean; migrateStorageFrom?: string };
4546
type ExtensionInfo = { readonly id: string; preRelease: boolean };
@@ -83,7 +84,6 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
8384

8485
private readonly systemExtensionsCacheResource: URI | undefined = undefined;
8586
private readonly customBuiltinExtensionsCacheResource: URI | undefined = undefined;
86-
private readonly installedExtensionsResource: URI | undefined = undefined;
8787
private readonly resourcesAccessQueueMap = new ResourceMap<Queue<IWebExtension[]>>();
8888

8989
constructor(
@@ -97,11 +97,11 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
9797
@IExtensionStorageService private readonly extensionStorageService: IExtensionStorageService,
9898
@IStorageService private readonly storageService: IStorageService,
9999
@IProductService private readonly productService: IProductService,
100+
@IUserDataProfileService private readonly userDataProfileService: IUserDataProfileService,
100101
@ILifecycleService lifecycleService: ILifecycleService,
101102
) {
102103
super();
103104
if (isWeb) {
104-
this.installedExtensionsResource = joinPath(environmentService.userRoamingDataHome, 'extensions.json');
105105
this.systemExtensionsCacheResource = joinPath(environmentService.userRoamingDataHome, 'systemExtensionsCache.json');
106106
this.customBuiltinExtensionsCacheResource = joinPath(environmentService.userRoamingDataHome, 'customBuiltinExtensionsCache.json');
107107
this.registerActions();
@@ -672,15 +672,15 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
672672

673673
private async readInstalledExtensions(): Promise<IWebExtension[]> {
674674
await this.migratePackageNLSUris();
675-
return this.withWebExtensions(this.installedExtensionsResource);
675+
return this.withWebExtensions(this.userDataProfileService.currentProfile.extensionsResource);
676676
}
677677

678678
// TODO: @TylerLeonhardt/@Sandy081: Delete after 6 months
679679
private _migratePackageNLSUrisPromise: Promise<void> | undefined;
680680
private migratePackageNLSUris(): Promise<void> {
681681
if (!this._migratePackageNLSUrisPromise) {
682682
this._migratePackageNLSUrisPromise = (async () => {
683-
const webExtensions = await this.withWebExtensions(this.installedExtensionsResource);
683+
const webExtensions = await this.withWebExtensions(this.userDataProfileService.currentProfile.extensionsResource);
684684
if (webExtensions.some(e => !e.packageNLSUris && e.packageNLSUri)) {
685685
const migratedExtensions = await Promise.all(webExtensions.map(async e => {
686686
if (!e.packageNLSUris && e.packageNLSUri) {
@@ -691,15 +691,15 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
691691
}
692692
return e;
693693
}));
694-
await this.withWebExtensions(this.installedExtensionsResource, () => migratedExtensions);
694+
await this.withWebExtensions(this.userDataProfileService.currentProfile.extensionsResource, () => migratedExtensions);
695695
}
696696
})();
697697
}
698698
return this._migratePackageNLSUrisPromise;
699699
}
700700

701701
private writeInstalledExtensions(updateFn: (extensions: IWebExtension[]) => IWebExtension[]): Promise<IWebExtension[]> {
702-
return this.withWebExtensions(this.installedExtensionsResource, updateFn);
702+
return this.withWebExtensions(this.userDataProfileService.currentProfile.extensionsResource, updateFn);
703703
}
704704

705705
private readCustomBuiltinExtensionsCache(): Promise<IWebExtension[]> {
@@ -809,7 +809,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
809809
});
810810
}
811811
run(serviceAccessor: ServicesAccessor): void {
812-
serviceAccessor.get(IEditorService).openEditor({ resource: that.installedExtensionsResource });
812+
serviceAccessor.get(IEditorService).openEditor({ resource: that.userDataProfileService.currentProfile.extensionsResource });
813813
}
814814
}));
815815
}

0 commit comments

Comments
 (0)