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

View file

@ -736,22 +736,4 @@ Emitted when DevTools is closed.
Emitted when DevTools is focused / opened.
### Event: 'permission-request'
Returns:
* `permission` String - The type of permission being requested. Enum of 'media', 'notifications', 'midiSysex', 'geolocation'.
* `allow` Function - Allows the permission.
* `deny` Function - Deny the permission. This is the default behaviour if `allow` is not called.
Emitted when guest page requires special permission.
```javascript
// This will deny guest page access to the webkitGetUserMedia API.
webview.addEventListener('permission-request', function(e) {
if (e.permission === 'media')
e.deny();
});
```
[blink-feature-string]: https://code.google.com/p/chromium/codesearch#chromium/src/out/Debug/gen/blink/platform/RuntimeEnabledFeatures.cpp&sq=package:chromium&type=cs&l=527