New media permission, show dialog when not enabled for voice msg
UI now in separate renderer: - the permissions popup - settings dialog - debug log dialog - about window Couple bug fixes: - About Window: Fix 'escape' to close window - Remove outdated dist/copy tasks from Gruntfile Eslintified settings_view.js
This commit is contained in:
parent
9d9a797bda
commit
ad4387803b
33 changed files with 1192 additions and 383 deletions
|
@ -4,9 +4,11 @@
|
|||
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
|
||||
|
||||
// Off by default, can be enabled by user
|
||||
media: false, // required for access to microphone, used for voice notes
|
||||
|
||||
// Not allowed
|
||||
geolocation: false,
|
||||
midiSysex: false,
|
||||
|
@ -14,18 +16,32 @@ const PERMISSIONS = {
|
|||
pointerLock: false,
|
||||
};
|
||||
|
||||
function _permissionHandler(webContents, permission, callback) {
|
||||
if (PERMISSIONS[permission]) {
|
||||
console.log(`Approving request for permission '${permission}'`);
|
||||
return callback(true);
|
||||
}
|
||||
function _createPermissionHandler(userConfig) {
|
||||
return (webContents, permission, callback) => {
|
||||
// We default 'media' permission to false, but the user can override that
|
||||
if (permission === 'media' && userConfig.get('mediaPermissions')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
console.log(`Denying request for permission '${permission}'`);
|
||||
return callback(false);
|
||||
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);
|
||||
function installPermissionsHandler({ session, userConfig }) {
|
||||
// Setting the permission request handler to null first forces any permissions to be
|
||||
// requested again. Without this, revoked permissions might still be available if
|
||||
// they've already been used successfully.
|
||||
session.defaultSession.setPermissionRequestHandler(null);
|
||||
|
||||
session.defaultSession.setPermissionRequestHandler(
|
||||
_createPermissionHandler(userConfig)
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue