aboutsummaryrefslogblamecommitdiffstats
path: root/app/scripts/popup.js
blob: 6606c958478d133c0ff5c27dcdb40b0b83e16c4e (plain) (tree)
1
2
3
4
5
6
7
8
9
                                       
                                             
                                          
                                                  
                                                                       



                                                                 
 


                         


                                  
 

                                                    
 
                      
 
                                  
                                
                                    

   
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('extensionizer')
const NotificationManager = require('./lib/notification-manager')

const notificationManager = new NotificationManager()

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') {
    notificationManager.closePopup()
  }
}