fcd3357fb8
In this way we can avoid initializing defaultSession when protocol module is used.
19 lines
512 B
JavaScript
19 lines
512 B
JavaScript
const {session} = require('electron')
|
|
|
|
// Global protocol APIs.
|
|
module.exports = process.atomBinding('protocol')
|
|
|
|
// Fallback protocol APIs of default session.
|
|
Object.setPrototypeOf(module.exports, new Proxy({}, {
|
|
get (target, property) {
|
|
return (...args) => session.defaultSession.protocol[property](...args)
|
|
},
|
|
|
|
ownKeys () {
|
|
return Object.getOwnPropertyNames(session.defaultSession.protocol)
|
|
},
|
|
|
|
getOwnPropertyDescriptor (target) {
|
|
return { configurable: true, enumerable: true }
|
|
}
|
|
}))
|