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