expose handler from session and remove permission-request event

This commit is contained in:
Robo 2016-02-01 03:05:34 +05:30
parent 04c3e083fb
commit db26dcaf4c
14 changed files with 134 additions and 134 deletions

View file

@ -289,6 +289,29 @@ myWindow.webContents.session.setCertificateVerifyProc(function(hostname, cert, c
});
```
#### `ses.setPermissionRequestHandler(handler)`
* `handler` Function
* `webContents` Object - [WebContents](web-contents.md) requesting the permission.
* `permission` String - Enum of 'media', 'geolocation', 'notifications', 'midiSysex'.
* `callback` Function - Allow or deny the permission.
Sets the handler which can be used to respond to permission requests for the `session`.
Calling `callback('granted')` will allow the permission and `callback('denied')` will reject it.
```javascript
session.fromPartition(partition).setPermissionRequestHandler(function(webContents, permission, callback) {
if (webContents.getURL() === host) {
if (permission == "notifications") {
callback(); // denied.
return;
}
}
callback('granted');
});
```
#### `ses.webRequest`
The `webRequest` API set allows to intercept and modify contents of a request at