diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index d69a37ffb0f..de09ab8f939 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -78,8 +78,6 @@ import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common import { StorageKeysSyncRegistryChannel } from 'vs/platform/userDataSync/common/userDataSyncIpc'; import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; import { mnemonicButtonLabel, getPathLabel } from 'vs/base/common/labels'; -import { IFileService } from 'vs/platform/files/common/files'; -import { WebviewChannel } from 'vs/platform/webview/electron-main/webviewIpcs'; import { WebviewMainService } from 'vs/platform/webview/electron-main/webviewMainService'; import { IWebviewManagerService } from 'vs/platform/webview/common/webviewManagerService'; @@ -90,7 +88,6 @@ export class CodeApplication extends Disposable { constructor( private readonly mainIpcServer: Server, private readonly userEnv: IProcessEnvironment, - @IFileService fileService: IFileService, @IInstantiationService private readonly instantiationService: IInstantiationService, @ILogService private readonly logService: ILogService, @IEnvironmentService private readonly environmentService: INativeEnvironmentService, @@ -580,7 +577,7 @@ export class CodeApplication extends Disposable { electronIpcServer.registerChannel('url', urlChannel); const webviewManagerService = accessor.get(IWebviewManagerService); - const webviewChannel = new WebviewChannel(webviewManagerService); + const webviewChannel = createChannelReceiver(webviewManagerService); electronIpcServer.registerChannel('webview', webviewChannel); const storageMainService = accessor.get(IStorageMainService); diff --git a/src/vs/platform/webview/common/webviewManagerService.ts b/src/vs/platform/webview/common/webviewManagerService.ts index 75a021dee8f..5a67ccbc3d4 100644 --- a/src/vs/platform/webview/common/webviewManagerService.ts +++ b/src/vs/platform/webview/common/webviewManagerService.ts @@ -15,7 +15,7 @@ export interface IWebviewManagerService { unregisterWebview(id: string): Promise; updateLocalResourceRoots(id: string, roots: UriComponents[]): Promise; - setIgnoreMenuShortcuts(webContentsId: number, enabled: boolean): void; + setIgnoreMenuShortcuts(webContentsId: number, enabled: boolean): Promise; } export interface RegisterWebviewMetadata { diff --git a/src/vs/platform/webview/electron-main/webviewIpcs.ts b/src/vs/platform/webview/electron-main/webviewIpcs.ts deleted file mode 100644 index 7f5aadb9fda..00000000000 --- a/src/vs/platform/webview/electron-main/webviewIpcs.ts +++ /dev/null @@ -1,34 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { Event } from 'vs/base/common/event'; -import { IServerChannel } from 'vs/base/parts/ipc/common/ipc'; -import { IWebviewManagerService } from 'vs/platform/webview/common/webviewManagerService'; - -type KeyWithParams = { - [K in keyof T]: T[K] extends (...args: infer P) => any ? [K, P] : never -}[keyof T]; - -export class WebviewChannel implements IServerChannel { - - constructor( - @IWebviewManagerService private readonly webviewMainService: IWebviewManagerService, - ) { } - - listen(_: unknown, event: string): Event { - throw new Error(`Event not found: ${event}`); - } - - async call(_: unknown, ...commandAndArgs: KeyWithParams): Promise { - switch (commandAndArgs[0]) { - case 'setIgnoreMenuShortcuts': this.webviewMainService.setIgnoreMenuShortcuts(...commandAndArgs[1]); return; - case 'registerWebview': this.webviewMainService.registerWebview(...commandAndArgs[1]); return; - case 'unregisterWebview': this.webviewMainService.unregisterWebview(...commandAndArgs[1]); return; - case 'updateLocalResourceRoots': this.webviewMainService.updateLocalResourceRoots(...commandAndArgs[1]); return; - } - - throw new Error(`Call not found: ${commandAndArgs[0]}`); - } -} diff --git a/src/vs/platform/webview/electron-main/webviewMainService.ts b/src/vs/platform/webview/electron-main/webviewMainService.ts index d7b36705579..93990e16fbd 100644 --- a/src/vs/platform/webview/electron-main/webviewMainService.ts +++ b/src/vs/platform/webview/electron-main/webviewMainService.ts @@ -36,7 +36,7 @@ export class WebviewMainService implements IWebviewManagerService { this.protocolProvider.updateLocalResourceRoots(id, roots.map((x: UriComponents) => URI.from(x))); } - public setIgnoreMenuShortcuts(webContentsId: number, enabled: boolean): void { + public async setIgnoreMenuShortcuts(webContentsId: number, enabled: boolean): Promise { const contents = webContents.fromId(webContentsId); if (!contents) { throw new Error(`Invalid webContentsId: ${webContentsId}`);