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:
authorMatt Bierner <matb@microsoft.com>2020-05-28 08:23:24 +0300
committerMatt Bierner <matb@microsoft.com>2020-05-28 08:24:50 +0300
commit229602bb7910060b727d5b40ea38f24d109b50ea (patch)
treea98e8dd07734c5b3a796e20672ed03f06f18c16d
parent7a4880a6bd68ba2d8432043877c431d28f4d5d2c (diff)
Use createChannelReceiver for webview manager
From https://github.com/microsoft/vscode/pull/98131#issuecomment-635104095
-rw-r--r--src/vs/code/electron-main/app.ts5
-rw-r--r--src/vs/platform/webview/common/webviewManagerService.ts2
-rw-r--r--src/vs/platform/webview/electron-main/webviewIpcs.ts34
-rw-r--r--src/vs/platform/webview/electron-main/webviewMainService.ts2
4 files changed, 3 insertions, 40 deletions
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<void>;
updateLocalResourceRoots(id: string, roots: UriComponents[]): Promise<void>;
- setIgnoreMenuShortcuts(webContentsId: number, enabled: boolean): void;
+ setIgnoreMenuShortcuts(webContentsId: number, enabled: boolean): Promise<void>;
}
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<T> = {
- [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<any> {
- throw new Error(`Event not found: ${event}`);
- }
-
- async call(_: unknown, ...commandAndArgs: KeyWithParams<IWebviewManagerService>): Promise<any> {
- 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<void> {
const contents = webContents.fromId(webContentsId);
if (!contents) {
throw new Error(`Invalid webContentsId: ${webContentsId}`);