diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-08-02 23:41:29 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-08-02 23:41:29 +0800 |
commit | 25cffd21f8defdf5a1bf139bdc2e3b1cfd08c220 (patch) | |
tree | 8e8f6225578722fb825ec0d98b2ff73b94f543d9 /app/scripts/background.js | |
parent | ece9200c72cd0b53ee237263933b2b9a24ae5802 (diff) | |
parent | d15e402ed87bf7533250c49a7972a7b1a12c99c2 (diff) | |
download | tangerine-wallet-browser-25cffd21f8defdf5a1bf139bdc2e3b1cfd08c220.tar tangerine-wallet-browser-25cffd21f8defdf5a1bf139bdc2e3b1cfd08c220.tar.gz tangerine-wallet-browser-25cffd21f8defdf5a1bf139bdc2e3b1cfd08c220.tar.bz2 tangerine-wallet-browser-25cffd21f8defdf5a1bf139bdc2e3b1cfd08c220.tar.lz tangerine-wallet-browser-25cffd21f8defdf5a1bf139bdc2e3b1cfd08c220.tar.xz tangerine-wallet-browser-25cffd21f8defdf5a1bf139bdc2e3b1cfd08c220.tar.zst tangerine-wallet-browser-25cffd21f8defdf5a1bf139bdc2e3b1cfd08c220.zip |
Merge branch 'master' into transactionControllerRefractor
Diffstat (limited to 'app/scripts/background.js')
-rw-r--r-- | app/scripts/background.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js index e8987394f..bc0fbdc37 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -11,6 +11,7 @@ const NotificationManager = require('./lib/notification-manager.js') const MetamaskController = require('./metamask-controller') const extension = require('extensionizer') const firstTimeState = require('./first-time-state') +const isPhish = require('./lib/is-phish') const STORAGE_KEY = 'metamask-config' const METAMASK_DEBUG = 'GULP_METAMASK_DEBUG' @@ -90,6 +91,10 @@ function setupController (initState) { extension.runtime.onConnect.addListener(connectRemote) function connectRemote (remotePort) { + if (remotePort.name === 'blacklister') { + return checkBlacklist(remotePort) + } + var isMetaMaskInternalProcess = remotePort.name === 'popup' || remotePort.name === 'notification' var portStream = new PortStream(remotePort) if (isMetaMaskInternalProcess) { @@ -135,6 +140,27 @@ function setupController (initState) { return Promise.resolve() } +// Listen for new pages and return if blacklisted: +function checkBlacklist (port) { + const handler = handleNewPageLoad.bind(null, port) + port.onMessage.addListener(handler) + setTimeout(() => { + port.onMessage.removeListener(handler) + }, 30000) +} + +function handleNewPageLoad (port, message) { + const { pageLoaded } = message + if (!pageLoaded || !global.metamaskController) return + + const state = global.metamaskController.getState() + const updatedBlacklist = state.blacklist + + if (isPhish({ updatedBlacklist, hostname: pageLoaded })) { + port.postMessage({ 'blacklist': pageLoaded }) + } +} + // // Etc... // |