mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
Merge pull request #3997 from jakubsta/master
Allow other extensions to connect
This commit is contained in:
commit
e447438504
@ -67,6 +67,7 @@
|
|||||||
"externally_connectable": {
|
"externally_connectable": {
|
||||||
"matches": [
|
"matches": [
|
||||||
"https://metamask.io/*"
|
"https://metamask.io/*"
|
||||||
]
|
],
|
||||||
|
"ids": ["*"]
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -309,6 +309,7 @@ function setupController (initState, initLangCode) {
|
|||||||
// connect to other contexts
|
// connect to other contexts
|
||||||
//
|
//
|
||||||
extension.runtime.onConnect.addListener(connectRemote)
|
extension.runtime.onConnect.addListener(connectRemote)
|
||||||
|
extension.runtime.onConnectExternal.addListener(connectExternal)
|
||||||
|
|
||||||
const metamaskInternalProcessHash = {
|
const metamaskInternalProcessHash = {
|
||||||
[ENVIRONMENT_TYPE_POPUP]: true,
|
[ENVIRONMENT_TYPE_POPUP]: true,
|
||||||
@ -335,9 +336,9 @@ function setupController (initState, initLangCode) {
|
|||||||
function connectRemote (remotePort) {
|
function connectRemote (remotePort) {
|
||||||
const processName = remotePort.name
|
const processName = remotePort.name
|
||||||
const isMetaMaskInternalProcess = metamaskInternalProcessHash[processName]
|
const isMetaMaskInternalProcess = metamaskInternalProcessHash[processName]
|
||||||
const portStream = new PortStream(remotePort)
|
|
||||||
|
|
||||||
if (isMetaMaskInternalProcess) {
|
if (isMetaMaskInternalProcess) {
|
||||||
|
const portStream = new PortStream(remotePort)
|
||||||
// communication with popup
|
// communication with popup
|
||||||
controller.isClientOpen = true
|
controller.isClientOpen = true
|
||||||
controller.setupTrustedCommunication(portStream, 'MetaMask')
|
controller.setupTrustedCommunication(portStream, 'MetaMask')
|
||||||
@ -370,12 +371,17 @@ function setupController (initState, initLangCode) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// communication with page
|
connectExternal(remotePort)
|
||||||
const originDomain = urlUtil.parse(remotePort.sender.url).hostname
|
|
||||||
controller.setupUntrustedCommunication(portStream, originDomain)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
// User Interface setup
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user