webContents.session.setPermissionRequestHandler(function(webContents, permission, callback) {
console.log(`handlePermissionRequests for ${permission}`);
if (permission === 'notifications') {
+ if (!self.notificationPermissionMap)
+ self.notificationPermissionMap = new Map();
+ else if (self.notificationPermissionMap.has(webContents)) {
+ process.nextTick(callback, self.notificationPermissionMap.get(webContents));
+ return;
+ }
const id = ++self.pendingID;
console.log(`Raising a notification permission request with id: ${id}`);
- self.pendingCallbacks.set(id, callback);
+ self.pendingCallbacks.set(id, (result) => {
+ self.notificationPermissionMap.set(webContents, result);
+ callback(result);
+ });
wrt.handleNotificationPermissionRequest(id, webContents);
} else if (permission === 'media') {
const id = ++self.pendingID;