Refactor requireWorkspaceTrust to requestWorkspaceTrust
This commit is contained in:
parent
be5170cc19
commit
648ea3d1e0
12 changed files with 18 additions and 18 deletions
|
@ -39,7 +39,7 @@ export class TypeScriptVersionManager extends Disposable {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
vscode.workspace.requireWorkspaceTrust({ modal: false })
|
vscode.workspace.requestWorkspaceTrust({ modal: false })
|
||||||
.then(trustState => {
|
.then(trustState => {
|
||||||
if (trustState === vscode.WorkspaceTrustState.Trusted && this.versionProvider.localVersion) {
|
if (trustState === vscode.WorkspaceTrustState.Trusted && this.versionProvider.localVersion) {
|
||||||
this.updateActiveVersion(this.versionProvider.localVersion);
|
this.updateActiveVersion(this.versionProvider.localVersion);
|
||||||
|
@ -120,7 +120,7 @@ export class TypeScriptVersionManager extends Disposable {
|
||||||
description: version.displayName,
|
description: version.displayName,
|
||||||
detail: version.pathLabel,
|
detail: version.pathLabel,
|
||||||
run: async () => {
|
run: async () => {
|
||||||
const trustState = await vscode.workspace.requireWorkspaceTrust();
|
const trustState = await vscode.workspace.requestWorkspaceTrust();
|
||||||
if (trustState === vscode.WorkspaceTrustState.Trusted) {
|
if (trustState === vscode.WorkspaceTrustState.Trusted) {
|
||||||
await this.workspaceState.update(useWorkspaceTsdkStorageKey, true);
|
await this.workspaceState.update(useWorkspaceTsdkStorageKey, true);
|
||||||
const tsConfig = vscode.workspace.getConfiguration('typescript');
|
const tsConfig = vscode.workspace.getConfiguration('typescript');
|
||||||
|
|
|
@ -84,7 +84,7 @@ export interface IWorkspaceTrustService {
|
||||||
onDidChangeTrustState: WorkspaceTrustChangeEvent;
|
onDidChangeTrustState: WorkspaceTrustChangeEvent;
|
||||||
getWorkspaceTrustState(): WorkspaceTrustState;
|
getWorkspaceTrustState(): WorkspaceTrustState;
|
||||||
isWorkspaceTrustEnabled(): boolean;
|
isWorkspaceTrustEnabled(): boolean;
|
||||||
requireWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState>;
|
requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IWorkspaceTrustUriInfo {
|
export interface IWorkspaceTrustUriInfo {
|
||||||
|
|
2
src/vs/vscode.proposed.d.ts
vendored
2
src/vs/vscode.proposed.d.ts
vendored
|
@ -2836,7 +2836,7 @@ declare module 'vscode' {
|
||||||
* @param options Optional object describing the properties of the
|
* @param options Optional object describing the properties of the
|
||||||
* workspace trust request
|
* workspace trust request
|
||||||
*/
|
*/
|
||||||
export function requireWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Thenable<WorkspaceTrustState>;
|
export function requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Thenable<WorkspaceTrustState>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event that fires when the trust state of the current workspace changes
|
* Event that fires when the trust state of the current workspace changes
|
||||||
|
|
|
@ -208,8 +208,8 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
|
||||||
|
|
||||||
// --- trust ---
|
// --- trust ---
|
||||||
|
|
||||||
$requireWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState> {
|
$requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState> {
|
||||||
return this._workspaceTrustService.requireWorkspaceTrust(options);
|
return this._workspaceTrustService.requestWorkspaceTrust(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getWorkspaceTrustState(): WorkspaceTrustState {
|
private getWorkspaceTrustState(): WorkspaceTrustState {
|
||||||
|
|
|
@ -912,9 +912,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||||
checkProposedApiEnabled(extension);
|
checkProposedApiEnabled(extension);
|
||||||
return extHostWorkspace.trustState;
|
return extHostWorkspace.trustState;
|
||||||
},
|
},
|
||||||
requireWorkspaceTrust: (options?: vscode.WorkspaceTrustRequestOptions) => {
|
requestWorkspaceTrust: (options?: vscode.WorkspaceTrustRequestOptions) => {
|
||||||
checkProposedApiEnabled(extension);
|
checkProposedApiEnabled(extension);
|
||||||
return extHostWorkspace.requireWorkspaceTrust(options);
|
return extHostWorkspace.requestWorkspaceTrust(options);
|
||||||
},
|
},
|
||||||
onDidChangeWorkspaceTrustState: (listener, thisArgs?, disposables?) => {
|
onDidChangeWorkspaceTrustState: (listener, thisArgs?, disposables?) => {
|
||||||
return extHostWorkspace.onDidChangeWorkspaceTrustState(listener, thisArgs, disposables);
|
return extHostWorkspace.onDidChangeWorkspaceTrustState(listener, thisArgs, disposables);
|
||||||
|
|
|
@ -927,7 +927,7 @@ export interface MainThreadWorkspaceShape extends IDisposable {
|
||||||
$saveAll(includeUntitled?: boolean): Promise<boolean>;
|
$saveAll(includeUntitled?: boolean): Promise<boolean>;
|
||||||
$updateWorkspaceFolders(extensionName: string, index: number, deleteCount: number, workspaceFoldersToAdd: { uri: UriComponents, name?: string; }[]): Promise<void>;
|
$updateWorkspaceFolders(extensionName: string, index: number, deleteCount: number, workspaceFoldersToAdd: { uri: UriComponents, name?: string; }[]): Promise<void>;
|
||||||
$resolveProxy(url: string): Promise<string | undefined>;
|
$resolveProxy(url: string): Promise<string | undefined>;
|
||||||
$requireWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState>;
|
$requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IFileChangeDto {
|
export interface IFileChangeDto {
|
||||||
|
|
|
@ -563,8 +563,8 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac
|
||||||
return this._workspaceTrustState;
|
return this._workspaceTrustState;
|
||||||
}
|
}
|
||||||
|
|
||||||
requireWorkspaceTrust(options?: vscode.WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState> {
|
requestWorkspaceTrust(options?: vscode.WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState> {
|
||||||
return this._proxy.$requireWorkspaceTrust(options);
|
return this._proxy.$requestWorkspaceTrust(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
$onDidChangeWorkspaceTrustState(state: WorkspaceTrustStateChangeEvent): void {
|
$onDidChangeWorkspaceTrustState(state: WorkspaceTrustStateChangeEvent): void {
|
||||||
|
|
|
@ -116,7 +116,7 @@ export class RunAutomaticTasks extends Disposable implements IWorkbenchContribut
|
||||||
|
|
||||||
public static async promptForPermission(taskService: ITaskService, storageService: IStorageService, notificationService: INotificationService, workspaceTrustService: IWorkspaceTrustService,
|
public static async promptForPermission(taskService: ITaskService, storageService: IStorageService, notificationService: INotificationService, workspaceTrustService: IWorkspaceTrustService,
|
||||||
openerService: IOpenerService, workspaceTaskResult: Map<string, WorkspaceFolderTaskResult>) {
|
openerService: IOpenerService, workspaceTaskResult: Map<string, WorkspaceFolderTaskResult>) {
|
||||||
const isWorkspaceTrusted = await workspaceTrustService.requireWorkspaceTrust({ modal: false }) === WorkspaceTrustState.Trusted;
|
const isWorkspaceTrusted = await workspaceTrustService.requestWorkspaceTrust({ modal: false }) === WorkspaceTrustState.Trusted;
|
||||||
if (!isWorkspaceTrusted) {
|
if (!isWorkspaceTrusted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench
|
||||||
// TODO: Confirm that this is the right lifecycle phase
|
// TODO: Confirm that this is the right lifecycle phase
|
||||||
this.lifecycleService.when(LifecyclePhase.Eventually).then(() => {
|
this.lifecycleService.when(LifecyclePhase.Eventually).then(() => {
|
||||||
if (this.extensionsDisabledByTrustRequirement.length > 0) {
|
if (this.extensionsDisabledByTrustRequirement.length > 0) {
|
||||||
this.workspaceTrustService.requireWorkspaceTrust({ modal: false });
|
this.workspaceTrustService.requestWorkspaceTrust({ modal: false });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench
|
||||||
|
|
||||||
const result = await Promises.settled(extensions.map(e => {
|
const result = await Promises.settled(extensions.map(e => {
|
||||||
if (this._isDisabledByTrustRequirement(e)) {
|
if (this._isDisabledByTrustRequirement(e)) {
|
||||||
return this.workspaceTrustService.requireWorkspaceTrust()
|
return this.workspaceTrustService.requestWorkspaceTrust()
|
||||||
.then(trustState => {
|
.then(trustState => {
|
||||||
if (trustState === WorkspaceTrustState.Trusted) {
|
if (trustState === WorkspaceTrustState.Trusted) {
|
||||||
return this._setEnablement(e, newState);
|
return this._setEnablement(e, newState);
|
||||||
|
@ -442,7 +442,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench
|
||||||
|
|
||||||
private _onDidInstallExtension({ local, error }: DidInstallExtensionEvent): void {
|
private _onDidInstallExtension({ local, error }: DidInstallExtensionEvent): void {
|
||||||
if (local && !error && this._isDisabledByTrustRequirement(local)) {
|
if (local && !error && this._isDisabledByTrustRequirement(local)) {
|
||||||
this.workspaceTrustService.requireWorkspaceTrust({ modal: false });
|
this.workspaceTrustService.requestWorkspaceTrust({ modal: false });
|
||||||
this._onEnablementChanged.fire([local]);
|
this._onEnablementChanged.fire([local]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,7 +363,7 @@ export class ExtensionManagementService extends Disposable implements IWorkbench
|
||||||
protected async checkForWorkspaceTrust(manifest: IExtensionManifest): Promise<void> {
|
protected async checkForWorkspaceTrust(manifest: IExtensionManifest): Promise<void> {
|
||||||
if (getExtensionWorkspaceTrustRequirement(manifest) === 'onStart') {
|
if (getExtensionWorkspaceTrustRequirement(manifest) === 'onStart') {
|
||||||
try {
|
try {
|
||||||
await this.workspaceTrustService.requireWorkspaceTrust({
|
await this.workspaceTrustService.requestWorkspaceTrust({
|
||||||
modal: true,
|
modal: true,
|
||||||
message: localize('extensionInstallWorkspaceTrustMessage', "Enabling this extension requires a trusted workspace."),
|
message: localize('extensionInstallWorkspaceTrustMessage', "Enabling this extension requires a trusted workspace."),
|
||||||
buttons: [
|
buttons: [
|
||||||
|
|
|
@ -436,7 +436,7 @@ export class WorkspaceTrustService extends Disposable implements IWorkspaceTrust
|
||||||
return this.configurationService.getValue<boolean>(WORKSPACE_TRUST_ENABLED) ?? false;
|
return this.configurationService.getValue<boolean>(WORKSPACE_TRUST_ENABLED) ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async requireWorkspaceTrust(options: WorkspaceTrustRequestOptions = { modal: true }): Promise<WorkspaceTrustState> {
|
async requestWorkspaceTrust(options: WorkspaceTrustRequestOptions = { modal: true }): Promise<WorkspaceTrustState> {
|
||||||
// Trusted workspace
|
// Trusted workspace
|
||||||
if (this.currentTrustState === WorkspaceTrustState.Trusted) {
|
if (this.currentTrustState === WorkspaceTrustState.Trusted) {
|
||||||
return this.currentTrustState;
|
return this.currentTrustState;
|
||||||
|
|
|
@ -22,7 +22,7 @@ export class TestWorkspaceTrustService implements IWorkspaceTrustService {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
requireWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState> {
|
requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState> {
|
||||||
return Promise.resolve(WorkspaceTrustState.Trusted);
|
return Promise.resolve(WorkspaceTrustState.Trusted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue