Merge pull request #4223 from deepak1556/notification_disable_patch

session: add setPermissionRequestHandler api
This commit is contained in:
Cheng Zhao 2016-02-01 20:51:22 +08:00
commit 69f93a7528
21 changed files with 666 additions and 2 deletions

View file

@ -290,6 +290,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', 'pointerLock', 'fullscreen'.
* `callback` Function - Allow or deny the permission.
Sets the handler which can be used to respond to permission requests for the `session`.
Calling `callback(true)` will allow the permission and `callback(false)` will reject it.
```javascript
session.fromPartition(partition).setPermissionRequestHandler(function(webContents, permission, callback) {
if (webContents.getURL() === host) {
if (permission == "notifications") {
callback(false); // denied.
return;
}
}
callback(true);
});
```
#### `ses.webRequest`
The `webRequest` API set allows to intercept and modify contents of a request at