2018-08-05 08:43:02 +02:00
|
|
|
/*
|
|
|
|
Passing messages from background script to popup
|
|
|
|
*/
|
|
|
|
|
|
|
|
let port = chrome.runtime.connect({ name: 'trezor-connect' });
|
|
|
|
port.onMessage.addListener(message => {
|
|
|
|
window.postMessage(message, window.location.origin);
|
|
|
|
});
|
2018-08-22 19:39:43 +02:00
|
|
|
port.onDisconnect.addListener(d => {
|
|
|
|
port = null;
|
|
|
|
});
|
|
|
|
|
2018-08-05 08:43:02 +02:00
|
|
|
/*
|
|
|
|
Passing messages from popup to background script
|
|
|
|
*/
|
|
|
|
|
|
|
|
window.addEventListener('message', event => {
|
|
|
|
if (port && event.source === window && event.data) {
|
2021-01-21 18:12:54 +01:00
|
|
|
port.postMessage({ data: event.data });
|
2018-08-05 08:43:02 +02:00
|
|
|
}
|
2018-08-05 09:17:51 +02:00
|
|
|
});
|