mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Send message to inpage when extension revives (#15958)
This commit is contained in:
parent
24a3156a2b
commit
d9dda82678
@ -230,6 +230,8 @@ const setupExtensionStreams = () => {
|
|||||||
// connect "phishing" channel to warning system
|
// connect "phishing" channel to warning system
|
||||||
extensionPhishingStream = extensionMux.createStream('phishing');
|
extensionPhishingStream = extensionMux.createStream('phishing');
|
||||||
extensionPhishingStream.once('data', redirectToPhishingWarning);
|
extensionPhishingStream.once('data', redirectToPhishingWarning);
|
||||||
|
|
||||||
|
notifyInpageOfExtensionStreamConnect();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Destroys all of the extension streams */
|
/** Destroys all of the extension streams */
|
||||||
@ -387,6 +389,26 @@ function logStreamDisconnectWarning(remoteLabel, error) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The function send message to inpage to notify it of extension stream connection
|
||||||
|
*/
|
||||||
|
function notifyInpageOfExtensionStreamConnect() {
|
||||||
|
window.postMessage(
|
||||||
|
{
|
||||||
|
target: INPAGE, // the post-message-stream "target"
|
||||||
|
data: {
|
||||||
|
// this object gets passed to obj-multiplex
|
||||||
|
name: PROVIDER, // the obj-multiplex channel name
|
||||||
|
data: {
|
||||||
|
jsonrpc: '2.0',
|
||||||
|
method: 'METAMASK_EXTENSION_STREAM_CONNECT',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
window.location.origin,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function must ONLY be called in pump destruction/close callbacks.
|
* This function must ONLY be called in pump destruction/close callbacks.
|
||||||
* Notifies the inpage context that streams have failed, via window.postMessage.
|
* Notifies the inpage context that streams have failed, via window.postMessage.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user