Path: blob/main/src/vs/platform/browserView/common/browserViewGroup.ts
13397 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 { IDisposable } from '../../../base/common/lifecycle.js';7import { IBrowserViewOwner } from './browserView.js';8import { CDPEvent, CDPRequest, CDPResponse } from './cdp/types.js';910export const ipcBrowserViewGroupChannelName = 'browserViewGroup';1112/**13* Fired when a browser view is added to or removed from a group.14*/15export interface IBrowserViewGroupViewEvent {16/** The ID of the browser view that was added or removed. */17readonly viewId: string;18}1920/**21* A browser view group - an isolated collection of browser views.22*23* This interface is shared between the main-process entity and remote proxies.24*/25export interface IBrowserViewGroup extends IDisposable {26readonly id: string;2728readonly onDidAddView: Event<IBrowserViewGroupViewEvent>;29readonly onDidRemoveView: Event<IBrowserViewGroupViewEvent>;30readonly onDidDestroy: Event<void>;31readonly onCDPMessage: Event<CDPResponse | CDPEvent>;3233addView(viewId: string): Promise<void>;34removeView(viewId: string): Promise<void>;35sendCDPMessage(msg: CDPRequest): Promise<void>;36}3738/**39* Common service for managing browser view groups across processes.40*41* A browser view group is an isolated collection of browser views that can be42* independently exposed to different services or CDP clients.43*44* This interface is consumed via {@link ProxyChannel}.45* The main-process implementation is {@link BrowserViewGroupMainService}.46*/47export interface IBrowserViewGroupService {4849// Dynamic events - one per group instance, keyed by group ID.50onDynamicDidAddView(groupId: string): Event<IBrowserViewGroupViewEvent>;51onDynamicDidRemoveView(groupId: string): Event<IBrowserViewGroupViewEvent>;52onDynamicDidDestroy(groupId: string): Event<void>;53onDynamicCDPMessage(groupId: string): Event<CDPResponse | CDPEvent>;5455/**56* Create a new browser view group.57* @param owner The owner of the group's lifecycle.58* @returns The id of the newly created group.59*/60createGroup(owner: IBrowserViewOwner): Promise<string>;6162/**63* Destroy a browser view group.64* Views in the group are **not** destroyed - they are simply detached.65* @param groupId The group identifier.66*/67destroyGroup(groupId: string): Promise<void>;6869/**70* Add a browser view to a group.71* A view can belong to multiple groups simultaneously.72* @param groupId The group identifier.73* @param viewId The browser view identifier.74*/75addViewToGroup(groupId: string, viewId: string): Promise<void>;7677/**78* Remove a browser view from a group.79* @param groupId The group identifier.80* @param viewId The browser view identifier.81*/82removeViewFromGroup(groupId: string, viewId: string): Promise<void>;8384/**85* Send a CDP message to a group's browser proxy.86* @param groupId The group identifier.87* @param message The CDP request.88*/89sendCDPMessage(groupId: string, message: CDPRequest): Promise<void>;90}919293