diff options
author | Jakub Stasiak <kubafr2@gmail.com> | 2018-04-12 00:32:27 +0800 |
---|---|---|
committer | Jakub Stasiak <kubafr2@gmail.com> | 2018-04-18 03:49:40 +0800 |
commit | ad7d38c0dc206074379c813b307ed9350c7efeb0 (patch) | |
tree | ca75631e551a7d2d608681474cb15e82267f52d2 /app/scripts | |
parent | 7b70804aa0d74120098a4bcb2c375d29080e8368 (diff) | |
download | tangerine-wallet-browser-ad7d38c0dc206074379c813b307ed9350c7efeb0.tar tangerine-wallet-browser-ad7d38c0dc206074379c813b307ed9350c7efeb0.tar.gz tangerine-wallet-browser-ad7d38c0dc206074379c813b307ed9350c7efeb0.tar.bz2 tangerine-wallet-browser-ad7d38c0dc206074379c813b307ed9350c7efeb0.tar.lz tangerine-wallet-browser-ad7d38c0dc206074379c813b307ed9350c7efeb0.tar.xz tangerine-wallet-browser-ad7d38c0dc206074379c813b307ed9350c7efeb0.tar.zst tangerine-wallet-browser-ad7d38c0dc206074379c813b307ed9350c7efeb0.zip |
Update: allow other extension to connect
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/background.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js index 6550e8944..6296eaa21 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -197,6 +197,7 @@ function setupController (initState, initLangCode) { // connect to other contexts // extension.runtime.onConnect.addListener(connectRemote) + extension.runtime.onConnectExternal.addListener(connectExternal) const metamaskInternalProcessHash = { [ENVIRONMENT_TYPE_POPUP]: true, @@ -211,9 +212,9 @@ function setupController (initState, initLangCode) { function connectRemote (remotePort) { const processName = remotePort.name const isMetaMaskInternalProcess = metamaskInternalProcessHash[processName] - const portStream = new PortStream(remotePort) if (isMetaMaskInternalProcess) { + const portStream = new PortStream(remotePort) // communication with popup controller.isClientOpen = true controller.setupTrustedCommunication(portStream, 'MetaMask') @@ -246,12 +247,17 @@ function setupController (initState, initLangCode) { }) } } else { - // communication with page - const originDomain = urlUtil.parse(remotePort.sender.url).hostname - controller.setupUntrustedCommunication(portStream, originDomain) + connectExternal(remotePort) } } + // communication with page or other extension + function connectExternal(remotePort) { + const originDomain = urlUtil.parse(remotePort.sender.url).hostname + const portStream = new PortStream(remotePort) + controller.setupUntrustedCommunication(portStream, originDomain) + } + // // User Interface setup // |