Merge pull request #5904 from deepak1556/extension_partition_patch

browser: set up extension protocol handler for each browser context
This commit is contained in:
Cheng Zhao 2016-06-09 08:04:58 +00:00 committed by GitHub
commit 2ec5406ca6
23 changed files with 202 additions and 66 deletions

View file

@ -547,3 +547,22 @@ The `listener` will be called with `listener(details)` when an error occurs.
* `timestamp` Double
* `fromCache` Boolean
* `error` String - The error description.
#### `ses.protocol`
Returns an instance of [protocol](protocol.md) module for this session.
```javascript
const {app, session} = require('electron')
const path = require('path')
app.on('ready', function () {
const protocol = session.fromPartition(partitionName).protocol
protocol.registerFileProtocol('atom', function (request, callback) {
var url = request.url.substr(7)
callback({path: path.normalize(__dirname + '/' + url)})
}, function (error) {
if (error)
console.error('Failed to register protocol')
})
})