Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/browserView/electron-browser/browserViewCDPService.ts
13401 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 { Event } from '../../../../base/common/event.js';
7
import { Disposable } from '../../../../base/common/lifecycle.js';
8
import { ProxyChannel } from '../../../../base/parts/ipc/common/ipc.js';
9
import { CDPEvent, CDPRequest, CDPResponse } from '../../../../platform/browserView/common/cdp/types.js';
10
import { IBrowserViewGroupService, ipcBrowserViewGroupChannelName } from '../../../../platform/browserView/common/browserViewGroup.js';
11
import { IMainProcessService } from '../../../../platform/ipc/common/mainProcessService.js';
12
import { IBrowserViewCDPService } from '../common/browserView.js';
13
import { mainWindow } from '../../../../base/browser/window.js';
14
15
export class BrowserViewCDPService extends Disposable implements IBrowserViewCDPService {
16
declare readonly _serviceBrand: undefined;
17
18
private readonly _groupService: IBrowserViewGroupService;
19
20
constructor(
21
@IMainProcessService mainProcessService: IMainProcessService,
22
) {
23
super();
24
const channel = mainProcessService.getChannel(ipcBrowserViewGroupChannelName);
25
this._groupService = ProxyChannel.toService<IBrowserViewGroupService>(channel);
26
}
27
28
async createSessionGroup(browserId: string): Promise<string> {
29
const groupId = await this._groupService.createGroup({ mainWindowId: mainWindow.vscodeWindowId });
30
await this._groupService.addViewToGroup(groupId, browserId);
31
return groupId;
32
}
33
34
async destroySessionGroup(groupId: string): Promise<void> {
35
await this._groupService.destroyGroup(groupId);
36
}
37
38
async sendCDPMessage(groupId: string, message: CDPRequest): Promise<void> {
39
await this._groupService.sendCDPMessage(groupId, message);
40
}
41
42
onCDPMessage(groupId: string): Event<CDPResponse | CDPEvent> {
43
return this._groupService.onDynamicCDPMessage(groupId);
44
}
45
46
onDidDestroy(groupId: string): Event<void> {
47
return this._groupService.onDynamicDidDestroy(groupId);
48
}
49
}
50
51