diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index 630c577a640..c3e48687980 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -71,7 +71,7 @@ import { withNullAsUndefined } from 'vs/base/common/types'; import { mnemonicButtonLabel, getPathLabel } from 'vs/base/common/labels'; import { WebviewMainService } from 'vs/platform/webview/electron-main/webviewMainService'; import { IWebviewManagerService } from 'vs/platform/webview/common/webviewManagerService'; -import { FileOperationError, FileOperationResult, IFileService } from 'vs/platform/files/common/files'; +import { IFileService } from 'vs/platform/files/common/files'; import { stripComments } from 'vs/base/common/json'; import { generateUuid } from 'vs/base/common/uuid'; import { VSBuffer } from 'vs/base/common/buffer'; @@ -148,37 +148,6 @@ export class CodeApplication extends Disposable { // // !!! DO NOT CHANGE without consulting the documentation !!! // - app.on('remote-require', (event, sender, module) => { - this.logService.trace('app#on(remote-require): prevented'); - - event.preventDefault(); - }); - app.on('remote-get-global', (event, sender, module) => { - this.logService.trace(`app#on(remote-get-global): prevented on ${module}`); - - event.preventDefault(); - }); - app.on('remote-get-builtin', (event, sender, module) => { - this.logService.trace(`app#on(remote-get-builtin): prevented on ${module}`); - - if (module !== 'clipboard') { - event.preventDefault(); - } - }); - app.on('remote-get-current-window', event => { - this.logService.trace(`app#on(remote-get-current-window): prevented`); - - event.preventDefault(); - }); - app.on('remote-get-current-web-contents', event => { - if (this.environmentMainService.args.driver) { - return; // the driver needs access to web contents - } - - this.logService.trace(`app#on(remote-get-current-web-contents): prevented`); - - event.preventDefault(); - }); app.on('web-contents-created', (event, contents) => { contents.on('will-attach-webview', (event, webPreferences, params) => { @@ -222,19 +191,19 @@ export class CodeApplication extends Disposable { event.preventDefault(); }); - contents.on('new-window', (event, url) => { - event.preventDefault(); // prevent code that wants to open links - + contents.setWindowOpenHandler(({ url }) => { this.nativeHostMainService?.openExternal(undefined, url); + + return { action: 'deny' }; }); - const isUrlFromWebview = (requestingUrl: string) => - requestingUrl.startsWith(`${Schemas.vscodeWebview}://`); + const isUrlFromWebview = (requestingUrl: string) => requestingUrl.startsWith(`${Schemas.vscodeWebview}://`); session.defaultSession.setPermissionRequestHandler((_webContents, permission /* 'media' | 'geolocation' | 'notifications' | 'midiSysex' | 'pointerLock' | 'fullscreen' | 'openExternal' */, callback, details) => { if (isUrlFromWebview(details.requestingUrl)) { return callback(permission === 'clipboard-read'); } + return callback(false); }); @@ -242,6 +211,7 @@ export class CodeApplication extends Disposable { if (isUrlFromWebview(details.requestingUrl)) { return permission === 'clipboard-read'; } + return false; }); }); @@ -379,18 +349,6 @@ export class CodeApplication extends Disposable { this.logService.debug(`from: ${this.environmentMainService.appRoot}`); this.logService.debug('args:', this.environmentMainService.args); - // TODO@bpasero TODO@deepak1556 workaround for #120655 - try { - const cachedDataPath = URI.file(this.environmentMainService.chromeCachedDataDir); - this.logService.trace(`Deleting Chrome cached data path: ${cachedDataPath.fsPath}`); - - await this.fileService.del(cachedDataPath, { recursive: true }); - } catch (error) { - if ((error).fileOperationResult !== FileOperationResult.FILE_NOT_FOUND) { - this.logService.error(error); - } - } - // Make sure we associate the program with the app user model id // This will help Windows to associate the running program with // any shortcut that is pinned to the taskbar and prevent showing @@ -678,16 +636,18 @@ export class CodeApplication extends Disposable { // Check for initial URLs to handle from protocol link invocations const pendingWindowOpenablesFromProtocolLinks: IWindowOpenable[] = []; const pendingProtocolLinksToHandle = [ + // Windows/Linux: protocol handler invokes CLI with --open-url ...this.environmentMainService.args['open-url'] ? this.environmentMainService.args._urls || [] : [], // macOS: open-url events ...((global).getOpenUrls() || []) as string[] + ].map(url => { try { return { uri: URI.parse(url), url }; } catch { - return null; + return undefined; } }).filter((obj): obj is { uri: URI, url: string } => { if (!obj) { @@ -741,7 +701,7 @@ export class CodeApplication extends Disposable { cli: { ...environmentService.args }, urisToOpen: [windowOpenableFromProtocolLink], gotoLineMode: true - /* remoteAuthority will be determined based on windowOpenableFromProtocolLink */ + // remoteAuthority: will be determined based on windowOpenableFromProtocolLink }); window.focus(); // this should help ensuring that the right window gets focus when multiple are opened @@ -804,7 +764,7 @@ export class CodeApplication extends Disposable { urisToOpen: pendingWindowOpenablesFromProtocolLinks, gotoLineMode: true, initialStartup: true - /* remoteAuthority will be determined based on pendingWindowOpenablesFromProtocolLinks */ + // remoteAuthority: will be determined based on pendingWindowOpenablesFromProtocolLinks }); } @@ -831,7 +791,7 @@ export class CodeApplication extends Disposable { noRecentEntry, waitMarkerFileURI, initialStartup: true, - /* remoteAuthority will be determined based on macOpenFiles */ + // remoteAuthority: will be determined based on macOpenFiles }); } diff --git a/src/vs/code/node/cli.ts b/src/vs/code/node/cli.ts index 2e7b324ed1d..9c7ad6268b6 100644 --- a/src/vs/code/node/cli.ts +++ b/src/vs/code/node/cli.ts @@ -56,7 +56,7 @@ export async function main(argv: string[]): Promise { // Extensions Management else if (shouldSpawnCliProcess(args)) { - const cli = await new Promise((c, e) => require(['vs/code/node/cliProcessMain'], c, e)); + const cli = await new Promise((resolve, reject) => require(['vs/code/node/cliProcessMain'], resolve, reject)); await cli.main(args); return; diff --git a/src/vs/platform/backup/electron-main/backupMainService.ts b/src/vs/platform/backup/electron-main/backupMainService.ts index ac9d7f2a86d..1bd2f63f6cd 100644 --- a/src/vs/platform/backup/electron-main/backupMainService.ts +++ b/src/vs/platform/backup/electron-main/backupMainService.ts @@ -54,21 +54,23 @@ export class BackupMainService implements IBackupMainService { backups = Object.create(null); } - // read empty workspaces backups first - if (backups.emptyWorkspaceInfos) { - this.emptyWindows = await this.validateEmptyWorkspaces(backups.emptyWorkspaceInfos); - } + // validate empty workspaces backups first + this.emptyWindows = await this.validateEmptyWorkspaces(backups.emptyWorkspaceInfos); // read workspace backups let rootWorkspaces: IWorkspaceBackupInfo[] = []; try { if (Array.isArray(backups.rootURIWorkspaces)) { - rootWorkspaces = backups.rootURIWorkspaces.map(workspace => ({ workspace: { id: workspace.id, configPath: URI.parse(workspace.configURIPath) }, remoteAuthority: workspace.remoteAuthority })); + rootWorkspaces = backups.rootURIWorkspaces.map(workspace => ({ + workspace: { id: workspace.id, configPath: URI.parse(workspace.configURIPath) }, + remoteAuthority: workspace.remoteAuthority + })); } } catch (e) { // ignore URI parsing exceptions } + // validate workspace backups this.workspaces = await this.validateWorkspaces(rootWorkspaces); // read folder backups @@ -81,6 +83,7 @@ export class BackupMainService implements IBackupMainService { // ignore URI parsing exceptions } + // validate folder backups this.folders = await this.validateFolders(workspaceFolders); // save again in case some workspaces or folders have been removed diff --git a/src/vs/platform/issue/electron-main/issueMainService.ts b/src/vs/platform/issue/electron-main/issueMainService.ts index 1eb0ac224bc..0df99eba03e 100644 --- a/src/vs/platform/issue/electron-main/issueMainService.ts +++ b/src/vs/platform/issue/electron-main/issueMainService.ts @@ -308,7 +308,6 @@ export class IssueMainService implements ICommonIssueService { additionalArguments: [`--vscode-window-config=${ipcObjectUrl.resource.toString()}`, '--context-isolation' /* TODO@bpasero: Use process.contextIsolateed when 13-x-y is adopted (https://github.com/electron/electron/pull/28030) */], v8CacheOptions: browserCodeLoadingCacheStrategy, enableWebSQL: false, - enableRemoteModule: false, spellcheck: false, nativeWindowOpen: true, zoomFactor: zoomLevelToZoomFactor(options.zoomLevel), diff --git a/src/vs/platform/product/common/product.ts b/src/vs/platform/product/common/product.ts index 4a0b94187d6..1eafa991bd9 100644 --- a/src/vs/platform/product/common/product.ts +++ b/src/vs/platform/product/common/product.ts @@ -54,7 +54,7 @@ else { // Running out of sources if (Object.keys(product).length === 0) { Object.assign(product, { - version: '1.57.0-dev', + version: '1.58.0-dev', nameShort: isWeb ? 'Code Web - OSS Dev' : 'Code - OSS Dev', nameLong: isWeb ? 'Code Web - OSS Dev' : 'Code - OSS Dev', applicationName: 'code-oss', diff --git a/src/vs/platform/sharedProcess/electron-main/sharedProcess.ts b/src/vs/platform/sharedProcess/electron-main/sharedProcess.ts index f62912e56d1..a2d420a49fe 100644 --- a/src/vs/platform/sharedProcess/electron-main/sharedProcess.ts +++ b/src/vs/platform/sharedProcess/electron-main/sharedProcess.ts @@ -170,7 +170,6 @@ export class SharedProcess extends Disposable implements ISharedProcess { nodeIntegration: true, contextIsolation: false, enableWebSQL: false, - enableRemoteModule: false, spellcheck: false, nativeWindowOpen: true, images: false, diff --git a/src/vs/platform/windows/electron-main/window.ts b/src/vs/platform/windows/electron-main/window.ts index c597738aa69..9ec6e9fd476 100644 --- a/src/vs/platform/windows/electron-main/window.ts +++ b/src/vs/platform/windows/electron-main/window.ts @@ -186,7 +186,6 @@ export class CodeWindow extends Disposable implements ICodeWindow { [`--vscode-window-config=${this.configObjectUrl.resource.toString()}`], v8CacheOptions: browserCodeLoadingCacheStrategy, enableWebSQL: false, - enableRemoteModule: false, spellcheck: false, nativeWindowOpen: true, webviewTag: true, diff --git a/test/unit/electron/index.js b/test/unit/electron/index.js index 7d85f302c7d..99bb64e92a4 100644 --- a/test/unit/electron/index.js +++ b/test/unit/electron/index.js @@ -168,7 +168,6 @@ app.on('ready', () => { nodeIntegration: true, contextIsolation: false, enableWebSQL: false, - enableRemoteModule: false, spellcheck: false, nativeWindowOpen: true, webviewTag: true