提交 062d9393 编写于 作者: B Benjamin Pasero

sandboy - more adoption of IPC API from preload script

上级 41461768
......@@ -9,19 +9,19 @@ export const ipcRenderer = (window as any).vscode.ipcRenderer as {
* Listens to `channel`, when a new message arrives `listener` would be called with
* `listener(event, args...)`.
*/
on(channel: string, listener: Function): void;
on(channel: string, listener: (event: unknown, ...args: any[]) => void): void;
/**
* Adds a one time `listener` function for the event. This `listener` is invoked
* only the next time a message is sent to `channel`, after which it is removed.
*/
once(channel: string, listener: Function): void;
once(channel: string, listener: (event: unknown, ...args: any[]) => void): void;
/**
* Removes the specified `listener` from the listener array for the specified
* `channel`.
*/
removeListener(channel: string, listener: Function): void;
removeListener(channel: string, listener: (event: unknown, ...args: any[]) => void): void;
/**
* Send an asynchronous message to the main process via `channel`, along with
......
......@@ -13,7 +13,7 @@ export function popup(items: IContextMenuItem[], options?: IPopupOptions): void
const contextMenuId = contextMenuIdPool++;
const onClickChannel = `vscode:onContextMenu${contextMenuId}`;
const onClickChannelHandler = (_event: Event, itemId: number, context: IContextMenuEvent) => {
const onClickChannelHandler = (event: unknown, itemId: number, context: IContextMenuEvent) => {
const item = processedItems[itemId];
if (item.click) {
item.click(context);
......@@ -21,7 +21,7 @@ export function popup(items: IContextMenuItem[], options?: IPopupOptions): void
};
ipcRenderer.once(onClickChannel, onClickChannelHandler);
ipcRenderer.once(CONTEXT_MENU_CLOSE_CHANNEL, (_event: Event, closedContextMenuId: number) => {
ipcRenderer.once(CONTEXT_MENU_CLOSE_CHANNEL, (event: unknown, closedContextMenuId: number) => {
if (closedContextMenuId !== contextMenuId) {
return;
}
......
......@@ -4,7 +4,8 @@
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./media/issueReporter';
import { clipboard, ipcRenderer, shell, webFrame } from 'electron';
import { clipboard, shell, webFrame } from 'electron';
import { ipcRenderer } from 'vs/base/electron-sandbox/globals';
import * as os from 'os';
import * as browser from 'vs/base/browser/browser';
import { $ } from 'vs/base/browser/dom';
......
......@@ -4,7 +4,8 @@
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./media/processExplorer';
import { webFrame, ipcRenderer, clipboard } from 'electron';
import { webFrame, clipboard } from 'electron';
import { ipcRenderer } from 'vs/base/electron-sandbox/globals';
import { repeat } from 'vs/base/common/strings';
import { totalmem } from 'os';
import product from 'vs/platform/product/common/product';
......@@ -369,7 +370,7 @@ function requestProcessList(totalWaitTime: number): void {
// Wait at least a second between requests.
if (waited > 1000) {
ipcRenderer.send('windowsInfoRequest');
ipcRenderer.send('vscode:windowsInfoRequest');
ipcRenderer.send('vscode:listProcesses');
} else {
requestProcessList(waited);
......@@ -393,18 +394,18 @@ export function startup(data: ProcessExplorerData): void {
createCloseListener();
// Map window process pids to titles, annotate process names with this when rendering to distinguish between them
ipcRenderer.on('vscode:windowsInfoResponse', (_event: unknown, windows: any[]) => {
ipcRenderer.on('vscode:windowsInfoResponse', (event: unknown, windows: any[]) => {
mapPidToWindowTitle = new Map<number, string>();
windows.forEach(window => mapPidToWindowTitle.set(window.pid, window.title));
});
ipcRenderer.on('vscode:listProcessesResponse', (_event: Event, processRoots: [{ name: string, rootProcess: ProcessItem | IRemoteDiagnosticError }]) => {
ipcRenderer.on('vscode:listProcessesResponse', (event: unknown, processRoots: [{ name: string, rootProcess: ProcessItem | IRemoteDiagnosticError }]) => {
updateProcessInfo(processRoots);
requestProcessList(0);
});
lastRequestTime = Date.now();
ipcRenderer.send('windowsInfoRequest');
ipcRenderer.send('vscode:windowsInfoRequest');
ipcRenderer.send('vscode:listProcesses');
document.onkeydown = (e: KeyboardEvent) => {
......
......@@ -27,7 +27,7 @@ import { resolveCommonProperties } from 'vs/platform/telemetry/node/commonProper
import { TelemetryAppenderChannel } from 'vs/platform/telemetry/node/telemetryIpc';
import { TelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService';
import { AppInsightsAppender } from 'vs/platform/telemetry/node/appInsightsAppender';
import { ipcRenderer } from 'electron';
import { ipcRenderer } from 'vs/base/electron-sandbox/globals';
import { ILogService, LogLevel, ILoggerService } from 'vs/platform/log/common/log';
import { LoggerChannelClient, FollowerLogService } from 'vs/platform/log/common/logIpc';
import { LocalizationsService } from 'vs/platform/localizations/node/localizations';
......@@ -114,7 +114,7 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat
const onExit = () => disposables.dispose();
process.once('exit', onExit);
ipcRenderer.once('electron-main->shared-process: exit', onExit);
ipcRenderer.once('vscode:electron-main->shared-process=exit', onExit);
disposables.add(server);
......@@ -302,17 +302,17 @@ async function handshake(configuration: ISharedProcessConfiguration): Promise<vo
// receive payload from electron-main to start things
const data = await new Promise<ISharedProcessInitData>(c => {
ipcRenderer.once('electron-main->shared-process: payload', (_: any, r: ISharedProcessInitData) => c(r));
ipcRenderer.once('vscode:electron-main->shared-process=payload', (event: unknown, r: ISharedProcessInitData) => c(r));
// tell electron-main we are ready to receive payload
ipcRenderer.send('shared-process->electron-main: ready-for-payload');
ipcRenderer.send('vscode:shared-process->electron-main=ready-for-payload');
});
// await IPC connection and signal this back to electron-main
const server = await setupIPC(data.sharedIPCHandle);
ipcRenderer.send('shared-process->electron-main: ipc-ready');
ipcRenderer.send('vscode:shared-process->electron-main=ipc-ready');
// await initialization and signal this back to electron-main
await main(server, data, configuration);
ipcRenderer.send('shared-process->electron-main: init-done');
ipcRenderer.send('vscode:shared-process->electron-main=init-done');
}
......@@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { URI } from 'vs/base/common/uri';
import { memoize } from 'vs/base/common/decorators';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { BrowserWindow, ipcMain, WebContents, Event as ElectronEvent } from 'electron';
......@@ -32,7 +33,7 @@ export class SharedProcess implements ISharedProcess {
@IThemeMainService private readonly themeMainService: IThemeMainService
) {
// overall ready promise when shared process signals initialization is done
this._whenReady = new Promise<void>(c => ipcMain.once('shared-process->electron-main: init-done', () => c(undefined)));
this._whenReady = new Promise<void>(c => ipcMain.once('vscode:shared-process->electron-main=init-done', () => c(undefined)));
}
@memoize
......@@ -41,6 +42,7 @@ export class SharedProcess implements ISharedProcess {
show: false,
backgroundColor: this.themeMainService.getBackgroundColor(),
webPreferences: {
preload: URI.parse(require.toUrl('vs/code/electron-browser/preload.js')).fsPath,
images: false,
nodeIntegration: true,
webgl: false,
......@@ -105,18 +107,18 @@ export class SharedProcess implements ISharedProcess {
return new Promise<void>(c => {
// send payload once shared process is ready to receive it
disposables.add(Event.once(Event.fromNodeEventEmitter(ipcMain, 'shared-process->electron-main: ready-for-payload', ({ sender }: { sender: WebContents }) => sender))(sender => {
sender.send('electron-main->shared-process: payload', {
disposables.add(Event.once(Event.fromNodeEventEmitter(ipcMain, 'vscode:shared-process->electron-main=ready-for-payload', ({ sender }: { sender: WebContents }) => sender))(sender => {
sender.send('vscode:electron-main->shared-process=payload', {
sharedIPCHandle: this.environmentService.sharedIPCHandle,
args: this.environmentService.args,
logLevel: this.logService.getLevel()
});
// signal exit to shared process when we get disposed
disposables.add(toDisposable(() => sender.send('electron-main->shared-process: exit')));
disposables.add(toDisposable(() => sender.send('vscode:electron-main->shared-process=exit')));
// complete IPC-ready promise when shared process signals this to us
ipcMain.once('shared-process->electron-main: ipc-ready', () => c(undefined));
ipcMain.once('vscode:shared-process->electron-main=ipc-ready', () => c(undefined));
}));
});
}
......
......@@ -164,12 +164,11 @@ export class IssueMainService implements IIssueService {
}
});
ipcMain.on('windowsInfoRequest', (event: IpcMainEvent) => {
ipcMain.on('vscode:windowsInfoRequest', (event: IpcMainEvent) => {
this.launchMainService.getMainProcessInfo().then(info => {
event.sender.send('vscode:windowsInfoResponse', info.windows);
});
});
}
openReporter(data: IssueReporterData): Promise<void> {
......@@ -227,7 +226,7 @@ export class IssueMainService implements IIssueService {
if (!this._processExplorerWindow) {
this._processExplorerParentWindow = BrowserWindow.getFocusedWindow();
if (this._processExplorerParentWindow) {
const position = this.getWindowPosition(this._processExplorerParentWindow, 800, 300);
const position = this.getWindowPosition(this._processExplorerParentWindow, 800, 500);
this._processExplorerWindow = new BrowserWindow({
skipTaskbar: true,
resizable: true,
......
......@@ -4,6 +4,5 @@
*--------------------------------------------------------------------------------------------*/
import './inputClipboardActions';
import './sleepResumeRepaintMinimap';
import './selectionClipboard';
import './startDebugTextMate';
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import './sleepResumeRepaintMinimap';
......@@ -6,7 +6,7 @@
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { Registry } from 'vs/platform/registry/common/platform';
import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
import { ipcRenderer as ipc } from 'electron';
import { ipcRenderer } from 'vs/base/electron-sandbox/globals';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
class SleepResumeRepaintMinimap implements IWorkbenchContribution {
......@@ -14,7 +14,7 @@ class SleepResumeRepaintMinimap implements IWorkbenchContribution {
constructor(
@ICodeEditorService codeEditorService: ICodeEditorService
) {
ipc.on('vscode:osResume', () => {
ipcRenderer.on('vscode:osResume', () => {
codeEditorService.listCodeEditors().forEach(editor => editor.render(true));
});
}
......
......@@ -1028,6 +1028,8 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
// Handle folder upload
else {
// Create target folder
await this.fileService.createFolder(resource);
// Recursive upload files in this directory
......
......@@ -21,7 +21,7 @@ import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { DialogChannel } from 'vs/platform/dialogs/electron-browser/dialogIpc';
import { DownloadServiceChannel } from 'vs/platform/download/common/downloadIpc';
import { LoggerChannel } from 'vs/platform/log/common/logIpc';
import { ipcRenderer as ipc } from 'electron';
import { ipcRenderer } from 'vs/base/electron-sandbox/globals';
import { IDiagnosticInfoOptions, IRemoteDiagnosticInfo } from 'vs/platform/diagnostics/common/diagnostics';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { PersistentConnectionEventType } from 'vs/platform/remote/common/remoteAgentConnection';
......@@ -55,7 +55,7 @@ class RemoteAgentDiagnosticListener implements IWorkbenchContribution {
@IRemoteAgentService remoteAgentService: IRemoteAgentService,
@ILabelService labelService: ILabelService
) {
ipc.on('vscode:getDiagnosticInfo', (event: Event, request: { replyChannel: string, args: IDiagnosticInfoOptions }): void => {
ipcRenderer.on('vscode:getDiagnosticInfo', (event: unknown, request: { replyChannel: string, args: IDiagnosticInfoOptions }): void => {
const connection = remoteAgentService.getConnection();
if (connection) {
const hostName = labelService.getHostLabel(REMOTE_HOST_SCHEME, connection.remoteAuthority);
......@@ -65,14 +65,14 @@ class RemoteAgentDiagnosticListener implements IWorkbenchContribution {
(info as IRemoteDiagnosticInfo).hostName = hostName;
}
ipc.send(request.replyChannel, info);
ipcRenderer.send(request.replyChannel, info);
})
.catch(e => {
const errorMessage = e && e.message ? `Fetching remote diagnostics for '${hostName}' failed: ${e.message}` : `Fetching remote diagnostics for '${hostName}' failed.`;
ipc.send(request.replyChannel, { hostName, errorMessage });
ipcRenderer.send(request.replyChannel, { hostName, errorMessage });
});
} else {
ipc.send(request.replyChannel);
ipcRenderer.send(request.replyChannel);
}
});
}
......
......@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ipcRenderer as ipc } from 'electron';
import { ipcRenderer } from 'vs/base/electron-sandbox/globals';
import { join } from 'vs/base/common/path';
import { onDidChangeFullscreen, isFullscreen } from 'vs/base/browser/browser';
import { getTotalHeight, getTotalWidth } from 'vs/base/browser/dom';
......@@ -112,7 +112,7 @@ class PartsSplash {
// the color needs to be in hex
const backgroundColor = this._themeService.getColorTheme().getColor(editorBackground) || themes.WORKBENCH_BACKGROUND(this._themeService.getColorTheme());
const payload = JSON.stringify({ baseTheme, background: Color.Format.CSS.formatHex(backgroundColor) });
ipc.send('vscode:changeColorTheme', this._envService.configuration.windowId, payload);
ipcRenderer.send('vscode:changeColorTheme', this._envService.configuration.windowId, payload);
}
}
......
......@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ipcRenderer as ipc } from 'electron';
import { ipcRenderer } from 'vs/base/electron-sandbox/globals';
import { IOpenFileRequest } from 'vs/platform/windows/common/windows';
import { ITerminalNativeService, LinuxDistro } from 'vs/workbench/contrib/terminal/common/terminal';
import { URI } from 'vs/base/common/uri';
......@@ -31,8 +31,8 @@ export class TerminalNativeService implements ITerminalNativeService {
@IInstantiationService readonly instantiationService: IInstantiationService,
@IRemoteAgentService remoteAgentService: IRemoteAgentService
) {
ipc.on('vscode:openFiles', (_event: any, request: IOpenFileRequest) => this._onOpenFileRequest.fire(request));
ipc.on('vscode:osResume', () => this._onOsResume.fire());
ipcRenderer.on('vscode:openFiles', (event: unknown, request: IOpenFileRequest) => this._onOpenFileRequest.fire(request));
ipcRenderer.on('vscode:osResume', () => this._onOsResume.fire());
const connection = remoteAgentService.getConnection();
if (connection && connection.remoteAuthority) {
......
......@@ -3,7 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { FindInPageOptions, OnBeforeRequestListenerDetails, OnHeadersReceivedListenerDetails, Response, WebContents, WebviewTag, ipcRenderer } from 'electron';
import { FindInPageOptions, OnBeforeRequestListenerDetails, OnHeadersReceivedListenerDetails, Response, WebContents, WebviewTag } from 'electron';
import { ipcRenderer } from 'vs/base/electron-sandbox/globals';
import { addDisposableListener } from 'vs/base/browser/dom';
import { ThrottledDelayer } from 'vs/base/common/async';
import { Emitter, Event } from 'vs/base/common/event';
......
......@@ -22,7 +22,8 @@ import * as browser from 'vs/base/browser/browser';
import { ICommandService, CommandsRegistry } from 'vs/platform/commands/common/commands';
import { IResourceEditorInput } from 'vs/platform/editor/common/editor';
import { KeyboardMapperFactory } from 'vs/workbench/services/keybinding/electron-browser/nativeKeymapService';
import { ipcRenderer as ipc, webFrame, crashReporter, CrashReporterStartOptions, Event as IpcEvent } from 'electron';
import { webFrame, crashReporter, CrashReporterStartOptions } from 'electron';
import { ipcRenderer } from 'vs/base/electron-sandbox/globals';
import { IWorkspaceEditingService } from 'vs/workbench/services/workspaces/common/workspaceEditing';
import { IMenuService, MenuId, IMenu, MenuItemAction, ICommandAction, SubmenuItemAction, MenuRegistry } from 'vs/platform/actions/common/actions';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
......@@ -127,7 +128,7 @@ export class NativeWindow extends Disposable {
});
// Support runAction event
ipc.on('vscode:runAction', async (event: IpcEvent, request: IRunActionInWindowRequest) => {
ipcRenderer.on('vscode:runAction', async (event: unknown, request: IRunActionInWindowRequest) => {
const args: unknown[] = request.args || [];
// If we run an action from the touchbar, we fill in the currently active resource
......@@ -158,47 +159,47 @@ export class NativeWindow extends Disposable {
});
// Support runKeybinding event
ipc.on('vscode:runKeybinding', (event: IpcEvent, request: IRunKeybindingInWindowRequest) => {
ipcRenderer.on('vscode:runKeybinding', (event: unknown, request: IRunKeybindingInWindowRequest) => {
if (document.activeElement) {
this.keybindingService.dispatchByUserSettingsLabel(request.userSettingsLabel, document.activeElement);
}
});
// Error reporting from main
ipc.on('vscode:reportError', (event: IpcEvent, error: string) => {
ipcRenderer.on('vscode:reportError', (event: unknown, error: string) => {
if (error) {
errors.onUnexpectedError(JSON.parse(error));
}
});
// Support openFiles event for existing and new files
ipc.on('vscode:openFiles', (event: IpcEvent, request: IOpenFileRequest) => this.onOpenFiles(request));
ipcRenderer.on('vscode:openFiles', (event: unknown, request: IOpenFileRequest) => this.onOpenFiles(request));
// Support addFolders event if we have a workspace opened
ipc.on('vscode:addFolders', (event: IpcEvent, request: IAddFoldersRequest) => this.onAddFoldersRequest(request));
ipcRenderer.on('vscode:addFolders', (event: unknown, request: IAddFoldersRequest) => this.onAddFoldersRequest(request));
// Message support
ipc.on('vscode:showInfoMessage', (event: IpcEvent, message: string) => {
ipcRenderer.on('vscode:showInfoMessage', (event: unknown, message: string) => {
this.notificationService.info(message);
});
ipc.on('vscode:displayChanged', (event: IpcEvent) => {
ipcRenderer.on('vscode:displayChanged', () => {
clearAllFontInfos();
});
// Fullscreen Events
ipc.on('vscode:enterFullScreen', async () => {
ipcRenderer.on('vscode:enterFullScreen', async () => {
await this.lifecycleService.when(LifecyclePhase.Ready);
browser.setFullscreen(true);
});
ipc.on('vscode:leaveFullScreen', async () => {
ipcRenderer.on('vscode:leaveFullScreen', async () => {
await this.lifecycleService.when(LifecyclePhase.Ready);
browser.setFullscreen(false);
});
// High Contrast Events
ipc.on('vscode:enterHighContrast', async () => {
ipcRenderer.on('vscode:enterHighContrast', async () => {
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
if (windowConfig?.autoDetectHighContrast) {
await this.lifecycleService.when(LifecyclePhase.Ready);
......@@ -206,7 +207,7 @@ export class NativeWindow extends Disposable {
}
});
ipc.on('vscode:leaveHighContrast', async () => {
ipcRenderer.on('vscode:leaveHighContrast', async () => {
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
if (windowConfig?.autoDetectHighContrast) {
await this.lifecycleService.when(LifecyclePhase.Ready);
......@@ -215,12 +216,12 @@ export class NativeWindow extends Disposable {
});
// keyboard layout changed event
ipc.on('vscode:keyboardLayoutChanged', () => {
ipcRenderer.on('vscode:keyboardLayoutChanged', () => {
KeyboardMapperFactory.INSTANCE._onKeyboardLayoutChanged();
});
// accessibility support changed event
ipc.on('vscode:accessibilitySupportChanged', (event: IpcEvent, accessibilitySupportEnabled: boolean) => {
ipcRenderer.on('vscode:accessibilitySupportChanged', (event: unknown, accessibilitySupportEnabled: boolean) => {
this.accessibilityService.setAccessibilitySupport(accessibilitySupportEnabled ? AccessibilitySupport.Enabled : AccessibilitySupport.Disabled);
});
......@@ -399,7 +400,7 @@ export class NativeWindow extends Disposable {
this.setupOpenHandlers();
// Emit event when vscode is ready
this.lifecycleService.when(LifecyclePhase.Ready).then(() => ipc.send('vscode:workbenchReady', this.environmentService.configuration.windowId));
this.lifecycleService.when(LifecyclePhase.Ready).then(() => ipcRenderer.send('vscode:workbenchReady', this.environmentService.configuration.windowId));
// Integrity warning
this.integrityService.isPure().then(res => this.titleService.updateProperties({ isPure: res.isPure }));
......
......@@ -63,6 +63,8 @@ export class EditorService extends Disposable implements EditorServiceImpl {
//#endregion
private readonly fileEditorInputFactory = Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).getFileEditorInputFactory();
constructor(
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
@IUntitledTextEditorService private readonly untitledTextEditorService: IUntitledTextEditorService,
......@@ -295,7 +297,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
}
private closeOnFileDelete: boolean = false;
private fileEditorInputFactory = Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).getFileEditorInputFactory();
private onConfigurationUpdated(configuration: IWorkbenchEditorConfiguration): void {
if (typeof configuration.workbench?.editor?.closeOnFileDelete === 'boolean') {
this.closeOnFileDelete = configuration.workbench.editor.closeOnFileDelete;
......
......@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ipcRenderer as ipc } from 'electron';
import { ipcRenderer } from 'vs/base/electron-sandbox/globals';
import { ExtensionHostProcessWorker } from 'vs/workbench/services/extensions/electron-browser/extensionHost';
import { CachedExtensionScanner } from 'vs/workbench/services/extensions/electron-browser/cachedExtensionScanner';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
......@@ -573,7 +573,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
public _onExtensionHostExit(code: number): void {
if (this._isExtensionDevTestFromCli) {
// When CLI testing make sure to exit with proper exit code
ipc.send('vscode:exit', code);
ipcRenderer.send('vscode:exit', code);
} else {
// Expected development extension termination: When the extension host goes down we also shutdown the window
this._electronService.closeWindow();
......
......@@ -3,17 +3,17 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { localize } from 'vs/nls';
import { toErrorMessage } from 'vs/base/common/errorMessage';
import { ShutdownReason, StartupKind, handleVetos, ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IStorageService, StorageScope, WillSaveStateReason } from 'vs/platform/storage/common/storage';
import { ipcRenderer as ipc } from 'electron';
import { ipcRenderer } from 'vs/base/electron-sandbox/globals';
import { ILogService } from 'vs/platform/log/common/log';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { onUnexpectedError } from 'vs/base/common/errors';
import { AbstractLifecycleService } from 'vs/platform/lifecycle/common/lifecycleService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import Severity from 'vs/base/common/severity';
import { localize } from 'vs/nls';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
......@@ -60,7 +60,7 @@ export class NativeLifecycleService extends AbstractLifecycleService {
const windowId = this.environmentService.configuration.windowId;
// Main side indicates that window is about to unload, check for vetos
ipc.on('vscode:onBeforeUnload', (_event: unknown, reply: { okChannel: string, cancelChannel: string, reason: ShutdownReason }) => {
ipcRenderer.on('vscode:onBeforeUnload', (event: unknown, reply: { okChannel: string, cancelChannel: string, reason: ShutdownReason }) => {
this.logService.trace(`lifecycle: onBeforeUnload (reason: ${reply.reason})`);
// trigger onBeforeShutdown events and veto collecting
......@@ -68,18 +68,18 @@ export class NativeLifecycleService extends AbstractLifecycleService {
if (veto) {
this.logService.trace('lifecycle: onBeforeUnload prevented via veto');
ipc.send(reply.cancelChannel, windowId);
ipcRenderer.send(reply.cancelChannel, windowId);
} else {
this.logService.trace('lifecycle: onBeforeUnload continues without veto');
this.shutdownReason = reply.reason;
ipc.send(reply.okChannel, windowId);
ipcRenderer.send(reply.okChannel, windowId);
}
});
});
// Main side indicates that we will indeed shutdown
ipc.on('vscode:onWillUnload', async (_event: unknown, reply: { replyChannel: string, reason: ShutdownReason }) => {
ipcRenderer.on('vscode:onWillUnload', async (event: unknown, reply: { replyChannel: string, reason: ShutdownReason }) => {
this.logService.trace(`lifecycle: onWillUnload (reason: ${reply.reason})`);
// trigger onWillShutdown events and joining
......@@ -89,7 +89,7 @@ export class NativeLifecycleService extends AbstractLifecycleService {
this._onShutdown.fire();
// acknowledge to main side
ipc.send(reply.replyChannel, windowId);
ipcRenderer.send(reply.replyChannel, windowId);
});
// Save shutdown reason to retrieve on next startup
......
......@@ -24,6 +24,9 @@ import 'vs/workbench/services/update/electron-sandbox/updateService';
//#region --- workbench contributions
// CodeEditor Contributions
import 'vs/workbench/contrib/codeEditor/electron-sandbox/codeEditor.contribution';
// Debug
import 'vs/workbench/contrib/debug/electron-sandbox/extensionHostDebugService';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册