2016-06-08 14:31:27 +00:00
|
|
|
const {app, session} = require('electron')
|
|
|
|
const {registerStandardSchemes} = process.atomBinding('protocol')
|
2016-01-12 02:40:23 +00:00
|
|
|
|
2016-05-08 11:14:14 +00:00
|
|
|
exports.registerStandardSchemes = function (schemes) {
|
|
|
|
if (app.isReady()) {
|
2016-05-09 00:49:28 +00:00
|
|
|
console.warn('protocol.registerStandardSchemes should be called before app is ready')
|
|
|
|
return
|
2016-05-08 11:14:14 +00:00
|
|
|
}
|
|
|
|
registerStandardSchemes(schemes)
|
2016-03-24 20:15:04 +00:00
|
|
|
}
|
2016-01-12 02:40:23 +00:00
|
|
|
|
2016-06-16 23:23:08 +00:00
|
|
|
const setupProtocol = function () {
|
2016-06-08 14:31:27 +00:00
|
|
|
let protocol = session.defaultSession.protocol
|
2016-05-08 11:14:14 +00:00
|
|
|
for (let method in protocol) {
|
|
|
|
exports[method] = protocol[method].bind(protocol)
|
|
|
|
}
|
2016-06-16 23:23:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (app.isReady()) {
|
|
|
|
setupProtocol()
|
|
|
|
} else {
|
|
|
|
app.once('ready', setupProtocol)
|
|
|
|
}
|