Merge from vscode 4d91d96e5e121b38d33508cdef17868bab255eae

This commit is contained in:
ADS Merger
2020-06-18 04:32:54 +00:00
committed by AzureDataStudio
parent a971aee5bd
commit 5e7071e466
1002 changed files with 24201 additions and 13193 deletions

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { app, ipcMain as ipc, systemPreferences, shell, Event, contentTracing, protocol, powerMonitor, IpcMainEvent, BrowserWindow, dialog, session } from 'electron';
import { app, ipcMain as ipc, systemPreferences, shell, Event, contentTracing, protocol, IpcMainEvent, BrowserWindow, dialog, session } from 'electron';
import { IProcessEnvironment, isWindows, isMacintosh } from 'vs/base/common/platform';
import { WindowsMainService } from 'vs/platform/windows/electron-main/windowsMainService';
import { IWindowOpenable } from 'vs/platform/windows/common/windows';
@@ -26,7 +26,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IURLService } from 'vs/platform/url/common/url';
import { URLHandlerChannelClient, URLHandlerRouter } from 'vs/platform/url/common/urlIpc';
import { ITelemetryService, machineIdKey, trueMachineIdKey } from 'vs/platform/telemetry/common/telemetry';
import { ITelemetryService, machineIdKey } from 'vs/platform/telemetry/common/telemetry';
import { NullTelemetryService, combinedAppender, LogAppender } from 'vs/platform/telemetry/common/telemetryUtils';
import { TelemetryAppenderClient } from 'vs/platform/telemetry/node/telemetryIpc';
import { TelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService';
@@ -261,13 +261,6 @@ export class CodeApplication extends Disposable {
}
});
ipc.on('vscode:exit', (event: Event, code: number) => {
this.logService.trace('IPC#vscode:exit', code);
this.dispose();
this.lifecycleMainService.kill(code);
});
ipc.on('vscode:fetchShellEnv', async (event: IpcMainEvent) => {
const webContents = event.sender;
@@ -294,13 +287,6 @@ export class CodeApplication extends Disposable {
(async () => {
await this.lifecycleMainService.when(LifecycleMainPhase.AfterWindowOpen);
// After waking up from sleep (after window opened)
powerMonitor.on('resume', () => {
if (this.windowsMainService) {
this.windowsMainService.sendToAll('vscode:osResume', undefined);
}
});
// Keyboard layout changes (after window opened)
const nativeKeymap = await import('native-keymap');
nativeKeymap.onDidChangeKeyboardLayout(() => {
@@ -365,8 +351,8 @@ export class CodeApplication extends Disposable {
// Resolve unique machine ID
this.logService.trace('Resolving machine identifier...');
const { machineId, trueMachineId } = await this.resolveMachineId();
this.logService.trace(`Resolved machine identifier: ${machineId} (trueMachineId: ${trueMachineId})`);
const machineId = await this.resolveMachineId();
this.logService.trace(`Resolved machine identifier: ${machineId}`);
// Spawn shared process after the first window has opened and 3s have passed
const sharedProcess = this.instantiationService.createInstance(SharedProcess, machineId, this.userEnv);
@@ -387,7 +373,7 @@ export class CodeApplication extends Disposable {
});
// Services
const appInstantiationService = await this.createServices(machineId, trueMachineId, sharedProcess, sharedProcessReady);
const appInstantiationService = await this.createServices(machineId, sharedProcess, sharedProcessReady);
// Create driver
if (this.environmentService.driverHandle) {
@@ -412,32 +398,21 @@ export class CodeApplication extends Disposable {
}
}
private async resolveMachineId(): Promise<{ machineId: string, trueMachineId?: string }> {
private async resolveMachineId(): Promise<string> {
// We cache the machineId for faster lookups on startup
// and resolve it only once initially if not cached
// and resolve it only once initially if not cached or we need to replace the macOS iBridge device
let machineId = this.stateService.getItem<string>(machineIdKey);
if (!machineId) {
if (!machineId || (isMacintosh && machineId === '6c9d2bc8f91b89624add29c0abeae7fb42bf539fa1cdb2e3e57cd668fa9bcead')) {
machineId = await getMachineId();
this.stateService.setItem(machineIdKey, machineId);
}
// Check if machineId is hashed iBridge Device
let trueMachineId: string | undefined;
if (isMacintosh && machineId === '6c9d2bc8f91b89624add29c0abeae7fb42bf539fa1cdb2e3e57cd668fa9bcead') {
trueMachineId = this.stateService.getItem<string>(trueMachineIdKey);
if (!trueMachineId) {
trueMachineId = await getMachineId();
this.stateService.setItem(trueMachineIdKey, trueMachineId);
}
}
return { machineId, trueMachineId };
return machineId;
}
private async createServices(machineId: string, trueMachineId: string | undefined, sharedProcess: SharedProcess, sharedProcessReady: Promise<Client<string>>): Promise<IInstantiationService> {
private async createServices(machineId: string, sharedProcess: SharedProcess, sharedProcessReady: Promise<Client<string>>): Promise<IInstantiationService> {
const services = new ServiceCollection();
switch (process.platform) {
@@ -489,7 +464,7 @@ export class CodeApplication extends Disposable {
const appender = combinedAppender(new TelemetryAppenderClient(channel), new LogAppender(this.logService));
const commonProperties = resolveCommonProperties(product.commit, product.version, machineId, product.msftInternalDomains, this.environmentService.installSourcePath);
const piiPaths = this.environmentService.extensionsPath ? [this.environmentService.appRoot, this.environmentService.extensionsPath] : [this.environmentService.appRoot];
const config: ITelemetryServiceConfig = { appender, commonProperties, piiPaths, trueMachineId, sendErrorTelemetry: true };
const config: ITelemetryServiceConfig = { appender, commonProperties, piiPaths, sendErrorTelemetry: true };
services.set(ITelemetryService, new SyncDescriptor(TelemetryService, [config]));
} else {

View File

@@ -23,7 +23,7 @@ type Credentials = {
export class ProxyAuthHandler extends Disposable {
_serviceBrand: undefined;
declare readonly _serviceBrand: undefined;
private retryCount = 0;
@@ -60,7 +60,8 @@ export class ProxyAuthHandler extends Disposable {
webPreferences: {
nodeIntegration: true,
webviewTag: true,
enableWebSQL: false
enableWebSQL: false,
nativeWindowOpen: true
}
};

View File

@@ -47,6 +47,9 @@ import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemPro
import { Schemas } from 'vs/base/common/network';
import { IFileService } from 'vs/platform/files/common/files';
import { IStorageKeysSyncRegistryService, StorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
import { ITunnelService } from 'vs/platform/remote/common/tunnel';
import { TunnelService } from 'vs/platform/remote/node/tunnelService';
import { IProductService } from 'vs/platform/product/common/productService';
class ExpectedError extends Error {
readonly isExpected = true;
@@ -162,6 +165,8 @@ class CodeMain {
services.set(IThemeMainService, new SyncDescriptor(ThemeMainService));
services.set(ISignService, new SyncDescriptor(SignService));
services.set(IStorageKeysSyncRegistryService, new SyncDescriptor(StorageKeysSyncRegistryService));
services.set(IProductService, { _serviceBrand: undefined, ...product });
services.set(ITunnelService, new SyncDescriptor(TunnelService));
return [new InstantiationService(services, true), instanceEnvironment, environmentService];
}

View File

@@ -47,6 +47,7 @@ export class SharedProcess implements ISharedProcess {
nodeIntegration: true,
webgl: false,
enableWebSQL: false,
nativeWindowOpen: true,
disableBlinkFeatures: 'Auxclick' // do NOT change, allows us to identify this window as shared-process in the process explorer
}
});

View File

@@ -8,7 +8,7 @@ import * as objects from 'vs/base/common/objects';
import * as nls from 'vs/nls';
import { Emitter } from 'vs/base/common/event';
import { URI } from 'vs/base/common/uri';
import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage, Rectangle, Display, TouchBarSegmentedControl, NativeImage, BrowserWindowConstructorOptions, SegmentedControlSegment, nativeTheme } from 'electron';
import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage, Rectangle, Display, TouchBarSegmentedControl, NativeImage, BrowserWindowConstructorOptions, SegmentedControlSegment, nativeTheme, Event } from 'electron';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
import { ILogService } from 'vs/platform/log/common/log';
@@ -91,15 +91,18 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private static readonly MAX_URL_LENGTH = 2 * 1024 * 1024; // https://cs.chromium.org/chromium/src/url/url_constants.cc?l=32
private readonly _onLoad = this._register(new Emitter<void>());
readonly onLoad = this._onLoad.event;
private readonly _onReady = this._register(new Emitter<void>());
readonly onReady = this._onReady.event;
private readonly _onClose = this._register(new Emitter<void>());
readonly onClose = this._onClose.event;
private readonly _onDestroy = this._register(new Emitter<void>());
readonly onDestroy = this._onDestroy.event;
private readonly _onLoad = this._register(new Emitter<void>());
readonly onLoad = this._onLoad.event;
private hiddenTitleBarStyle: boolean | undefined;
private showTimeoutHandle: NodeJS.Timeout | undefined;
private _lastFocusTime: number;
@@ -167,7 +170,8 @@ export class CodeWindow extends Disposable implements ICodeWindow {
nodeIntegration: true,
nodeIntegrationInWorker: RUN_TEXTMATE_IN_WORKER,
webviewTag: true,
enableWebSQL: false
enableWebSQL: false,
nativeWindowOpen: true
}
};
@@ -346,6 +350,9 @@ export class CodeWindow extends Disposable implements ICodeWindow {
while (this.whenReadyCallbacks.length) {
this.whenReadyCallbacks.pop()!(this);
}
// Events
this._onReady.fire();
}
ready(): Promise<ICodeWindow> {
@@ -431,24 +438,34 @@ export class CodeWindow extends Disposable implements ICodeWindow {
this._lastFocusTime = Date.now();
});
// Simple fullscreen doesn't resize automatically when the resolution changes so as a workaround
// we need to detect when display metrics change or displays are added/removed and toggle the
// fullscreen manually.
if (isMacintosh) {
const simpleFullScreenScheduler = this._register(new RunOnceScheduler(() => {
const displayChangedScheduler = this._register(new RunOnceScheduler(() => {
if (!this._win) {
return; // disposed
}
// Notify renderers about displays changed
this.sendWhenReady('vscode:displayChanged');
// Simple fullscreen doesn't resize automatically when the resolution changes so as a workaround
// we need to detect when display metrics change or displays are added/removed and toggle the
// fullscreen manually.
if (!this.useNativeFullScreen() && this.isFullScreen) {
this.setFullScreen(false);
this.setFullScreen(true);
}
this.sendWhenReady('vscode:displayChanged');
}, 100));
const displayChangedListener = () => simpleFullScreenScheduler.schedule();
const displayChangedListener = (event: Event, display: Display, changedMetrics?: string[]) => {
if (Array.isArray(changedMetrics) && changedMetrics.length === 1 && changedMetrics[0] === 'workArea') {
// Electron will emit 'display-metrics-changed' events even when actually
// going fullscreen, because the dock hides. However, we do not want to
// react on this event as there is no change in display bounds.
return;
}
displayChangedScheduler.schedule();
};
screen.on('display-metrics-changed', displayChangedListener);
this._register(toDisposable(() => screen.removeListener('display-metrics-changed', displayChangedListener)));