electron/lib/browser/api/protocol.js
2016-06-16 16:23:08 -07:00

23 lines
595 B
JavaScript

const {app, session} = require('electron')
const {registerStandardSchemes} = process.atomBinding('protocol')
exports.registerStandardSchemes = function (schemes) {
if (app.isReady()) {
console.warn('protocol.registerStandardSchemes should be called before app is ready')
return
}
registerStandardSchemes(schemes)
}
const setupProtocol = function () {
let protocol = session.defaultSession.protocol
for (let method in protocol) {
exports[method] = protocol[method].bind(protocol)
}
}
if (app.isReady()) {
setupProtocol()
} else {
app.once('ready', setupProtocol)
}