mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Improvements in connectRemote function in background.js (#13762)
This commit is contained in:
parent
3747ace06b
commit
9d26bd762f
@ -16,6 +16,7 @@ import {
|
|||||||
ENVIRONMENT_TYPE_POPUP,
|
ENVIRONMENT_TYPE_POPUP,
|
||||||
ENVIRONMENT_TYPE_NOTIFICATION,
|
ENVIRONMENT_TYPE_NOTIFICATION,
|
||||||
ENVIRONMENT_TYPE_FULLSCREEN,
|
ENVIRONMENT_TYPE_FULLSCREEN,
|
||||||
|
PLATFORM_FIREFOX,
|
||||||
} from '../../shared/constants/app';
|
} from '../../shared/constants/app';
|
||||||
import { SECOND } from '../../shared/constants/time';
|
import { SECOND } from '../../shared/constants/time';
|
||||||
import {
|
import {
|
||||||
@ -38,6 +39,7 @@ import rawFirstTimeState from './first-time-state';
|
|||||||
import getFirstPreferredLangCode from './lib/get-first-preferred-lang-code';
|
import getFirstPreferredLangCode from './lib/get-first-preferred-lang-code';
|
||||||
import getObjStructure from './lib/getObjStructure';
|
import getObjStructure from './lib/getObjStructure';
|
||||||
import setupEnsIpfsResolver from './lib/ens-ipfs/setup';
|
import setupEnsIpfsResolver from './lib/ens-ipfs/setup';
|
||||||
|
import { getPlatform } from './lib/util';
|
||||||
/* eslint-enable import/first */
|
/* eslint-enable import/first */
|
||||||
|
|
||||||
const { sentry } = global;
|
const { sentry } = global;
|
||||||
@ -345,12 +347,22 @@ function setupController(initState, initLangCode) {
|
|||||||
*/
|
*/
|
||||||
function connectRemote(remotePort) {
|
function connectRemote(remotePort) {
|
||||||
const processName = remotePort.name;
|
const processName = remotePort.name;
|
||||||
const isMetaMaskInternalProcess = metamaskInternalProcessHash[processName];
|
|
||||||
|
|
||||||
if (metamaskBlockedPorts.includes(remotePort.name)) {
|
if (metamaskBlockedPorts.includes(remotePort.name)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let isMetaMaskInternalProcess = false;
|
||||||
|
const sourcePlatform = getPlatform();
|
||||||
|
|
||||||
|
if (sourcePlatform === PLATFORM_FIREFOX) {
|
||||||
|
isMetaMaskInternalProcess = metamaskInternalProcessHash[processName];
|
||||||
|
} else {
|
||||||
|
isMetaMaskInternalProcess =
|
||||||
|
remotePort.sender.origin ===
|
||||||
|
`chrome-extension://${extension.runtime.id}`;
|
||||||
|
}
|
||||||
|
|
||||||
if (isMetaMaskInternalProcess) {
|
if (isMetaMaskInternalProcess) {
|
||||||
const portStream = new PortStream(remotePort);
|
const portStream = new PortStream(remotePort);
|
||||||
// communication with popup
|
// communication with popup
|
||||||
|
Loading…
Reference in New Issue
Block a user