diff --git a/lib/browser/api/protocol.js b/lib/browser/api/protocol.js index f7bf48a250..d1c26991d0 100644 --- a/lib/browser/api/protocol.js +++ b/lib/browser/api/protocol.js @@ -1,17 +1,19 @@ -const {app, session} = require('electron') -const {registerStandardSchemes} = process.atomBinding('protocol') +const {session} = require('electron') -exports.registerStandardSchemes = registerStandardSchemes +// Global protocol APIs. +module.exports = process.atomBinding('protocol') -const setupProtocol = function () { - let protocol = session.defaultSession.protocol - for (let method in protocol) { - exports[method] = protocol[method].bind(protocol) +// Fallback protocol APIs of default session. +Object.setPrototypeOf(module.exports, new Proxy({}, { + get (target, property) { + return (...args) => session.defaultSession.protocol[property](...args) + }, + + ownKeys () { + return Object.getOwnPropertyNames(session.defaultSession.protocol) + }, + + getOwnPropertyDescriptor (target) { + return { configurable: true, enumerable: true } } -} - -if (app.isReady()) { - setupProtocol() -} else { - app.once('ready', setupProtocol) -} +}))