Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandeep Somavarapu <sasomava@microsoft.com>2022-10-12 13:08:52 +0300
committerGitHub <noreply@github.com>2022-10-12 13:08:52 +0300
commitd045a5eda657f4d7b676dedbfa7aab8207f8a075 (patch)
tree2b57d8417882059c3c701791590b7e72987b3034
parent4ca683019ed66c1648b8b49fee5ad08e06df4a2c (diff)
parentd769a2f94585d6ca2a9e188976e81ff5448e6d53 (diff)
Merge pull request #163414 from microsoft/sandy081/dangerous-catfish1.72.2
Fix #163005 (#163339)
-rw-r--r--src/vs/workbench/services/extensionManagement/common/extensionManagementServerService.ts13
-rw-r--r--src/vs/workbench/services/extensionManagement/common/remoteExtensionManagementService.ts62
2 files changed, 65 insertions, 10 deletions
diff --git a/src/vs/workbench/services/extensionManagement/common/extensionManagementServerService.ts b/src/vs/workbench/services/extensionManagement/common/extensionManagementServerService.ts
index 4db3f9b85cc..732c9bd3a02 100644
--- a/src/vs/workbench/services/extensionManagement/common/extensionManagementServerService.ts
+++ b/src/vs/workbench/services/extensionManagement/common/extensionManagementServerService.ts
@@ -4,10 +4,9 @@
*--------------------------------------------------------------------------------------------*/
import { localize } from 'vs/nls';
-import { ExtensionInstallLocation, IExtensionManagementServer, IExtensionManagementServerService, IProfileAwareExtensionManagementService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
+import { ExtensionInstallLocation, IExtensionManagementServer, IExtensionManagementServerService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { Schemas } from 'vs/base/common/network';
-import { Event } from 'vs/base/common/event';
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { ILabelService } from 'vs/platform/label/common/label';
@@ -15,7 +14,7 @@ import { isWeb } from 'vs/base/common/platform';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { WebExtensionManagementService } from 'vs/workbench/services/extensionManagement/common/webExtensionManagementService';
import { IExtension } from 'vs/platform/extensions/common/extensions';
-import { ExtensionManagementChannelClient } from 'vs/platform/extensionManagement/common/extensionManagementIpc';
+import { RemoteExtensionManagementService } from 'vs/workbench/services/extensionManagement/common/remoteExtensionManagementService';
export class ExtensionManagementServerService implements IExtensionManagementServerService {
@@ -32,13 +31,7 @@ export class ExtensionManagementServerService implements IExtensionManagementSer
) {
const remoteAgentConnection = remoteAgentService.getConnection();
if (remoteAgentConnection) {
- const extensionManagementService = new class extends ExtensionManagementChannelClient implements IProfileAwareExtensionManagementService {
- get onProfileAwareInstallExtension() { return super.onInstallExtension; }
- get onProfileAwareDidInstallExtensions() { return super.onDidInstallExtensions; }
- get onProfileAwareUninstallExtension() { return super.onUninstallExtension; }
- get onProfileAwareDidUninstallExtension() { return super.onDidUninstallExtension; }
- readonly onDidChangeProfile = Event.None;
- }(remoteAgentConnection.getChannel<IChannel>('extensions'));
+ const extensionManagementService = instantiationService.createInstance(RemoteExtensionManagementService, remoteAgentConnection.getChannel<IChannel>('extensions'));
this.remoteExtensionManagementServer = {
id: 'remote',
extensionManagementService,
diff --git a/src/vs/workbench/services/extensionManagement/common/remoteExtensionManagementService.ts b/src/vs/workbench/services/extensionManagement/common/remoteExtensionManagementService.ts
new file mode 100644
index 00000000000..3a364fd2052
--- /dev/null
+++ b/src/vs/workbench/services/extensionManagement/common/remoteExtensionManagementService.ts
@@ -0,0 +1,62 @@
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+import { IChannel } from 'vs/base/parts/ipc/common/ipc';
+import { Event } from 'vs/base/common/event';
+import { ILocalExtension, IGalleryExtension, InstallOptions, InstallVSIXOptions, UninstallOptions } from 'vs/platform/extensionManagement/common/extensionManagement';
+import { URI } from 'vs/base/common/uri';
+import { ExtensionType } from 'vs/platform/extensions/common/extensions';
+import { IProfileAwareExtensionManagementService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
+import { ExtensionManagementChannelClient } from 'vs/platform/extensionManagement/common/extensionManagementIpc';
+import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
+import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
+
+export class RemoteExtensionManagementService extends ExtensionManagementChannelClient implements IProfileAwareExtensionManagementService {
+
+ readonly onDidChangeProfile = Event.None;
+ get onProfileAwareInstallExtension() { return super.onInstallExtension; }
+ get onProfileAwareDidInstallExtensions() { return super.onDidInstallExtensions; }
+ get onProfileAwareUninstallExtension() { return super.onUninstallExtension; }
+ get onProfileAwareDidUninstallExtension() { return super.onDidUninstallExtension; }
+
+ constructor(
+ channel: IChannel,
+ @IUserDataProfilesService private readonly userDataProfileService: IUserDataProfilesService,
+ @IUriIdentityService private readonly uriIdentityService: IUriIdentityService,
+ ) {
+ super(channel);
+ }
+
+ override getInstalled(type: ExtensionType | null = null, profileLocation?: URI): Promise<ILocalExtension[]> {
+ this.validateProfileLocation({ profileLocation });
+ return super.getInstalled(type);
+ }
+
+ override uninstall(extension: ILocalExtension, options?: UninstallOptions): Promise<void> {
+ options = this.validateProfileLocation(options);
+ return super.uninstall(extension, options);
+ }
+
+ override async install(vsix: URI, options?: InstallVSIXOptions): Promise<ILocalExtension> {
+ options = this.validateProfileLocation(options);
+ return super.install(vsix, options);
+ }
+
+ override async installFromGallery(extension: IGalleryExtension, options?: InstallOptions): Promise<ILocalExtension> {
+ options = this.validateProfileLocation(options);
+ return super.installFromGallery(extension, options);
+ }
+
+ private validateProfileLocation<T extends { profileLocation?: URI }>(options?: T): T | undefined {
+ if (options?.profileLocation) {
+ if (!this.uriIdentityService.extUri.isEqual(options?.profileLocation, this.userDataProfileService.defaultProfile.extensionsResource)) {
+ throw new Error('This operataion is not supported in remote scenario');
+ }
+ options = { ...options, profileLocation: undefined };
+ }
+ return options;
+ }
+
+}