Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/services/extensionManagement/common/remoteExtensionManagementService.ts
3296 views
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 { IChannel } from '../../../../base/parts/ipc/common/ipc.js';
7
import { URI } from '../../../../base/common/uri.js';
8
import { DidChangeProfileEvent, IProfileAwareExtensionManagementService } from './extensionManagement.js';
9
import { IUriIdentityService } from '../../../../platform/uriIdentity/common/uriIdentity.js';
10
import { IRemoteUserDataProfilesService } from '../../userDataProfile/common/remoteUserDataProfiles.js';
11
import { ProfileAwareExtensionManagementChannelClient } from './extensionManagementChannelClient.js';
12
import { IUserDataProfileService } from '../../userDataProfile/common/userDataProfile.js';
13
import { IUserDataProfilesService } from '../../../../platform/userDataProfile/common/userDataProfile.js';
14
import { ExtensionIdentifier } from '../../../../platform/extensions/common/extensions.js';
15
import { IProductService } from '../../../../platform/product/common/productService.js';
16
import { IAllowedExtensionsService } from '../../../../platform/extensionManagement/common/extensionManagement.js';
17
18
export class RemoteExtensionManagementService extends ProfileAwareExtensionManagementChannelClient implements IProfileAwareExtensionManagementService {
19
20
constructor(
21
channel: IChannel,
22
@IProductService productService: IProductService,
23
@IAllowedExtensionsService allowedExtensionsService: IAllowedExtensionsService,
24
@IUserDataProfileService userDataProfileService: IUserDataProfileService,
25
@IUserDataProfilesService private readonly userDataProfilesService: IUserDataProfilesService,
26
@IRemoteUserDataProfilesService private readonly remoteUserDataProfilesService: IRemoteUserDataProfilesService,
27
@IUriIdentityService uriIdentityService: IUriIdentityService
28
) {
29
super(channel, productService, allowedExtensionsService, userDataProfileService, uriIdentityService);
30
}
31
32
protected async filterEvent(profileLocation: URI, applicationScoped: boolean): Promise<boolean> {
33
if (applicationScoped) {
34
return true;
35
}
36
if (!profileLocation && this.userDataProfileService.currentProfile.isDefault) {
37
return true;
38
}
39
const currentRemoteProfile = await this.remoteUserDataProfilesService.getRemoteProfile(this.userDataProfileService.currentProfile);
40
if (this.uriIdentityService.extUri.isEqual(currentRemoteProfile.extensionsResource, profileLocation)) {
41
return true;
42
}
43
return false;
44
}
45
46
protected override getProfileLocation(profileLocation: URI): Promise<URI>;
47
protected override getProfileLocation(profileLocation?: URI): Promise<URI | undefined>;
48
protected override async getProfileLocation(profileLocation?: URI): Promise<URI | undefined> {
49
if (!profileLocation && this.userDataProfileService.currentProfile.isDefault) {
50
return undefined;
51
}
52
profileLocation = await super.getProfileLocation(profileLocation);
53
let profile = this.userDataProfilesService.profiles.find(p => this.uriIdentityService.extUri.isEqual(p.extensionsResource, profileLocation));
54
if (profile) {
55
profile = await this.remoteUserDataProfilesService.getRemoteProfile(profile);
56
} else {
57
profile = (await this.remoteUserDataProfilesService.getRemoteProfiles()).find(p => this.uriIdentityService.extUri.isEqual(p.extensionsResource, profileLocation));
58
}
59
return profile?.extensionsResource;
60
}
61
62
protected override async switchExtensionsProfile(previousProfileLocation: URI, currentProfileLocation: URI, preserveExtensions?: ExtensionIdentifier[]): Promise<DidChangeProfileEvent> {
63
const remoteProfiles = await this.remoteUserDataProfilesService.getRemoteProfiles();
64
const previousProfile = remoteProfiles.find(p => this.uriIdentityService.extUri.isEqual(p.extensionsResource, previousProfileLocation));
65
const currentProfile = remoteProfiles.find(p => this.uriIdentityService.extUri.isEqual(p.extensionsResource, currentProfileLocation));
66
if (previousProfile?.id === currentProfile?.id) {
67
return { added: [], removed: [] };
68
}
69
return super.switchExtensionsProfile(previousProfileLocation, currentProfileLocation, preserveExtensions);
70
}
71
}
72
73