From cb5e6485026f560ab27c3fa960aef86764f119c6 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Wed, 8 Jun 2016 21:40:39 +0530 Subject: [PATCH] register extension handler for every session created --- lib/browser/api/session.js | 4 +++- lib/browser/chrome-extension.js | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/browser/api/session.js b/lib/browser/api/session.js index dc1c529878fb..4004713b8843 100644 --- a/lib/browser/api/session.js +++ b/lib/browser/api/session.js @@ -10,7 +10,9 @@ const fromPartition = function (partition, persist) { throw new Error('session module can only be used when app is ready') } - return bindings.fromPartition(partition, persist) + let session = bindings.fromPartition(partition, persist) + process.emit('session-created', session) + return session } // Returns the Session from |partition| string. diff --git a/lib/browser/chrome-extension.js b/lib/browser/chrome-extension.js index 5b6bd5fbe1c8..a26ca626dc81 100644 --- a/lib/browser/chrome-extension.js +++ b/lib/browser/chrome-extension.js @@ -280,10 +280,12 @@ app.once('ready', function () { } }) } - protocol.registerBufferProtocol('chrome-extension', chromeExtensionHandler, function (error) { - if (error) { - console.error(`Unable to register chrome-extension protocol: ${error}`) - } + process.on('session-created', function (session) { + session.protocol.registerBufferProtocol('chrome-extension', chromeExtensionHandler, function (error) { + if (error) { + console.error(`Unable to register chrome-extension protocol: ${error}`) + } + }) }) // Load persisted extensions.