Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/vs/workbench/services/workspaces/common/workspaceTrust.ts')
-rw-r--r--src/vs/workbench/services/workspaces/common/workspaceTrust.ts91
1 files changed, 26 insertions, 65 deletions
diff --git a/src/vs/workbench/services/workspaces/common/workspaceTrust.ts b/src/vs/workbench/services/workspaces/common/workspaceTrust.ts
index 38877625d85..e5039e9bc04 100644
--- a/src/vs/workbench/services/workspaces/common/workspaceTrust.ts
+++ b/src/vs/workbench/services/workspaces/common/workspaceTrust.ts
@@ -21,8 +21,7 @@ import { Memento, MementoObject } from 'vs/workbench/common/memento';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
import { isEqualAuthority } from 'vs/base/common/resources';
-import { ILogService } from 'vs/platform/log/common/log';
-import { isCI } from 'vs/base/common/platform';
+import { isWeb } from 'vs/base/common/platform';
export const WORKSPACE_TRUST_ENABLED = 'security.workspace.trust.enabled';
export const WORKSPACE_TRUST_STARTUP_PROMPT = 'security.workspace.trust.startupPrompt';
@@ -119,8 +118,7 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@IWorkspaceContextService private readonly workspaceService: IWorkspaceContextService,
- @IWorkspaceTrustEnablementService private readonly workspaceTrustEnablementService: IWorkspaceTrustEnablementService,
- @ILogService protected readonly _logService: ILogService,
+ @IWorkspaceTrustEnablementService private readonly workspaceTrustEnablementService: IWorkspaceTrustEnablementService
) {
super();
@@ -134,7 +132,7 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
this._workspaceTrustInitializedPromiseResolve = resolve;
});
- this._storedTrustState = new WorkspaceTrustMemento(this.storageService);
+ this._storedTrustState = new WorkspaceTrustMemento(isWeb && this.workspaceService.getWorkbenchState() === WorkbenchState.EMPTY ? undefined : this.storageService);
this._trustTransitionManager = this._register(new WorkspaceTrustTransitionManager());
this._trustStateInfo = this.loadTrustInfo();
@@ -147,10 +145,6 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
//#region initialize
private initializeWorkspaceTrust(): void {
- if (isCI) {
- this._logService.info(`[WT] Enter initializeWorkspaceTrust()...`);
- }
-
// Resolve canonical Uris
this.resolveCanonicalUris()
.then(async () => {
@@ -158,15 +152,9 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
await this.updateWorkspaceTrust();
})
.finally(() => {
- if (isCI) {
- this._logService.info(`[WT] Open workspaceResolved gate...`);
- }
this._workspaceResolvedPromiseResolve();
if (!this.environmentService.remoteAuthority) {
- if (isCI) {
- this._logService.info(`[WT] Open workspaceTrustInitialized gate...`);
- }
this._workspaceTrustInitializedPromiseResolve();
}
});
@@ -211,33 +199,21 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
}
private async getCanonicalUri(uri: URI): Promise<URI> {
- if (isCI) {
- this._logService.info('[WT] Enter getCanonicalUri()...');
- }
-
+ let canonicalUri = uri;
if (this.environmentService.remoteAuthority && uri.scheme === Schemas.vscodeRemote) {
- if (isCI) {
- this._logService.info('[WT] Return this.remoteAuthorityResolverService.getCanonicalURI(uri)...');
- }
-
- return this.remoteAuthorityResolverService.getCanonicalURI(uri);
- }
-
- if (uri.scheme === 'vscode-vfs') {
+ canonicalUri = await this.remoteAuthorityResolverService.getCanonicalURI(uri);
+ } else if (uri.scheme === 'vscode-vfs') {
const index = uri.authority.indexOf('+');
if (index !== -1) {
- return uri.with({ authority: uri.authority.substr(0, index) });
+ canonicalUri = uri.with({ authority: uri.authority.substr(0, index) });
}
}
- return uri;
+ // ignore query and fragent section of uris always
+ return canonicalUri.with({ query: null, fragment: null });
}
private async resolveCanonicalUris(): Promise<void> {
- if (isCI) {
- this._logService.info('[WT] Enter resolveCanonicalUris()...');
- }
-
// Open editors
const filesToOpen: IPath[] = [];
if (this.environmentService.filesToOpenOrCreate) {
@@ -249,38 +225,22 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
}
if (filesToOpen.length) {
- const filesToOpenOrCreateUris = filesToOpen.filter(f => f.fileUri && f.fileUri.scheme === Schemas.file).map(f => f.fileUri!);
+ const filesToOpenOrCreateUris = filesToOpen.filter(f => !!f.fileUri).map(f => f.fileUri!);
const canonicalFilesToOpen = await Promise.all(filesToOpenOrCreateUris.map(uri => this.getCanonicalUri(uri)));
this._canonicalStartupFiles.push(...canonicalFilesToOpen.filter(uri => this._canonicalStartupFiles.every(u => !this.uriIdentityService.extUri.isEqual(uri, u))));
}
- if (isCI) {
- this._logService.info('[WT] Done processing open editors...');
- }
-
// Workspace
const workspaceUris = this.workspaceService.getWorkspace().folders.map(f => f.uri);
const canonicalWorkspaceFolders = await Promise.all(workspaceUris.map(uri => this.getCanonicalUri(uri)));
- if (isCI) {
- this._logService.info('[WT] Done processing workspace folders...');
- }
-
let canonicalWorkspaceConfiguration = this.workspaceService.getWorkspace().configuration;
if (canonicalWorkspaceConfiguration && isSavedWorkspace(canonicalWorkspaceConfiguration, this.environmentService)) {
canonicalWorkspaceConfiguration = await this.getCanonicalUri(canonicalWorkspaceConfiguration);
}
- if (isCI) {
- this._logService.info('[WT] Done processing workspace configuration...');
- }
-
this._canonicalWorkspace = new CanonicalWorkspace(this.workspaceService.getWorkspace(), canonicalWorkspaceFolders, canonicalWorkspaceConfiguration);
-
- if (isCI) {
- this._logService.info('[WT] Exit resolveCanonicalUris()...');
- }
}
private loadTrustInfo(): IWorkspaceTrustInfo {
@@ -362,16 +322,7 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
}
private async updateWorkspaceTrust(trusted?: boolean): Promise<void> {
- if (isCI) {
- this._logService.info(`[WT] Enter updateWorkspaceTrust()...`);
- }
-
if (!this.workspaceTrustEnablementService.isWorkspaceTrustEnabled()) {
- if (isCI) {
- this._logService.info(`[WT] Workspace trust is disabled.`);
- this._logService.info(`[WT] Exit updateWorkspaceTrust()...`);
- }
-
return;
}
@@ -883,15 +834,19 @@ class WorkspaceTrustTransitionManager extends Disposable {
class WorkspaceTrustMemento {
- private readonly _memento: Memento;
+ private readonly _memento?: Memento;
private readonly _mementoObject: MementoObject;
private readonly _acceptsOutOfWorkspaceFilesKey = 'acceptsOutOfWorkspaceFiles';
private readonly _isEmptyWorkspaceTrustedKey = 'isEmptyWorkspaceTrusted';
- constructor(storageService: IStorageService) {
- this._memento = new Memento('workspaceTrust', storageService);
- this._mementoObject = this._memento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
+ constructor(storageService?: IStorageService) {
+ if (storageService) {
+ this._memento = new Memento('workspaceTrust', storageService);
+ this._mementoObject = this._memento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
+ } else {
+ this._mementoObject = {};
+ }
}
get acceptsOutOfWorkspaceFiles(): boolean {
@@ -900,7 +855,10 @@ class WorkspaceTrustMemento {
set acceptsOutOfWorkspaceFiles(value: boolean) {
this._mementoObject[this._acceptsOutOfWorkspaceFilesKey] = value;
- this._memento.saveMemento();
+
+ if (this._memento) {
+ this._memento.saveMemento();
+ }
}
get isEmptyWorkspaceTrusted(): boolean | undefined {
@@ -909,7 +867,10 @@ class WorkspaceTrustMemento {
set isEmptyWorkspaceTrusted(value: boolean | undefined) {
this._mementoObject[this._isEmptyWorkspaceTrustedKey] = value;
- this._memento.saveMemento();
+
+ if (this._memento) {
+ this._memento.saveMemento();
+ }
}
}