Skip to content

Commit 65c65e2

Browse files
author
Benjamin Pasero
committed
debt - introduce and use dialog main service
1 parent f8cdbe7 commit 65c65e2

6 files changed

Lines changed: 261 additions & 216 deletions

File tree

src/vs/code/electron-main/app.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { app, ipcMain as ipc, systemPreferences, shell, Event, contentTracing, protocol, powerMonitor, IpcMainEvent } from 'electron';
6+
import { app, ipcMain as ipc, systemPreferences, shell, Event, contentTracing, protocol, powerMonitor, IpcMainEvent, BrowserWindow } from 'electron';
77
import { IProcessEnvironment, isWindows, isMacintosh } from 'vs/base/common/platform';
88
import { WindowsManager } from 'vs/code/electron-main/windows';
99
import { OpenContext, IWindowOpenable } from 'vs/platform/windows/common/windows';
@@ -78,13 +78,16 @@ import { IElectronService } from 'vs/platform/electron/node/electron';
7878
import { ElectronMainService } from 'vs/platform/electron/electron-main/electronMainService';
7979
import { ISharedProcessMainService, SharedProcessMainService } from 'vs/platform/ipc/electron-main/sharedProcessMainService';
8080
import { assign } from 'vs/base/common/objects';
81+
import { IDialogMainService, DialogMainService } from 'vs/platform/dialogs/electron-main/dialogs';
82+
import { withNullAsUndefined } from 'vs/base/common/types';
8183

8284
export class CodeApplication extends Disposable {
8385

8486
private static readonly MACHINE_ID_KEY = 'telemetry.machineId';
8587
private static readonly TRUE_MACHINE_ID_KEY = 'telemetry.trueMachineId';
8688

8789
private windowsMainService: IWindowsMainService | undefined;
90+
private dialogMainService: IDialogMainService | undefined;
8891

8992
constructor(
9093
private readonly mainIpcServer: Server,
@@ -449,6 +452,7 @@ export class CodeApplication extends Disposable {
449452
}
450453

451454
services.set(IWindowsMainService, new SyncDescriptor(WindowsManager, [machineId, this.userEnv]));
455+
services.set(IDialogMainService, new SyncDescriptor(DialogMainService));
452456
services.set(ISharedProcessMainService, new SyncDescriptor(SharedProcessMainService, [sharedProcess]));
453457
services.set(ILaunchMainService, new SyncDescriptor(LaunchMainService));
454458

@@ -503,13 +507,13 @@ export class CodeApplication extends Disposable {
503507

504508
contentTracing.stopRecording(join(homedir(), `${product.applicationName}-${Math.random().toString(16).slice(-4)}.trace.txt`), path => {
505509
if (!timeout) {
506-
if (this.windowsMainService) {
507-
this.windowsMainService.showMessageBox({
510+
if (this.dialogMainService) {
511+
this.dialogMainService.showMessageBox({
508512
type: 'info',
509513
message: localize('trace.message', "Successfully created trace."),
510514
detail: localize('trace.detail', "Please create an issue and manually attach the following file:\n{0}", path),
511515
buttons: [localize('trace.ok', "Ok")]
512-
}, this.windowsMainService.getLastActiveWindow());
516+
}, withNullAsUndefined(BrowserWindow.getFocusedWindow()));
513517
}
514518
} else {
515519
this.logService.info(`Tracing: data recorded (after 30s timeout) to ${path}`);
@@ -580,6 +584,7 @@ export class CodeApplication extends Disposable {
580584

581585
// Propagate to clients
582586
const windowsMainService = this.windowsMainService = accessor.get(IWindowsMainService);
587+
this.dialogMainService = accessor.get(IDialogMainService);
583588

584589
// Create a URL handler to open file URIs in the active window
585590
const environmentService = accessor.get(IEnvironmentService);

0 commit comments

Comments
 (0)