2016-01-14 21:18:52 +00:00
const app = require ( 'electron' ) . app ;
2016-01-12 02:40:23 +00:00
if ( ! app . isReady ( ) ) {
throw new Error ( 'Can not initialize protocol module before app is ready' ) ;
}
2016-02-19 14:09:01 +00:00
const session = require ( 'electron' ) . session ;
// Returns the protocol property for default session.
const protocol = session . defaultSession . protocol ;
2016-01-12 02:40:23 +00:00
2016-01-14 18:35:29 +00:00
// Warn about removed APIs.
2016-01-14 21:18:52 +00:00
var logAndThrow = function ( callback , message ) {
2016-01-12 02:40:23 +00:00
console . error ( message ) ;
if ( callback ) {
return callback ( new Error ( message ) ) ;
} else {
throw new Error ( message ) ;
}
} ;
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.' ) ;
} ;
protocol . isHandledProtocol = function ( scheme , callback ) {
return logAndThrow ( callback , 'isHandledProtocol API has been replaced by isProtocolHandled.' ) ;
} ;
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.' ) ;
} ;
module . exports = protocol ;