Deny all permissions we don't actually need

This commit is contained in:
Scott Nonnenberg 2018-05-24 12:13:16 -07:00
parent a58e94e17e
commit beb65b14c0
2 changed files with 40 additions and 8 deletions

33
app/permissions.js Normal file
View file

@ -0,0 +1,33 @@
// The list of permissions is here:
// https://electronjs.org/docs/api/session#sessetpermissionrequesthandlerhandler
const PERMISSIONS = {
// Allowed
fullscreen: true, // required to show videos in full-screen
media: true, // required for access to microphone, used for voice notes
notifications: true, // required to show OS notifications for new messages
// Not allowed
geolocation: false,
midiSysex: false,
openExternal: false, // we don't need this; we open links via 'will-navigate' event
pointerLock: false,
};
function _permissionHandler(webContents, permission, callback) {
if (PERMISSIONS[permission]) {
console.log(`Approving request for permission '${permission}'`);
return callback(true);
}
console.log(`Denying request for permission '${permission}'`);
return callback(false);
}
function installPermissionsHandler({ session }) {
session.defaultSession.setPermissionRequestHandler(_permissionHandler);
}
module.exports = {
installPermissionsHandler,
};