electron/lib/browser/api/protocol.js

28 lines
749 B
JavaScript
Raw Normal View History

const {app, session} = require('electron')
2016-01-12 02:40:23 +00:00
// Global protocol APIs.
module.exports = process.atomBinding('protocol')
2016-01-12 02:40:23 +00:00
// Fallback protocol APIs of default session.
Object.setPrototypeOf(module.exports, new Proxy({}, {
get (target, property) {
if (!app.isReady()) return
const protocol = session.defaultSession.protocol
2016-08-02 08:12:17 +00:00
if (!protocol.__proto__.hasOwnProperty(property)) return
// Returning a native function directly would throw error.
return (...args) => protocol[property](...args)
},
ownKeys () {
if (!app.isReady()) return []
2016-08-02 08:12:17 +00:00
return Object.getOwnPropertyNames(session.defaultSession.protocol.__proto__)
},
getOwnPropertyDescriptor (target) {
return { configurable: true, enumerable: true }
}
}))