aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/background.js
diff options
context:
space:
mode:
authorPhyrexTsai <x01ep23i@hotmail.com>2018-06-01 15:41:18 +0800
committerGitHub <noreply@github.com>2018-06-01 15:41:18 +0800
commitf90d07019081695ef3d697c5af0ae2bee3bb1637 (patch)
treef7c68bb9bcaaddc035c6595bb78fcba98d6cfd1c /app/scripts/background.js
parentcc5bdadbf1f12f3f8d7f24f9bcf7ea81fe93f012 (diff)
parentcc73d869fed79c63261821fb7ad8f1e5180ffca2 (diff)
downloadtangerine-wallet-browser-f90d07019081695ef3d697c5af0ae2bee3bb1637.tar
tangerine-wallet-browser-f90d07019081695ef3d697c5af0ae2bee3bb1637.tar.gz
tangerine-wallet-browser-f90d07019081695ef3d697c5af0ae2bee3bb1637.tar.bz2
tangerine-wallet-browser-f90d07019081695ef3d697c5af0ae2bee3bb1637.tar.lz
tangerine-wallet-browser-f90d07019081695ef3d697c5af0ae2bee3bb1637.tar.xz
tangerine-wallet-browser-f90d07019081695ef3d697c5af0ae2bee3bb1637.tar.zst
tangerine-wallet-browser-f90d07019081695ef3d697c5af0ae2bee3bb1637.zip
Merge branch 'develop' into portal-metamask
Diffstat (limited to 'app/scripts/background.js')
-rw-r--r--app/scripts/background.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 672a2dcac..610409975 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -315,6 +315,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,
@@ -341,9 +342,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')
@@ -376,12 +377,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
//