Skip to content

Commit 9d1eea5

Browse files
author
Benjamin Pasero
committed
sandbox - implement a simple native workbench environment service
1 parent 4e729bb commit 9d1eea5

10 files changed

Lines changed: 101 additions & 15 deletions

File tree

src/vs/workbench/electron-browser/desktop.main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import { IElectronService, ElectronService } from 'vs/platform/electron/electron
5252

5353
class DesktopMain extends Disposable {
5454

55-
private readonly environmentService = new NativeWorkbenchEnvironmentService(this.configuration, this.configuration.execPath);
55+
private readonly environmentService = new NativeWorkbenchEnvironmentService(this.configuration);
5656

5757
constructor(private configuration: INativeWorkbenchConfiguration) {
5858
super();

src/vs/workbench/electron-sandbox/desktop.main.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,11 @@ import { IProductService } from 'vs/platform/product/common/productService';
3030
import product from 'vs/platform/product/common/product';
3131
import { IResourceIdentityService } from 'vs/platform/resource/common/resourceIdentityService';
3232
import { IElectronService, ElectronService } from 'vs/platform/electron/electron-sandbox/electron';
33-
import { SimpleConfigurationService, simpleFileSystemProvider, SimpleLogService, SimpleRemoteAgentService, SimpleRemoteAuthorityResolverService, SimpleResourceIdentityService, SimpleSignService, SimpleStorageService, SimpleWorkspaceService } from 'vs/workbench/electron-sandbox/sandbox.simpleservices';
34-
import { BrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
33+
import { SimpleConfigurationService, simpleFileSystemProvider, SimpleLogService, SimpleRemoteAgentService, SimpleRemoteAuthorityResolverService, SimpleResourceIdentityService, SimpleSignService, SimpleStorageService, SimpleWorkbenchEnvironmentService, SimpleWorkspaceService } from 'vs/workbench/electron-sandbox/sandbox.simpleservices';
3534

3635
class DesktopMain extends Disposable {
3736

38-
private readonly environmentService = new BrowserWorkbenchEnvironmentService({
39-
logsPath: URI.file('logs-path'),
40-
workspaceId: ''
41-
});
37+
private readonly environmentService = new SimpleWorkbenchEnvironmentService(this.configuration);
4238

4339
constructor(private configuration: INativeWindowConfiguration) {
4440
super();

src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,95 @@ import { joinPath } from 'vs/base/common/resources';
6262
import { VSBuffer } from 'vs/base/common/buffer';
6363
import { IExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/common/extensions';
6464
import { IIntegrityService, IntegrityTestResult } from 'vs/workbench/services/integrity/common/integrity';
65+
import { INativeWorkbenchConfiguration, INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
66+
import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
67+
import { IExtensionHostDebugParams } from 'vs/platform/environment/common/environment';
68+
import { IWorkbenchConstructionOptions } from 'vs/workbench/workbench.web.api';
69+
import { Schemas } from 'vs/base/common/network';
70+
71+
72+
//#region Environment
73+
74+
export class SimpleWorkbenchEnvironmentService implements INativeWorkbenchEnvironmentService {
75+
76+
declare readonly _serviceBrand: undefined;
77+
78+
constructor(
79+
readonly configuration: INativeWorkbenchConfiguration
80+
) { }
81+
82+
get userRoamingDataHome(): URI { return URI.file('/User').with({ scheme: Schemas.userData }); }
83+
get settingsResource(): URI { return joinPath(this.userRoamingDataHome, 'settings.json'); }
84+
get argvResource(): URI { return joinPath(this.userRoamingDataHome, 'argv.json'); }
85+
get snippetsHome(): URI { return joinPath(this.userRoamingDataHome, 'snippets'); }
86+
get globalStorageHome(): URI { return URI.joinPath(this.userRoamingDataHome, 'globalStorage'); }
87+
get workspaceStorageHome(): URI { return URI.joinPath(this.userRoamingDataHome, 'workspaceStorage'); }
88+
get keybindingsResource(): URI { return joinPath(this.userRoamingDataHome, 'keybindings.json'); }
89+
get logFile(): URI { return joinPath(this.userRoamingDataHome, 'window.log'); }
90+
get untitledWorkspacesHome(): URI { return joinPath(this.userRoamingDataHome, 'Workspaces'); }
91+
get serviceMachineIdResource(): URI { return joinPath(this.userRoamingDataHome, 'machineid'); }
92+
get userDataSyncLogResource(): URI { return joinPath(this.userRoamingDataHome, 'syncLog'); }
93+
get userDataSyncHome(): URI { return joinPath(this.userRoamingDataHome, 'syncHome'); }
94+
get backupHome(): URI { return joinPath(this.userRoamingDataHome, 'backupsHome'); }
95+
96+
options?: IWorkbenchConstructionOptions | undefined;
97+
logExtensionHostCommunication?: boolean | undefined;
98+
extensionEnabledProposedApi?: string[] | undefined;
99+
webviewExternalEndpoint: string = undefined!;
100+
webviewResourceRoot: string = undefined!;
101+
webviewCspSource: string = undefined!;
102+
skipReleaseNotes: boolean = undefined!;
103+
keyboardLayoutResource: URI = undefined!;
104+
sync: 'on' | 'off' | undefined;
105+
enableSyncByDefault: boolean = false;
106+
debugExtensionHost: IExtensionHostDebugParams = undefined!;
107+
isExtensionDevelopment: boolean = false;
108+
disableExtensions: boolean | string[] = [];
109+
extensionDevelopmentLocationURI?: URI[] | undefined;
110+
extensionTestsLocationURI?: URI | undefined;
111+
logsPath: string = undefined!;
112+
logLevel?: string | undefined;
113+
114+
args: NativeParsedArgs = Object.create(null);
115+
116+
execPath: string = undefined!;
117+
cliPath: string = undefined!;
118+
appRoot: string = undefined!;
119+
userHome: URI = undefined!;
120+
appSettingsHome: URI = undefined!;
121+
userDataPath: string = undefined!;
122+
machineSettingsResource: URI = undefined!;
123+
backupWorkspacesPath: string = undefined!;
124+
125+
log?: string | undefined;
126+
extHostLogsPath: URI = undefined!;
127+
128+
installSourcePath: string = undefined!;
129+
130+
mainIPCHandle: string = undefined!;
131+
sharedIPCHandle: string = undefined!;
132+
133+
extensionsPath?: string | undefined;
134+
extensionsDownloadPath: string = undefined!;
135+
builtinExtensionsPath: string = undefined!;
136+
137+
driverHandle?: string | undefined;
138+
driverVerbose = false;
139+
140+
crashReporterDirectory?: string | undefined;
141+
crashReporterId?: string | undefined;
142+
143+
nodeCachedDataDir?: string | undefined;
144+
145+
disableUpdates = false;
146+
sandbox = true;
147+
verbose = false;
148+
isBuilt = false;
149+
disableTelemetry = false;
150+
}
151+
152+
//#endregion
153+
65154

66155
//#region Workspace
67156

src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const untitledBackupPath = path.join(workspaceBackupPath, 'untitled', hashPath(u
4949
class TestWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService {
5050

5151
constructor(backupPath: string) {
52-
super({ ...TestWorkbenchConfiguration, backupPath, 'user-data-dir': userdataDir }, TestWorkbenchConfiguration.execPath);
52+
super({ ...TestWorkbenchConfiguration, backupPath, 'user-data-dir': userdataDir });
5353
}
5454
}
5555

src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { FileUserDataProvider } from 'vs/workbench/services/userData/common/file
4545
class TestWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService {
4646

4747
constructor(private _appSettingsHome: URI) {
48-
super(TestWorkbenchConfiguration, TestWorkbenchConfiguration.execPath);
48+
super(TestWorkbenchConfiguration);
4949
}
5050

5151
get appSettingsHome() { return this._appSettingsHome; }

src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import { BrowserWorkbenchEnvironmentService } from 'vs/workbench/services/enviro
5656
class TestWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService {
5757

5858
constructor(private _appSettingsHome: URI) {
59-
super(TestWorkbenchConfiguration, TestWorkbenchConfiguration.execPath);
59+
super(TestWorkbenchConfiguration);
6060
}
6161

6262
get appSettingsHome() { return this._appSettingsHome; }

src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,6 @@ class MockInputsConfigurationService extends TestConfigurationService {
691691
class MockWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService {
692692

693693
constructor(public userEnv: platform.IProcessEnvironment) {
694-
super({ ...TestWorkbenchConfiguration, userEnv }, TestWorkbenchConfiguration.execPath);
694+
super({ ...TestWorkbenchConfiguration, userEnv });
695695
}
696696
}

src/vs/workbench/services/environment/electron-browser/environmentService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ export class NativeWorkbenchEnvironmentService extends EnvironmentService implem
6060
@memoize
6161
get cliPath(): string { return this.doGetCLIPath(); }
6262

63+
readonly execPath = this.configuration.execPath;
64+
6365
constructor(
64-
readonly configuration: INativeWorkbenchConfiguration,
65-
readonly execPath: string
66+
readonly configuration: INativeWorkbenchConfiguration
6667
) {
6768
super(configuration);
6869

src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import { UriIdentityService } from 'vs/workbench/services/uriIdentity/common/uri
6464
class TestWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService {
6565

6666
constructor(private _appSettingsHome: URI) {
67-
super(TestWorkbenchConfiguration, TestWorkbenchConfiguration.execPath);
67+
super(TestWorkbenchConfiguration);
6868
}
6969

7070
get appSettingsHome() { return this._appSettingsHome; }

src/vs/workbench/test/electron-browser/workbenchTestServices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const TestWorkbenchConfiguration: INativeWorkbenchConfiguration = {
5656
...parseArgs(process.argv, OPTIONS)
5757
};
5858

59-
export const TestEnvironmentService = new NativeWorkbenchEnvironmentService(TestWorkbenchConfiguration, process.execPath);
59+
export const TestEnvironmentService = new NativeWorkbenchEnvironmentService(TestWorkbenchConfiguration);
6060

6161
export class TestTextFileService extends NativeTextFileService {
6262
private resolveTextContentError!: FileOperationError | null;

0 commit comments

Comments
 (0)