Path: blob/main/src/vs/workbench/contrib/browserView/electron-browser/browserViewCDPService.ts
13401 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Event } from '../../../../base/common/event.js';6import { Disposable } from '../../../../base/common/lifecycle.js';7import { ProxyChannel } from '../../../../base/parts/ipc/common/ipc.js';8import { CDPEvent, CDPRequest, CDPResponse } from '../../../../platform/browserView/common/cdp/types.js';9import { IBrowserViewGroupService, ipcBrowserViewGroupChannelName } from '../../../../platform/browserView/common/browserViewGroup.js';10import { IMainProcessService } from '../../../../platform/ipc/common/mainProcessService.js';11import { IBrowserViewCDPService } from '../common/browserView.js';12import { mainWindow } from '../../../../base/browser/window.js';1314export class BrowserViewCDPService extends Disposable implements IBrowserViewCDPService {15declare readonly _serviceBrand: undefined;1617private readonly _groupService: IBrowserViewGroupService;1819constructor(20@IMainProcessService mainProcessService: IMainProcessService,21) {22super();23const channel = mainProcessService.getChannel(ipcBrowserViewGroupChannelName);24this._groupService = ProxyChannel.toService<IBrowserViewGroupService>(channel);25}2627async createSessionGroup(browserId: string): Promise<string> {28const groupId = await this._groupService.createGroup({ mainWindowId: mainWindow.vscodeWindowId });29await this._groupService.addViewToGroup(groupId, browserId);30return groupId;31}3233async destroySessionGroup(groupId: string): Promise<void> {34await this._groupService.destroyGroup(groupId);35}3637async sendCDPMessage(groupId: string, message: CDPRequest): Promise<void> {38await this._groupService.sendCDPMessage(groupId, message);39}4041onCDPMessage(groupId: string): Event<CDPResponse | CDPEvent> {42return this._groupService.onDynamicCDPMessage(groupId);43}4445onDidDestroy(groupId: string): Event<void> {46return this._groupService.onDynamicDidDestroy(groupId);47}48}495051