sandbox - move fileDialogService to sandbox

This commit is contained in:
Benjamin Pasero 2020-06-22 10:32:47 +02:00
parent 1264c0dfbf
commit 96bd9fa91e
5 changed files with 3 additions and 63 deletions

View file

@ -219,21 +219,17 @@ export abstract class AbstractFileDialogService implements IFileDialogService {
}
private pickResource(options: IOpenDialogOptions): Promise<URI | undefined> {
const simpleFileDialog = this.createSimpleFileDialog();
const simpleFileDialog = this.instantiationService.createInstance(SimpleFileDialog);
return simpleFileDialog.showOpenDialog(options);
}
private saveRemoteResource(options: ISaveDialogOptions): Promise<URI | undefined> {
const remoteFileDialog = this.createSimpleFileDialog();
const remoteFileDialog = this.instantiationService.createInstance(SimpleFileDialog);
return remoteFileDialog.showSaveDialog(options);
}
protected createSimpleFileDialog(): SimpleFileDialog {
return this.instantiationService.createInstance(SimpleFileDialog);
}
protected getSchemeFilterForWindow(): string {
return !this.environmentService.configuration.remoteAuthority ? Schemas.file : REMOTE_HOST_SCHEME;
}

View file

@ -1,49 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { URI } from 'vs/base/common/uri';
import { SimpleFileDialog } from 'vs/workbench/services/dialogs/browser/simpleFileDialog';
import { Schemas } from 'vs/base/common/network';
import { IFileService } from 'vs/platform/files/common/files';
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { ILabelService } from 'vs/platform/label/common/label';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
import { IModelService } from 'vs/editor/common/services/modelService';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { IPathService } from 'vs/workbench/services/path/common/pathService';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
export class NativeSimpleFileDialog extends SimpleFileDialog {
constructor(
@IFileService fileService: IFileService,
@IQuickInputService quickInputService: IQuickInputService,
@ILabelService labelService: ILabelService,
@IWorkspaceContextService workspaceContextService: IWorkspaceContextService,
@INotificationService notificationService: INotificationService,
@IFileDialogService fileDialogService: IFileDialogService,
@IModelService modelService: IModelService,
@IModeService modeService: IModeService,
@IWorkbenchEnvironmentService protected environmentService: INativeWorkbenchEnvironmentService,
@IRemoteAgentService remoteAgentService: IRemoteAgentService,
@IPathService protected pathService: IPathService,
@IKeybindingService keybindingService: IKeybindingService,
@IContextKeyService contextKeyService: IContextKeyService
) {
super(fileService, quickInputService, labelService, workspaceContextService, notificationService, fileDialogService, modelService, modeService, environmentService, remoteAgentService, pathService, keybindingService, contextKeyService);
}
protected async getUserHome(): Promise<URI> {
if (this.scheme !== Schemas.file) {
return super.getUserHome();
}
return this.environmentService.userHome;
}
}

View file

@ -21,8 +21,6 @@ import { Schemas } from 'vs/base/common/network';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
import { ILabelService } from 'vs/platform/label/common/label';
import { SimpleFileDialog } from 'vs/workbench/services/dialogs/browser/simpleFileDialog';
import { NativeSimpleFileDialog } from 'vs/workbench/services/dialogs/electron-browser/simpleFileDialog';
export class FileDialogService extends AbstractFileDialogService implements IFileDialogService {
@ -191,10 +189,6 @@ export class FileDialogService extends AbstractFileDialogService implements IFil
// Don't allow untitled schema through.
return schema === Schemas.untitled ? [Schemas.file] : (schema !== Schemas.file ? [schema, Schemas.file] : [schema]);
}
protected createSimpleFileDialog(): SimpleFileDialog {
return this.instantiationService.createInstance(NativeSimpleFileDialog);
}
}
registerSingleton(IFileDialogService, FileDialogService, true);

View file

@ -34,7 +34,6 @@ import 'vs/workbench/electron-browser/desktop.main';
//#region --- workbench services
import 'vs/workbench/services/dialogs/electron-browser/fileDialogService';
import 'vs/workbench/services/integrity/node/integrityService';
import 'vs/workbench/services/textMate/electron-browser/textMateService';
import 'vs/workbench/services/search/node/searchService';

View file

@ -19,6 +19,7 @@ import 'vs/workbench/workbench.common.main';
//#region --- workbench services
import 'vs/workbench/services/dialogs/electron-sandbox/fileDialogService';
import 'vs/workbench/services/workspaces/electron-sandbox/workspacesService';
import 'vs/workbench/services/userDataSync/electron-sandbox/storageKeysSyncRegistryService';
import 'vs/workbench/services/menubar/electron-sandbox/menubarService';
@ -32,7 +33,6 @@ import 'vs/workbench/services/request/electron-sandbox/requestService';
import 'vs/workbench/services/extensionResourceLoader/electron-sandbox/extensionResourceLoaderService';
import 'vs/workbench/services/clipboard/electron-sandbox/clipboardService';
//#endregion