Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ export class BrowserViewMainService extends Disposable implements IBrowserViewMa
@IApplicationStorageMainService private readonly applicationStorageMainService: IApplicationStorageMainService
) {
super();

this._register(this.windowsMainService.onDidDestroyWindow(window => {
if (this._perWindowTrustedRoots.delete(window.id)) {
this._recomputeTrustedFileRoots();
}
}));
}

async getOrCreateBrowserView(id: string, options: IBrowserViewCreateOptions): Promise<IBrowserViewState> {
Expand Down Expand Up @@ -329,10 +323,28 @@ export class BrowserViewMainService extends Disposable implements IBrowserViewMa

async updateTrustedFileRoots(windowId: number, roots: readonly string[]): Promise<void> {
this._perWindowTrustedRoots.set(windowId, roots);
this._ensureWindowCloseSubscription(windowId);
this._recomputeTrustedFileRoots();
}
Comment thread
kycutler marked this conversation as resolved.

private readonly _perWindowTrustedRoots = new Map<number, readonly string[]>();
private readonly _windowCloseSubscriptions = this._register(new DisposableMap<number>());
private _ensureWindowCloseSubscription(windowId: number): void {
if (this._windowCloseSubscriptions.has(windowId)) {
return;
}
const window = this.windowsMainService.getWindowById(windowId);
if (!window) {
return;
}
const onWindowGone = Event.any(window.onDidClose, window.onDidDestroy);
this._windowCloseSubscriptions.set(windowId, Event.once(onWindowGone)(() => {
this._windowCloseSubscriptions.deleteAndDispose(windowId);
if (this._perWindowTrustedRoots.delete(windowId)) {
this._recomputeTrustedFileRoots();
}
}));
}
private _recomputeTrustedFileRoots(): void {
const roots = new Set<string>();
for (const contribution of this._perWindowTrustedRoots.values()) {
Expand Down
Loading