aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/popup.js
blob: e6f149f968d4e35b26e3de75045c61553a07a08d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const injectCss = require('inject-css')
const MetaMaskUiCss = require('../../ui/css')
const startPopup = require('./popup-core')
const PortStream = require('./lib/port-stream.js')
const isPopupOrNotification = require('./lib/is-popup-or-notification')
const extension = require('./lib/extension')
const notification = require('./lib/notifications')

var css = MetaMaskUiCss()
injectCss(css)

var name = isPopupOrNotification()
closePopupIfOpen(name)
window.METAMASK_UI_TYPE = name

var pluginPort = extension.runtime.connect({ name })
var portStream = new PortStream(pluginPort)

startPopup(portStream)

function closePopupIfOpen(name) {
  if (name !== 'notification') {
    notification.closePopup()
  }
}