diff --git a/src/vs/platform/workspace/common/workspaceTrust.ts b/src/vs/platform/workspace/common/workspaceTrust.ts index 629eddaf9a0..d656caecb36 100644 --- a/src/vs/platform/workspace/common/workspaceTrust.ts +++ b/src/vs/platform/workspace/common/workspaceTrust.ts @@ -45,7 +45,7 @@ export interface IWorkspaceTrustModel { } export interface IWorkspaceTrustRequest { - immediate: boolean; + modal: boolean; message?: string; } diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 87f38977342..13fc8277203 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -2816,9 +2816,11 @@ declare module 'vscode' { /** * Prompt the user to chose whether to trust the current workspace - * @param message Optional message which would be displayed in the prompt + * @param modal When true, a modal dialog is used to prompt the user for workspace + * trust, otherwise a badge will be shown on the Settings activity bar item. + * Default value is true. */ - export function requireWorkspaceTrust(message?: string): Thenable; + export function requireWorkspaceTrust(modal?: boolean): Thenable; /** * Event that fires when the trust state of the current workspace changes diff --git a/src/vs/workbench/api/browser/mainThreadWorkspace.ts b/src/vs/workbench/api/browser/mainThreadWorkspace.ts index bd8725fd299..c2a442bcc52 100644 --- a/src/vs/workbench/api/browser/mainThreadWorkspace.ts +++ b/src/vs/workbench/api/browser/mainThreadWorkspace.ts @@ -208,8 +208,8 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape { // --- trust --- - $requireWorkspaceTrust(message?: string): Promise { - return this._workspaceTrustService.requireWorkspaceTrust({ immediate: true, message }); + $requireWorkspaceTrust(modal?: boolean): Promise { + return this._workspaceTrustService.requireWorkspaceTrust({ modal: modal ?? true }); } private getWorkspaceTrustState(): WorkspaceTrustState { diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 5f83c9abe57..2a9ee2731de 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -900,10 +900,10 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I checkRequiresWorkspaceTrust(extension); return extHostWorkspace.trustState; }, - requireWorkspaceTrust: (message?: string) => { + requireWorkspaceTrust: (modal?: boolean) => { checkProposedApiEnabled(extension); checkRequiresWorkspaceTrust(extension); - return extHostWorkspace.requireWorkspaceTrust(message); + return extHostWorkspace.requireWorkspaceTrust(modal); }, onDidChangeWorkspaceTrustState: (listener, thisArgs?, disposables?) => { return extHostWorkspace.onDidChangeWorkspaceTrustState(listener, thisArgs, disposables); diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index deba66dbfc1..0e15a91c0d8 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -833,7 +833,7 @@ export interface MainThreadWorkspaceShape extends IDisposable { $saveAll(includeUntitled?: boolean): Promise; $updateWorkspaceFolders(extensionName: string, index: number, deleteCount: number, workspaceFoldersToAdd: { uri: UriComponents, name?: string; }[]): Promise; $resolveProxy(url: string): Promise; - $requireWorkspaceTrust(message?: string): Promise + $requireWorkspaceTrust(modal?: boolean): Promise } export interface IFileChangeDto { diff --git a/src/vs/workbench/api/common/extHostWorkspace.ts b/src/vs/workbench/api/common/extHostWorkspace.ts index f73edbc8445..2b368c67b63 100644 --- a/src/vs/workbench/api/common/extHostWorkspace.ts +++ b/src/vs/workbench/api/common/extHostWorkspace.ts @@ -563,8 +563,8 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac return this._workspaceTrustState; } - requireWorkspaceTrust(message?: string): Promise { - return this._proxy.$requireWorkspaceTrust(message); + requireWorkspaceTrust(modal?: boolean): Promise { + return this._proxy.$requireWorkspaceTrust(modal); } $onDidChangeWorkspaceTrustState(state: WorkspaceTrustStateChangeEvent): void { diff --git a/src/vs/workbench/contrib/tasks/browser/runAutomaticTasks.ts b/src/vs/workbench/contrib/tasks/browser/runAutomaticTasks.ts index 7c5b14327d3..74ce4b72106 100644 --- a/src/vs/workbench/contrib/tasks/browser/runAutomaticTasks.ts +++ b/src/vs/workbench/contrib/tasks/browser/runAutomaticTasks.ts @@ -116,7 +116,7 @@ export class RunAutomaticTasks extends Disposable implements IWorkbenchContribut public static async promptForPermission(taskService: ITaskService, storageService: IStorageService, notificationService: INotificationService, workspaceTrustService: IWorkspaceTrustService, openerService: IOpenerService, workspaceTaskResult: Map) { - const isWorkspaceTrusted = await workspaceTrustService.requireWorkspaceTrust({ immediate: false }) === WorkspaceTrustState.Trusted; + const isWorkspaceTrusted = await workspaceTrustService.requireWorkspaceTrust({ modal: false }) === WorkspaceTrustState.Trusted; if (!isWorkspaceTrusted) { return; } diff --git a/src/vs/workbench/contrib/workspace/browser/workspace.contribution.ts b/src/vs/workbench/contrib/workspace/browser/workspace.contribution.ts index 6240c337b3a..cc239761e6a 100644 --- a/src/vs/workbench/contrib/workspace/browser/workspace.contribution.ts +++ b/src/vs/workbench/contrib/workspace/browser/workspace.contribution.ts @@ -69,7 +69,7 @@ export class WorkspaceTrustRequestHandler extends Disposable implements IWorkben if (this.requestModel.trustRequest) { this.toggleRequestBadge(true); - if (this.requestModel.trustRequest.immediate) { + if (this.requestModel.trustRequest.modal) { const result = await this.dialogService.show( Severity.Warning, localize('immediateTrustRequestTitle', "Do you trust the files in this folder?"), diff --git a/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts b/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts index d5e0e57ec7b..e0fa8953b67 100644 --- a/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts +++ b/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts @@ -68,7 +68,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench // TODO: Confirm that this is the right lifecycle phase this.lifecycleService.when(LifecyclePhase.Eventually).then(() => { if (this.extensionsDisabledByTrustRequirement.length > 0) { - this.workspaceTrustService.requireWorkspaceTrust({ immediate: false }); + this.workspaceTrustService.requireWorkspaceTrust({ modal: false }); } }); @@ -166,7 +166,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench const result = await Promises.settled(extensions.map(e => { if (this._isDisabledByTrustRequirement(e)) { return this.workspaceTrustService.requireWorkspaceTrust({ - immediate: true, + modal: true, message: 'Enabling this extension requires you to trust the contents of this workspace.' }).then(trustState => { if (trustState === WorkspaceTrustState.Trusted) { @@ -456,7 +456,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench private _onDidInstallExtension({ local, error }: DidInstallExtensionEvent): void { if (local && !error && this._isDisabledByTrustRequirement(local)) { this.workspaceTrustService.requireWorkspaceTrust({ - immediate: true, + modal: true, message: 'Enabling this extension requires you to trust the contents of this workspace.' }); } diff --git a/src/vs/workbench/services/extensionManagement/common/extensionManagementService.ts b/src/vs/workbench/services/extensionManagement/common/extensionManagementService.ts index 93d35892e9f..216e6b92e34 100644 --- a/src/vs/workbench/services/extensionManagement/common/extensionManagementService.ts +++ b/src/vs/workbench/services/extensionManagement/common/extensionManagementService.ts @@ -360,7 +360,7 @@ export class ExtensionManagementService extends Disposable implements IWorkbench if (manifest.requiresWorkspaceTrust === 'onStart') { const trustState = await this.workspaceTrustService.requireWorkspaceTrust( { - immediate: true, + modal: true, message: 'Installing this extension requires you to trust the contents of this workspace.' }); return trustState === WorkspaceTrustState.Trusted ? Promise.resolve() : Promise.reject(canceled()); diff --git a/src/vs/workbench/services/workspaces/common/workspaceTrust.ts b/src/vs/workbench/services/workspaces/common/workspaceTrust.ts index f048e4d411d..351b00a6ce5 100644 --- a/src/vs/workbench/services/workspaces/common/workspaceTrust.ts +++ b/src/vs/workbench/services/workspaces/common/workspaceTrust.ts @@ -187,7 +187,7 @@ export class WorkspaceTrustRequestModel extends Disposable implements IWorkspace readonly onDidCompleteRequest = this._onDidCompleteRequest.event; initiateRequest(request: IWorkspaceTrustRequest): void { - if (this.trustRequest && (!request.immediate || this.trustRequest.immediate)) { + if (this.trustRequest && (!request.modal || this.trustRequest.modal)) { return; } @@ -323,14 +323,14 @@ export class WorkspaceTrustService extends Disposable implements IWorkspaceTrust if (this.currentTrustState === WorkspaceTrustState.Trusted) { return this.currentTrustState; } - if (this.currentTrustState === WorkspaceTrustState.Untrusted && !request?.immediate) { + if (this.currentTrustState === WorkspaceTrustState.Untrusted && !request?.modal) { return this.currentTrustState; } if (this._trustRequestPromise) { - if (request?.immediate && + if (request?.modal && this.requestModel.trustRequest && - !this.requestModel.trustRequest.immediate) { + !this.requestModel.trustRequest.modal) { this.requestModel.initiateRequest(request); }