diff options
author | kumavis <kumavis@users.noreply.github.com> | 2018-05-22 04:41:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-22 04:41:09 +0800 |
commit | e447438504d791f60e389c328970da7db2dbf4dc (patch) | |
tree | 001b14afe8f6b59c27dbc96eca4b6d0614a78fe3 /app/scripts/background.js | |
parent | 3180b69b974f8ffc0d6546a647725d1bf8539483 (diff) | |
parent | ad7d38c0dc206074379c813b307ed9350c7efeb0 (diff) | |
download | tangerine-wallet-browser-e447438504d791f60e389c328970da7db2dbf4dc.tar tangerine-wallet-browser-e447438504d791f60e389c328970da7db2dbf4dc.tar.gz tangerine-wallet-browser-e447438504d791f60e389c328970da7db2dbf4dc.tar.bz2 tangerine-wallet-browser-e447438504d791f60e389c328970da7db2dbf4dc.tar.lz tangerine-wallet-browser-e447438504d791f60e389c328970da7db2dbf4dc.tar.xz tangerine-wallet-browser-e447438504d791f60e389c328970da7db2dbf4dc.tar.zst tangerine-wallet-browser-e447438504d791f60e389c328970da7db2dbf4dc.zip |
Merge pull request #3997 from jakubsta/master
Allow other extensions to connect
Diffstat (limited to 'app/scripts/background.js')
-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 69d549c85..37e2b68fc 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -309,6 +309,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, @@ -335,9 +336,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') @@ -370,12 +371,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 // |