Boolean Trust State (#121141)

* move to boolean-based trust state

* update api based on feedback
This commit is contained in:
SteVen Batten
2021-04-13 12:54:52 -07:00
committed by GitHub
parent 75f2ce9735
commit c5fab4faa3
23 changed files with 306 additions and 436 deletions

View File

@@ -16,7 +16,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { ILabelService } from 'vs/platform/label/common/label';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IRequestService } from 'vs/platform/request/common/request';
import { WorkspaceTrustStateChangeEvent, WorkspaceTrustRequestOptions, WorkspaceTrustState, IWorkspaceTrustManagementService, IWorkspaceTrustRequestService } from 'vs/platform/workspace/common/workspaceTrust';
import { WorkspaceTrustRequestOptions, IWorkspaceTrustManagementService, IWorkspaceTrustRequestService } from 'vs/platform/workspace/common/workspaceTrust';
import { IWorkspace, IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { isUntitledWorkspace } from 'vs/platform/workspaces/common/workspaces';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
@@ -55,13 +55,13 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
// The workspace file is provided be a unknown file system provider. It might come
// from the extension host. So initialize now knowing that `rootPath` is undefined.
if (workspace.configuration && !isNative && !fileService.canHandleResource(workspace.configuration)) {
this._proxy.$initializeWorkspace(this.getWorkspaceData(workspace), this.getWorkspaceTrustState());
this._proxy.$initializeWorkspace(this.getWorkspaceData(workspace), this.isWorkspaceTrusted());
} else {
this._contextService.getCompleteWorkspace().then(workspace => this._proxy.$initializeWorkspace(this.getWorkspaceData(workspace), this.getWorkspaceTrustState()));
this._contextService.getCompleteWorkspace().then(workspace => this._proxy.$initializeWorkspace(this.getWorkspaceData(workspace), this.isWorkspaceTrusted()));
}
this._contextService.onDidChangeWorkspaceFolders(this._onDidChangeWorkspace, this, this._toDispose);
this._contextService.onDidChangeWorkbenchState(this._onDidChangeWorkspace, this, this._toDispose);
this._workspaceTrustManagementService.onDidChangeTrustState(this._onDidChangeWorkspaceTrustState, this, this._toDispose);
this._workspaceTrustManagementService.onDidChangeTrust(this._onDidReceiveWorkspaceTrust, this, this._toDispose);
}
dispose(): void {
@@ -209,15 +209,15 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
// --- trust ---
$requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState | undefined> {
$requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<boolean> {
return this._workspaceTrustRequestService.requestWorkspaceTrust(options);
}
private getWorkspaceTrustState(): WorkspaceTrustState {
return this._workspaceTrustManagementService.getWorkspaceTrustState();
private isWorkspaceTrusted(): boolean {
return this._workspaceTrustManagementService.isWorkpaceTrusted();
}
private _onDidChangeWorkspaceTrustState(state: WorkspaceTrustStateChangeEvent): void {
this._proxy.$onDidChangeWorkspaceTrustState(state);
private _onDidReceiveWorkspaceTrust(): void {
this._proxy.$onDidReceiveWorkspaceTrust();
}
}