mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-27 01:11:13 -06:00
ELECTRON-491 - Change method to use getFocusedWindow instead of fromWebContents (#368)
This commit is contained in:
parent
c36b639296
commit
2362febc58
@ -496,32 +496,35 @@ function doCreateMainWindow(initialUrl, initialBounds) {
|
||||
* @param webContents Web contents of the window
|
||||
*/
|
||||
function handlePermissionRequests(webContents) {
|
||||
|
||||
|
||||
let session = webContents.session;
|
||||
|
||||
|
||||
getConfigField('permissions')
|
||||
.then((permissions) => {
|
||||
|
||||
|
||||
if (!permissions) {
|
||||
log.send(logLevels.ERROR, 'permissions configuration is invalid, so, everything will be true by default!');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
session.setPermissionRequestHandler((sessionWebContents, permission, callback) => {
|
||||
|
||||
|
||||
function handleSessionPermissions(userPermission, message, cb) {
|
||||
|
||||
|
||||
log.send(logLevels.INFO, 'permission is -> ' + userPermission);
|
||||
|
||||
|
||||
if (!userPermission) {
|
||||
let fullMessage = `Your administrator has disabled ${message}. Please contact your admin for help.`;
|
||||
electron.dialog.showMessageBox(BrowserWindow.fromWebContents(webContents), {type: 'error', title: 'Permission Denied!', message: fullMessage});
|
||||
const browserWindow = BrowserWindow.getFocusedWindow();
|
||||
if (browserWindow && !browserWindow.isDestroyed()) {
|
||||
electron.dialog.showMessageBox(browserWindow, {type: 'error', title: 'Permission Denied!', message: fullMessage});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return cb(userPermission);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
let PERMISSION_MEDIA = 'media';
|
||||
let PERMISSION_LOCATION = 'geolocation';
|
||||
let PERMISSION_NOTIFICATIONS = 'notifications';
|
||||
@ -529,40 +532,40 @@ function doCreateMainWindow(initialUrl, initialBounds) {
|
||||
let PERMISSION_POINTER_LOCK = 'pointerLock';
|
||||
let PERMISSION_FULL_SCREEN = 'fullscreen';
|
||||
let PERMISSION_OPEN_EXTERNAL = 'openExternal';
|
||||
|
||||
|
||||
switch (permission) {
|
||||
|
||||
|
||||
case PERMISSION_MEDIA:
|
||||
return handleSessionPermissions(permissions.media, 'sharing your camera, microphone, and speakers', callback);
|
||||
|
||||
|
||||
case PERMISSION_LOCATION:
|
||||
return handleSessionPermissions(permissions.geolocation, 'sharing your location', callback);
|
||||
|
||||
|
||||
case PERMISSION_NOTIFICATIONS:
|
||||
return handleSessionPermissions(permissions.notifications, 'notifications', callback);
|
||||
|
||||
|
||||
case PERMISSION_MIDI_SYSEX:
|
||||
return handleSessionPermissions(permissions.midiSysex, 'MIDI Sysex', callback);
|
||||
|
||||
|
||||
case PERMISSION_POINTER_LOCK:
|
||||
return handleSessionPermissions(permissions.pointerLock, 'Pointer Lock', callback);
|
||||
|
||||
|
||||
case PERMISSION_FULL_SCREEN:
|
||||
return handleSessionPermissions(permissions.fullscreen, 'Full Screen', callback);
|
||||
|
||||
|
||||
case PERMISSION_OPEN_EXTERNAL:
|
||||
return handleSessionPermissions(permissions.openExternal, 'Opening External App', callback);
|
||||
|
||||
|
||||
default:
|
||||
return callback(false);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
}).catch((error) => {
|
||||
log.send(logLevels.ERROR, 'unable to get permissions configuration, so, everything will be true by default! ' + error);
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user