Skip to content

Commit 07068ba

Browse files
author
Benjamin Pasero
committed
electron - block permissions requests via setPermissionRequestHandler
1 parent 817e166 commit 07068ba

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

  • src/vs/code/electron-main

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

Lines changed: 8 additions & 2 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, BrowserWindow, dialog } from 'electron';
6+
import { app, ipcMain as ipc, systemPreferences, shell, Event, contentTracing, protocol, powerMonitor, IpcMainEvent, BrowserWindow, dialog, session } from 'electron';
77
import { IProcessEnvironment, isWindows, isMacintosh } from 'vs/base/common/platform';
88
import { WindowsMainService } from 'vs/platform/windows/electron-main/windowsMainService';
99
import { IWindowOpenable } from 'vs/platform/windows/common/windows';
@@ -129,7 +129,7 @@ export class CodeApplication extends Disposable {
129129
}
130130
});
131131

132-
// Security related measures (https://electronjs.org/docs/tutorial/security)
132+
//#region Security related measures (https://electronjs.org/docs/tutorial/security)
133133
//
134134
// !!! DO NOT CHANGE without consulting the documentation !!!
135135
//
@@ -212,8 +212,14 @@ export class CodeApplication extends Disposable {
212212

213213
shell.openExternal(url);
214214
});
215+
216+
session.defaultSession.setPermissionRequestHandler((webContents, permission /* 'media' | 'geolocation' | 'notifications' | 'midiSysex' | 'pointerLock' | 'fullscreen' | 'openExternal' */, callback) => {
217+
return callback(false);
218+
});
215219
});
216220

221+
//#endregion
222+
217223
let macOpenFileURIs: IWindowOpenable[] = [];
218224
let runningTimeout: NodeJS.Timeout | null = null;
219225
app.on('open-file', (event: Event, path: string) => {

0 commit comments

Comments
 (0)