aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/manifest.json3
-rw-r--r--app/scripts/background.js14
2 files changed, 12 insertions, 5 deletions
diff --git a/app/manifest.json b/app/manifest.json
index 8a14323f0..141026d10 100644
--- a/app/manifest.json
+++ b/app/manifest.json
@@ -67,6 +67,7 @@
"externally_connectable": {
"matches": [
"https://metamask.io/*"
- ]
+ ],
+ "ids": ["*"]
}
} \ No newline at end of file
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
//