@ -19,44 +19,38 @@
Home : https : //github.com/gorhill/uBlock
Home : https : //github.com/gorhill/uBlock
* /
* /
/* global Services, APP_STARTUP, APP_SHUTDOWN */
/* global APP_SHUTDOWN */
/* exported startup, shutdown, install, uninstall */
/* exported startup, shutdown, install, uninstall */
'use strict' ;
'use strict' ;
/******************************************************************************/
/******************************************************************************/
var bgProcess ;
let bgProcess ;
Components . utils [ 'import' ] ( 'resource://gre/modules/Services.jsm' ) ;
/******************************************************************************/
/******************************************************************************/
function startup ( data , reason ) {
function startup ( data ) {
bgProcess = function ( ev ) {
let { AddonManager } = Components . utils [ 'import' ] (
if ( ev ) {
'resource://gre/modules/AddonManager.jsm' ,
this . removeEventListener ( ev . type , bgProcess ) ;
null
}
) ;
bgProcess = Services . appShell . hiddenDOMWindow . document ;
AddonManager . getAddonByID ( data . id , addon => {
bgProcess = bgProcess . documentElement . appendChild (
let hDoc = Components . classes [ '@mozilla.org/appshell/appShellService;1' ]
bgProcess . createElementNS ( 'http://www.w3.org/1999/xhtml' , 'iframe' )
. getService ( Components . interfaces . nsIAppShellService )
. hiddenDOMWindow . document ;
bgProcess = hDoc . documentElement . appendChild (
hDoc . createElementNS ( 'http://www.w3.org/1999/xhtml' , 'iframe' )
) ;
) ;
bgProcess . setAttribute ( 'src' , 'chrome://ublock/content/background.html' ) ;
} ;
let bgURI = 'chrome://ublock/content/background.html' ;
if ( reason === APP _STARTUP ) {
// send addon data synchronously to the background script
Services . ww . registerNotification ( {
bgProcess . src = bgURI + '#' + [ addon . name , addon . version ] ;
observe : function ( win ) {
Services . ww . unregisterNotification ( this ) ;
win . addEventListener ( 'DOMContentLoaded' , bgProcess ) ;
}
} ) ;
} ) ;
}
}
else {
bgProcess ( ) ;
}
}
/******************************************************************************/
/******************************************************************************/
@ -70,7 +64,8 @@ function shutdown(data, reason) {
function install ( ) {
function install ( ) {
// https://bugzil.la/719376
// https://bugzil.la/719376
Services . strings . flushBundles ( ) ;
Components . classes [ '@mozilla.org/intl/stringbundle;1' ]
. getService ( Components . interfaces . nsIStringBundleService ) . flushBundles ( ) ;
}
}
/******************************************************************************/
/******************************************************************************/