sandbox - drop setting to run shared process as hidden window

This commit is contained in:
Benjamin Pasero 2023-03-25 06:21:42 +01:00
parent 022a734b30
commit ea5f26aea7
No known key found for this signature in database
GPG key ID: E6380CC4C8219E65
7 changed files with 8 additions and 61 deletions

View file

@ -26,7 +26,6 @@ import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/use
import { IPolicyService } from 'vs/platform/policy/common/policy'; import { IPolicyService } from 'vs/platform/policy/common/policy';
import { ILoggerMainService } from 'vs/platform/log/electron-main/loggerService'; import { ILoggerMainService } from 'vs/platform/log/electron-main/loggerService';
import { UtilityProcess } from 'vs/platform/utilityProcess/electron-main/utilityProcess'; import { UtilityProcess } from 'vs/platform/utilityProcess/electron-main/utilityProcess';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils'; import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { canUseUtilityProcess } from 'vs/base/parts/sandbox/electron-main/electronTypes'; import { canUseUtilityProcess } from 'vs/base/parts/sandbox/electron-main/electronTypes';
import { parseSharedProcessDebugPort } from 'vs/platform/environment/node/environmentService'; import { parseSharedProcessDebugPort } from 'vs/platform/environment/node/environmentService';
@ -42,19 +41,7 @@ export class SharedProcess extends Disposable implements ISharedProcess {
private windowCloseListener: ((event: ElectronEvent) => void) | undefined = undefined; private windowCloseListener: ((event: ElectronEvent) => void) | undefined = undefined;
private utilityProcess: UtilityProcess | undefined = undefined; private utilityProcess: UtilityProcess | undefined = undefined;
private readonly useUtilityProcess = (() => { private readonly useUtilityProcess = canUseUtilityProcess;
let useUtilityProcess = false;
if (canUseUtilityProcess) {
const sharedProcessUseUtilityProcess = this.configurationService.getValue<boolean>('window.experimental.sharedProcessUseUtilityProcess');
if (typeof sharedProcessUseUtilityProcess === 'boolean') {
useUtilityProcess = sharedProcessUseUtilityProcess;
} else {
useUtilityProcess = typeof product.quality === 'string';
}
}
return useUtilityProcess;
})();
constructor( constructor(
private readonly machineId: string, private readonly machineId: string,
@ -66,8 +53,7 @@ export class SharedProcess extends Disposable implements ISharedProcess {
@ILoggerMainService private readonly loggerMainService: ILoggerMainService, @ILoggerMainService private readonly loggerMainService: ILoggerMainService,
@IPolicyService private readonly policyService: IPolicyService, @IPolicyService private readonly policyService: IPolicyService,
@IThemeMainService private readonly themeMainService: IThemeMainService, @IThemeMainService private readonly themeMainService: IThemeMainService,
@IProtocolMainService private readonly protocolMainService: IProtocolMainService, @IProtocolMainService private readonly protocolMainService: IProtocolMainService
@IConfigurationService private readonly configurationService: IConfigurationService
) { ) {
super(); super();

View file

@ -137,7 +137,7 @@ export interface IWindowSettings {
readonly enableMenuBarMnemonics: boolean; readonly enableMenuBarMnemonics: boolean;
readonly closeWhenEmpty: boolean; readonly closeWhenEmpty: boolean;
readonly clickThroughInactive: boolean; readonly clickThroughInactive: boolean;
readonly experimental?: { useSandbox: boolean; sharedProcessUseUtilityProcess: boolean }; readonly experimental?: { useSandbox: boolean };
} }
export function getTitleBarStyle(configurationService: IConfigurationService): 'native' | 'custom' { export function getTitleBarStyle(configurationService: IConfigurationService): 'native' | 'custom' {

View file

@ -1324,15 +1324,6 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
} }
} }
let preferUtilityProcess = false;
if (canUseUtilityProcess) {
if (typeof windowConfig?.experimental?.sharedProcessUseUtilityProcess === 'boolean') {
preferUtilityProcess = windowConfig.experimental.sharedProcessUseUtilityProcess;
} else {
preferUtilityProcess = typeof product.quality === 'string';
}
}
// Build up the window configuration from provided options, config and environment // Build up the window configuration from provided options, config and environment
const configuration: INativeWindowConfiguration = { const configuration: INativeWindowConfiguration = {
@ -1398,7 +1389,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
policiesData: this.policyService.serialize(), policiesData: this.policyService.serialize(),
continueOn: this.environmentMainService.continueOn, continueOn: this.environmentMainService.continueOn,
preferUtilityProcess preferUtilityProcess: canUseUtilityProcess
}; };
// New window // New window

View file

@ -147,6 +147,7 @@ export class Workbench extends Layout {
const configurationService = accessor.get(IConfigurationService); const configurationService = accessor.get(IConfigurationService);
const hostService = accessor.get(IHostService); const hostService = accessor.get(IHostService);
const dialogService = accessor.get(IDialogService); const dialogService = accessor.get(IDialogService);
const notificationService = accessor.get(INotificationService) as NotificationService;
// Layout // Layout
this.initLayout(accessor); this.initLayout(accessor);
@ -162,7 +163,7 @@ export class Workbench extends Layout {
this.registerListeners(lifecycleService, storageService, configurationService, hostService, dialogService); this.registerListeners(lifecycleService, storageService, configurationService, hostService, dialogService);
// Render Workbench // Render Workbench
this.renderWorkbench(instantiationService, accessor.get(INotificationService) as NotificationService, storageService, configurationService); this.renderWorkbench(instantiationService, notificationService, storageService, configurationService);
// Workbench Layout // Workbench Layout
this.createWorkbenchLayout(); this.createWorkbenchLayout();

View file

@ -26,7 +26,7 @@ interface IConfiguration extends IWindowsConfiguration {
debug?: { console?: { wordWrap?: boolean } }; debug?: { console?: { wordWrap?: boolean } };
editor?: { accessibilitySupport?: 'on' | 'off' | 'auto' }; editor?: { accessibilitySupport?: 'on' | 'off' | 'auto' };
security?: { workspace?: { trust?: { enabled?: boolean } } }; security?: { workspace?: { trust?: { enabled?: boolean } } };
window: IWindowSettings & { experimental?: { windowControlsOverlay?: { enabled?: boolean }; useSandbox?: boolean; sharedProcessUseUtilityProcess?: boolean } }; window: IWindowSettings & { experimental?: { windowControlsOverlay?: { enabled?: boolean }; useSandbox?: boolean } };
workbench?: { enableExperiments?: boolean }; workbench?: { enableExperiments?: boolean };
_extensionsGallery?: { enablePPE?: boolean }; _extensionsGallery?: { enablePPE?: boolean };
} }
@ -37,7 +37,6 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
'window.titleBarStyle', 'window.titleBarStyle',
'window.experimental.windowControlsOverlay.enabled', 'window.experimental.windowControlsOverlay.enabled',
'window.experimental.useSandbox', 'window.experimental.useSandbox',
'window.experimental.sharedProcessUseUtilityProcess',
'window.nativeTabs', 'window.nativeTabs',
'window.nativeFullScreen', 'window.nativeFullScreen',
'window.clickThroughInactive', 'window.clickThroughInactive',
@ -51,7 +50,6 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
private readonly titleBarStyle = new ChangeObserver<'native' | 'custom'>('string'); private readonly titleBarStyle = new ChangeObserver<'native' | 'custom'>('string');
private readonly windowControlsOverlayEnabled = new ChangeObserver('boolean'); private readonly windowControlsOverlayEnabled = new ChangeObserver('boolean');
private readonly windowSandboxEnabled = new ChangeObserver('boolean'); private readonly windowSandboxEnabled = new ChangeObserver('boolean');
private readonly sharedProcessUtilityProcessEnabled = new ChangeObserver('boolean');
private readonly nativeTabs = new ChangeObserver('boolean'); private readonly nativeTabs = new ChangeObserver('boolean');
private readonly nativeFullScreen = new ChangeObserver('boolean'); private readonly nativeFullScreen = new ChangeObserver('boolean');
private readonly clickThroughInactive = new ChangeObserver('boolean'); private readonly clickThroughInactive = new ChangeObserver('boolean');
@ -97,9 +95,6 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
// Windows: Sandbox // Windows: Sandbox
processChanged(this.windowSandboxEnabled.handleChange(config.window?.experimental?.useSandbox)); processChanged(this.windowSandboxEnabled.handleChange(config.window?.experimental?.useSandbox));
// Shared Process: Utility Process
processChanged(this.sharedProcessUtilityProcessEnabled.handleChange(config.window?.experimental?.sharedProcessUseUtilityProcess));
// macOS: Native tabs // macOS: Native tabs
processChanged(isMacintosh && this.nativeTabs.handleChange(config.window?.nativeTabs)); processChanged(isMacintosh && this.nativeTabs.handleChange(config.window?.nativeTabs));

View file

@ -16,7 +16,6 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { IFileService } from 'vs/platform/files/common/files'; import { IFileService } from 'vs/platform/files/common/files';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
export class ToggleDevToolsAction extends Action2 { export class ToggleDevToolsAction extends Action2 {
@ -69,23 +68,6 @@ export class ConfigureRuntimeArgumentsAction extends Action2 {
} }
} }
export class ToggleSharedProcessAction extends Action2 {
constructor() {
super({
id: 'workbench.action.toggleSharedProcess',
title: { value: localize('toggleSharedProcess', "Toggle Shared Process"), original: 'Toggle Shared Process' },
category: Categories.Developer,
precondition: ContextKeyExpr.has('config.window.experimental.sharedProcessUseUtilityProcess').negate(),
f1: true
});
}
async run(accessor: ServicesAccessor): Promise<void> {
return accessor.get(INativeHostService).toggleSharedProcessWindow();
}
}
export class ReloadWindowWithExtensionsDisabledAction extends Action2 { export class ReloadWindowWithExtensionsDisabledAction extends Action2 {
constructor() { constructor() {

View file

@ -9,7 +9,7 @@ import { MenuRegistry, MenuId, registerAction2 } from 'vs/platform/actions/commo
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry'; import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform'; import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform';
import { ConfigureRuntimeArgumentsAction, ToggleDevToolsAction, ToggleSharedProcessAction, ReloadWindowWithExtensionsDisabledAction, OpenUserDataFolderAction } from 'vs/workbench/electron-sandbox/actions/developerActions'; import { ConfigureRuntimeArgumentsAction, ToggleDevToolsAction, ReloadWindowWithExtensionsDisabledAction, OpenUserDataFolderAction } from 'vs/workbench/electron-sandbox/actions/developerActions';
import { ZoomResetAction, ZoomOutAction, ZoomInAction, CloseWindowAction, SwitchWindowAction, QuickSwitchWindowAction, NewWindowTabHandler, ShowPreviousWindowTabHandler, ShowNextWindowTabHandler, MoveWindowTabToNewWindowHandler, MergeWindowTabsHandlerHandler, ToggleWindowTabsBarHandler } from 'vs/workbench/electron-sandbox/actions/windowActions'; import { ZoomResetAction, ZoomOutAction, ZoomInAction, CloseWindowAction, SwitchWindowAction, QuickSwitchWindowAction, NewWindowTabHandler, ShowPreviousWindowTabHandler, ShowNextWindowTabHandler, MoveWindowTabToNewWindowHandler, MergeWindowTabsHandlerHandler, ToggleWindowTabsBarHandler } from 'vs/workbench/electron-sandbox/actions/windowActions';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
@ -106,7 +106,6 @@ import { applicationConfigurationNodeBase } from 'vs/workbench/common/configurat
// Actions: Developer // Actions: Developer
registerAction2(ReloadWindowWithExtensionsDisabledAction); registerAction2(ReloadWindowWithExtensionsDisabledAction);
registerAction2(ConfigureRuntimeArgumentsAction); registerAction2(ConfigureRuntimeArgumentsAction);
registerAction2(ToggleSharedProcessAction);
registerAction2(ToggleDevToolsAction); registerAction2(ToggleDevToolsAction);
registerAction2(OpenUserDataFolderAction); registerAction2(OpenUserDataFolderAction);
})(); })();
@ -266,13 +265,6 @@ import { applicationConfigurationNodeBase } from 'vs/workbench/common/configurat
tags: product.quality === 'stable' ? ['experimental'] : undefined, tags: product.quality === 'stable' ? ['experimental'] : undefined,
'scope': ConfigurationScope.APPLICATION, 'scope': ConfigurationScope.APPLICATION,
ignoreSync: true ignoreSync: true
},
'window.experimental.sharedProcessUseUtilityProcess': { // TODO@bpasero remove me once sandbox is final
type: 'boolean',
description: localize('experimentalUseSharedProcessUseUtilityProcess', "Experimental: When enabled, the window will have sandbox mode enabled via Electron API."),
default: typeof product.quality === 'string',
'scope': ConfigurationScope.APPLICATION,
ignoreSync: true
} }
} }
}); });