Skip to content

Commit e85114b

Browse files
author
Benjamin Pasero
committed
sandbox - add pedantic comments to prevent electron-browser usage
1 parent cf211ee commit e85114b

3 files changed

Lines changed: 208 additions & 13 deletions

File tree

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

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,19 @@ class DesktopMain extends Disposable {
164164
private async initServices(): Promise<{ serviceCollection: ServiceCollection, logService: ILogService, storageService: NativeStorageService }> {
165165
const serviceCollection = new ServiceCollection();
166166

167-
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
168-
// NOTE: DO NOT ADD ANY OTHER SERVICE INTO THE COLLECTION HERE.
169-
// CONTRIBUTE IT VIA WORKBENCH.DESKTOP.MAIN.TS AND registerSingleton().
170-
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
167+
168+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
169+
//
170+
// NOTE: Please do NOT register services here. Use `registerSingleton()`
171+
// from `workbench.common.main.ts` if the service is shared between
172+
// desktop and web or `workbench.sandbox.main.ts` if the service
173+
// is desktop only.
174+
//
175+
// DO NOT add services to `workbench.desktop.main.ts`, always add
176+
// to `workbench.sandbox.main.ts` to support our Electron sandbox
177+
//
178+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
179+
171180

172181
// Main Process
173182
const mainProcessService = this._register(new MainProcessService(this.configuration.windowId));
@@ -188,6 +197,20 @@ class DesktopMain extends Disposable {
188197
const remoteAuthorityResolverService = new RemoteAuthorityResolverService();
189198
serviceCollection.set(IRemoteAuthorityResolverService, remoteAuthorityResolverService);
190199

200+
201+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
202+
//
203+
// NOTE: Please do NOT register services here. Use `registerSingleton()`
204+
// from `workbench.common.main.ts` if the service is shared between
205+
// desktop and web or `workbench.sandbox.main.ts` if the service
206+
// is desktop only.
207+
//
208+
// DO NOT add services to `workbench.desktop.main.ts`, always add
209+
// to `workbench.sandbox.main.ts` to support our Electron sandbox
210+
//
211+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
212+
213+
191214
// Sign
192215
const signService = new SignService();
193216
serviceCollection.set(ISignService, signService);
@@ -210,6 +233,20 @@ class DesktopMain extends Disposable {
210233
// User Data Provider
211234
fileService.registerProvider(Schemas.userData, new FileUserDataProvider(this.environmentService.appSettingsHome, this.environmentService.configuration.backupPath ? URI.file(this.environmentService.configuration.backupPath) : undefined, diskFileSystemProvider, this.environmentService, logService));
212235

236+
237+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
238+
//
239+
// NOTE: Please do NOT register services here. Use `registerSingleton()`
240+
// from `workbench.common.main.ts` if the service is shared between
241+
// desktop and web or `workbench.sandbox.main.ts` if the service
242+
// is desktop only.
243+
//
244+
// DO NOT add services to `workbench.desktop.main.ts`, always add
245+
// to `workbench.sandbox.main.ts` to support our Electron sandbox
246+
//
247+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
248+
249+
213250
const connection = remoteAgentService.getConnection();
214251
if (connection) {
215252
const remoteFileSystemProvider = this._register(new RemoteFileSystemProvider(remoteAgentService));
@@ -242,6 +279,20 @@ class DesktopMain extends Disposable {
242279
})
243280
]);
244281

282+
283+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
284+
//
285+
// NOTE: Please do NOT register services here. Use `registerSingleton()`
286+
// from `workbench.common.main.ts` if the service is shared between
287+
// desktop and web or `workbench.sandbox.main.ts` if the service
288+
// is desktop only.
289+
//
290+
// DO NOT add services to `workbench.desktop.main.ts`, always add
291+
// to `workbench.sandbox.main.ts` to support our Electron sandbox
292+
//
293+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
294+
295+
245296
return { serviceCollection, logService, storageService: services[1] };
246297
}
247298

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

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,18 @@ class DesktopMain extends Disposable {
140140
private async initServices(): Promise<{ serviceCollection: ServiceCollection, logService: ILogService, storageService: SimpleStorageService }> {
141141
const serviceCollection = new ServiceCollection();
142142

143-
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
144-
// NOTE: DO NOT ADD ANY OTHER SERVICE INTO THE COLLECTION HERE.
145-
// CONTRIBUTE IT VIA WORKBENCH.DESKTOP.MAIN.TS AND registerSingleton().
146-
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
143+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
144+
//
145+
// NOTE: Please do NOT register services here. Use `registerSingleton()`
146+
// from `workbench.common.main.ts` if the service is shared between
147+
// desktop and web or `workbench.sandbox.main.ts` if the service
148+
// is desktop only.
149+
//
150+
// DO NOT add services to `workbench.desktop.main.ts`, always add
151+
// to `workbench.sandbox.main.ts` to support our Electron sandbox
152+
//
153+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
154+
147155

148156
// Main Process
149157
const mainProcessService = this._register(new MainProcessService(this.configuration.windowId));
@@ -173,6 +181,20 @@ class DesktopMain extends Disposable {
173181
const remoteAgentService = new SimpleRemoteAgentService();
174182
serviceCollection.set(IRemoteAgentService, remoteAgentService);
175183

184+
185+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
186+
//
187+
// NOTE: Please do NOT register services here. Use `registerSingleton()`
188+
// from `workbench.common.main.ts` if the service is shared between
189+
// desktop and web or `workbench.sandbox.main.ts` if the service
190+
// is desktop only.
191+
//
192+
// DO NOT add services to `workbench.desktop.main.ts`, always add
193+
// to `workbench.sandbox.main.ts` to support our Electron sandbox
194+
//
195+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
196+
197+
176198
// Native Host
177199
const nativeHostService = new NativeHostService(this.configuration.windowId, mainProcessService) as INativeHostService;
178200
serviceCollection.set(INativeHostService, nativeHostService);
@@ -195,6 +217,20 @@ class DesktopMain extends Disposable {
195217
const resourceIdentityService = new SimpleResourceIdentityService();
196218
serviceCollection.set(IResourceIdentityService, resourceIdentityService);
197219

220+
221+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
222+
//
223+
// NOTE: Please do NOT register services here. Use `registerSingleton()`
224+
// from `workbench.common.main.ts` if the service is shared between
225+
// desktop and web or `workbench.sandbox.main.ts` if the service
226+
// is desktop only.
227+
//
228+
// DO NOT add services to `workbench.desktop.main.ts`, always add
229+
// to `workbench.sandbox.main.ts` to support our Electron sandbox
230+
//
231+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
232+
233+
198234
const services = await Promise.all([
199235
this.createWorkspaceService().then(service => {
200236

@@ -216,6 +252,20 @@ class DesktopMain extends Disposable {
216252
})
217253
]);
218254

255+
256+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
257+
//
258+
// NOTE: Please do NOT register services here. Use `registerSingleton()`
259+
// from `workbench.common.main.ts` if the service is shared between
260+
// desktop and web or `workbench.sandbox.main.ts` if the service
261+
// is desktop only.
262+
//
263+
// DO NOT add services to `workbench.desktop.main.ts`, always add
264+
// to `workbench.sandbox.main.ts` to support our Electron sandbox
265+
//
266+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
267+
268+
219269
return { serviceCollection, logService, storageService: services[1] };
220270
}
221271

src/vs/workbench/workbench.desktop.main.ts

Lines changed: 99 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44
*--------------------------------------------------------------------------------------------*/
55

66

7-
// #######################################################################
8-
// ### ###
9-
// ### !!! PLEASE ADD COMMON IMPORTS INTO WORKBENCH.COMMON.MAIN.TS !!! ###
10-
// ### ###
11-
// #######################################################################
7+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
8+
//
9+
// NOTE: Please do NOT register services here. Use `registerSingleton()`
10+
// from `workbench.common.main.ts` if the service is shared between
11+
// desktop and web or `workbench.sandbox.main.ts` if the service
12+
// is desktop only.
13+
//
14+
// The `node` & `electron-browser` layer is deprecated for workbench!
15+
//
16+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1217

1318

1419
//#region --- workbench common & sandbox
@@ -25,6 +30,18 @@ import 'vs/workbench/electron-browser/actions/developerActions';
2530
//#endregion
2631

2732

33+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
34+
//
35+
// NOTE: Please do NOT register services here. Use `registerSingleton()`
36+
// from `workbench.common.main.ts` if the service is shared between
37+
// desktop and web or `workbench.sandbox.main.ts` if the service
38+
// is desktop only.
39+
//
40+
// The `node` & `electron-browser` layer is deprecated for workbench!
41+
//
42+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
43+
44+
2845
//#region --- workbench (desktop main)
2946

3047
import 'vs/workbench/electron-browser/desktop.main';
@@ -34,6 +51,19 @@ import 'vs/workbench/electron-browser/desktop.main';
3451

3552
//#region --- workbench services
3653

54+
55+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
56+
//
57+
// NOTE: Please do NOT register services here. Use `registerSingleton()`
58+
// from `workbench.common.main.ts` if the service is shared between
59+
// desktop and web or `workbench.sandbox.main.ts` if the service
60+
// is desktop only.
61+
//
62+
// The `node` & `electron-browser` layer is deprecated for workbench!
63+
//
64+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
65+
66+
3767
import 'vs/workbench/services/integrity/node/integrityService';
3868
import 'vs/workbench/services/search/electron-browser/searchService';
3969
import 'vs/workbench/services/output/electron-browser/outputChannelModelService';
@@ -55,6 +85,19 @@ import 'vs/workbench/services/localizations/electron-browser/localizationsServic
5585
import 'vs/workbench/services/diagnostics/electron-browser/diagnosticsService';
5686
import 'vs/workbench/services/experiment/electron-browser/experimentService';
5787

88+
89+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
90+
//
91+
// NOTE: Please do NOT register services here. Use `registerSingleton()`
92+
// from `workbench.common.main.ts` if the service is shared between
93+
// desktop and web or `workbench.sandbox.main.ts` if the service
94+
// is desktop only.
95+
//
96+
// The `node` & `electron-browser` layer is deprecated for workbench!
97+
//
98+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
99+
100+
58101
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
59102
import { ICredentialsService } from 'vs/platform/credentials/common/credentials';
60103
import { KeytarCredentialsService } from 'vs/platform/credentials/node/credentialsService';
@@ -67,6 +110,18 @@ registerSingleton(ITunnelService, TunnelService);
67110
//#endregion
68111

69112

113+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
114+
//
115+
// NOTE: Please do NOT register services here. Use `registerSingleton()`
116+
// from `workbench.common.main.ts` if the service is shared between
117+
// desktop and web or `workbench.sandbox.main.ts` if the service
118+
// is desktop only.
119+
//
120+
// The `node` & `electron-browser` layer is deprecated for workbench!
121+
//
122+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
123+
124+
70125
//#region --- workbench contributions
71126

72127
// Tags
@@ -82,6 +137,19 @@ import 'vs/workbench/contrib/debug/node/debugHelperService';
82137
// Webview
83138
import 'vs/workbench/contrib/webview/electron-browser/webview.contribution';
84139

140+
141+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
142+
//
143+
// NOTE: Please do NOT register services here. Use `registerSingleton()`
144+
// from `workbench.common.main.ts` if the service is shared between
145+
// desktop and web or `workbench.sandbox.main.ts` if the service
146+
// is desktop only.
147+
//
148+
// The `node` & `electron-browser` layer is deprecated for workbench!
149+
//
150+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
151+
152+
85153
// Notebook
86154
import 'vs/workbench/contrib/notebook/electron-browser/notebook.contribution';
87155

@@ -97,6 +165,19 @@ import 'vs/workbench/contrib/codeEditor/electron-browser/codeEditor.contribution
97165
// External Terminal
98166
import 'vs/workbench/contrib/externalTerminal/node/externalTerminal.contribution';
99167

168+
169+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
170+
//
171+
// NOTE: Please do NOT register services here. Use `registerSingleton()`
172+
// from `workbench.common.main.ts` if the service is shared between
173+
// desktop and web or `workbench.sandbox.main.ts` if the service
174+
// is desktop only.
175+
//
176+
// The `node` & `electron-browser` layer is deprecated for workbench!
177+
//
178+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
179+
180+
100181
// Performance
101182
import 'vs/workbench/contrib/performance/electron-browser/performance.contribution';
102183

@@ -109,4 +190,17 @@ import 'vs/workbench/contrib/tasks/electron-browser/taskService';
109190
// User Data Sync
110191
import 'vs/workbench/contrib/userDataSync/electron-browser/userDataSync.contribution';
111192

193+
194+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
195+
//
196+
// NOTE: Please do NOT register services here. Use `registerSingleton()`
197+
// from `workbench.common.main.ts` if the service is shared between
198+
// desktop and web or `workbench.sandbox.main.ts` if the service
199+
// is desktop only.
200+
//
201+
// The `node` & `electron-browser` layer is deprecated for workbench!
202+
//
203+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
204+
205+
112206
//#endregion

0 commit comments

Comments
 (0)