23 lines
595 B
JavaScript
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)
|
|
}
|