Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions src/vs/platform/browserView/common/browserView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,10 @@ export interface IBrowserViewService {
* @param workspaceId The workspace identifier
*/
clearWorkspaceStorage(workspaceId: string): Promise<void>;

/**
* Clear storage data for a specific browser view
* @param id The browser view identifier
*/
clearStorage(id: string): Promise<void>;
}
9 changes: 8 additions & 1 deletion src/vs/platform/browserView/electron-main/browserView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class BrowserView extends Disposable {
readonly onDidClose: Event<void> = this._onDidClose.event;

constructor(
viewSession: Electron.Session,
private readonly viewSession: Electron.Session,
private readonly storageScope: BrowserViewStorageScope,
@IWindowsMainService private readonly windowsMainService: IWindowsMainService,
@IAuxiliaryWindowsMainService private readonly auxiliaryWindowsMainService: IAuxiliaryWindowsMainService
Expand Down Expand Up @@ -466,6 +466,13 @@ export class BrowserView extends Disposable {
this._view.webContents.stopFindInPage(keepSelection ? 'keepSelection' : 'clearSelection');
}

/**
* Clear all storage data for this browser view's session
*/
async clearStorage(): Promise<void> {
await this.viewSession.clearData();
}

/**
* Get the underlying WebContentsView
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ export class BrowserViewMainService extends Disposable implements IBrowserViewMa
return this._getBrowserView(id).stopFindInPage(keepSelection);
}

async clearStorage(id: string): Promise<void> {
return this._getBrowserView(id).clearStorage();
}

async clearGlobalStorage(): Promise<void> {
const { session, resolvedScope } = this.getSession(BrowserViewStorageScope.Global);
if (resolvedScope !== BrowserViewStorageScope.Global) {
Expand Down
5 changes: 5 additions & 0 deletions src/vs/workbench/contrib/browserView/common/browserView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export interface IBrowserViewModel extends IDisposable {
focus(): Promise<void>;
findInPage(text: string, options?: IBrowserViewFindInPageOptions): Promise<void>;
stopFindInPage(keepSelection?: boolean): Promise<void>;
clearStorage(): Promise<void>;
}

export class BrowserViewModel extends Disposable implements IBrowserViewModel {
Expand Down Expand Up @@ -320,6 +321,10 @@ export class BrowserViewModel extends Disposable implements IBrowserViewModel {
return this.browserViewService.stopFindInPage(this.id, keepSelection);
}

async clearStorage(): Promise<void> {
return this.browserViewService.clearStorage(this.id);
}

/**
* Log navigation telemetry event
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@ export class BrowserEditor extends EditorPane {
return this._model?.toggleDevTools();
}

async clearStorage(): Promise<void> {
return this._model?.clearStorage();
}

/**
* Show the find widget
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
],
markdownEnumDescriptions: [
localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'browser.dataStorage.global' }, 'All browser views share a single persistent session across all workspaces.'),
localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'browser.dataStorage.workspace' }, 'Browser views within the same workspace share a persistent session.'),
localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'browser.dataStorage.workspace' }, 'Browser views within the same workspace share a persistent session. If no workspace is opened, `ephemeral` storage is used.'),
localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'browser.dataStorage.ephemeral' }, 'Each browser view has its own session that is cleaned up when closed.')
],
restricted: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class ClearWorkspaceBrowserStorageAction extends Action2 {
menu: {
id: MenuId.BrowserActionsToolbar,
group: '3_settings',
order: 2,
order: 1,
when: ContextKeyExpr.equals(CONTEXT_BROWSER_STORAGE_SCOPE.key, BrowserViewStorageScope.Workspace)
}
});
Expand All @@ -293,6 +293,33 @@ class ClearWorkspaceBrowserStorageAction extends Action2 {
}
}

class ClearEphemeralBrowserStorageAction extends Action2 {
static readonly ID = 'workbench.action.browser.clearEphemeralStorage';

constructor() {
super({
id: ClearEphemeralBrowserStorageAction.ID,
title: localize2('browser.clearEphemeralStorageAction', 'Clear Storage (Ephemeral)'),
category: BrowserCategory,
icon: Codicon.clearAll,
f1: true,
precondition: BROWSER_EDITOR_ACTIVE,
menu: {
id: MenuId.BrowserActionsToolbar,
group: '3_settings',
order: 1,
when: ContextKeyExpr.equals(CONTEXT_BROWSER_STORAGE_SCOPE.key, BrowserViewStorageScope.Ephemeral)
}
});
}

async run(accessor: ServicesAccessor, browserEditor = accessor.get(IEditorService).activeEditorPane): Promise<void> {
if (browserEditor instanceof BrowserEditor) {
await browserEditor.clearStorage();
}
}
}

class OpenBrowserSettingsAction extends Action2 {
static readonly ID = 'workbench.action.browser.openSettings';

Expand All @@ -306,7 +333,7 @@ class OpenBrowserSettingsAction extends Action2 {
menu: {
id: MenuId.BrowserActionsToolbar,
group: '3_settings',
order: 3
order: 2
}
});
}
Expand Down Expand Up @@ -443,6 +470,7 @@ registerAction2(ToggleDevToolsAction);
registerAction2(OpenInExternalBrowserAction);
registerAction2(ClearGlobalBrowserStorageAction);
registerAction2(ClearWorkspaceBrowserStorageAction);
registerAction2(ClearEphemeralBrowserStorageAction);
registerAction2(OpenBrowserSettingsAction);
registerAction2(ShowBrowserFindAction);
registerAction2(HideBrowserFindAction);
Expand Down
Loading