2016-03-24 13:15:04 -07:00
const app = require ( 'electron' ) . app
2016-01-11 18:40:23 -08:00
if ( ! app . isReady ( ) ) {
2016-03-24 13:15:04 -07:00
throw new Error ( 'Can not initialize protocol module before app is ready' )
2016-01-11 18:40:23 -08:00
}
2016-03-24 13:15:04 -07:00
const protocol = process . atomBinding ( 'protocol' ) . protocol
2016-01-11 18:40:23 -08:00
2016-01-14 10:35:29 -08:00
// Warn about removed APIs.
2016-03-24 13:15:04 -07:00
var logAndThrow = function ( callback , message ) {
console . error ( message )
2016-01-11 18:40:23 -08:00
if ( callback ) {
2016-03-24 13:15:04 -07:00
return callback ( new Error ( message ) )
2016-01-11 18:40:23 -08:00
} else {
2016-03-24 13:15:04 -07:00
throw new Error ( message )
2016-01-11 18:40:23 -08:00
}
2016-03-24 13:15:04 -07:00
}
2016-01-11 18:40:23 -08:00
2016-03-24 13:15:04 -07:00
protocol . registerProtocol = function ( scheme , handler , callback ) {
return logAndThrow ( callback , 'registerProtocol API has been replaced by the register[File/Http/Buffer/String]Protocol API family, please switch to the new APIs.' )
}
2016-01-11 18:40:23 -08:00
2016-03-24 13:15:04 -07:00
protocol . isHandledProtocol = function ( scheme , callback ) {
return logAndThrow ( callback , 'isHandledProtocol API has been replaced by isProtocolHandled.' )
}
2016-01-11 18:40:23 -08:00
2016-03-24 13:15:04 -07:00
protocol . interceptProtocol = function ( scheme , handler , callback ) {
return logAndThrow ( callback , 'interceptProtocol API has been replaced by the intercept[File/Http/Buffer/String]Protocol API family, please switch to the new APIs.' )
}
2016-01-11 18:40:23 -08:00
2016-03-24 13:15:04 -07:00
module . exports = protocol