|
|
@ -28,31 +28,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
let bgProcess;
|
|
|
|
let bgProcess;
|
|
|
|
const hostName = 'ublock';
|
|
|
|
const hostName = 'ublock';
|
|
|
|
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
|
|
|
const restartListener = {
|
|
|
|
const restartObserver = {
|
|
|
|
get messageManager() {
|
|
|
|
get observer() {
|
|
|
|
return Components.classes['@mozilla.org/parentprocessmessagemanager;1']
|
|
|
|
return Cc["@mozilla.org/observer-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIMessageListenerManager);
|
|
|
|
.getService(Ci.nsIObserverService);
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
QueryInterface: (function() {
|
|
|
|
receiveMessage: function() {
|
|
|
|
let {XPCOMUtils} = Cu['import']('resource://gre/modules/XPCOMUtils.jsm', {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return XPCOMUtils.generateQI([
|
|
|
|
|
|
|
|
Ci.nsIObserver,
|
|
|
|
|
|
|
|
Ci.nsISupportsWeakReference
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
})(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
register: function() {
|
|
|
|
|
|
|
|
this.observer.addObserver(this, hostName + '-restart', true);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unregister: function() {
|
|
|
|
|
|
|
|
this.observer.removeObserver(this, hostName + '-restart');
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
observe: function() {
|
|
|
|
|
|
|
|
shutdown();
|
|
|
|
shutdown();
|
|
|
|
startup();
|
|
|
|
startup();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -66,8 +48,8 @@ function startup(data, reason) {
|
|
|
|
this.removeEventListener(e.type, onReady);
|
|
|
|
this.removeEventListener(e.type, onReady);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let hDoc = Cc['@mozilla.org/appshell/appShellService;1']
|
|
|
|
let hDoc = Components.classes['@mozilla.org/appshell/appShellService;1']
|
|
|
|
.getService(Ci.nsIAppShellService)
|
|
|
|
.getService(Components.interfaces.nsIAppShellService)
|
|
|
|
.hiddenDOMWindow.document;
|
|
|
|
.hiddenDOMWindow.document;
|
|
|
|
|
|
|
|
|
|
|
|
bgProcess = hDoc.documentElement.appendChild(
|
|
|
|
bgProcess = hDoc.documentElement.appendChild(
|
|
|
@ -77,7 +59,11 @@ function startup(data, reason) {
|
|
|
|
'src',
|
|
|
|
'src',
|
|
|
|
'chrome://' + hostName + '/content/background.html'
|
|
|
|
'chrome://' + hostName + '/content/background.html'
|
|
|
|
);
|
|
|
|
);
|
|
|
|
restartObserver.register();
|
|
|
|
|
|
|
|
|
|
|
|
restartListener.messageManager.addMessageListener(
|
|
|
|
|
|
|
|
hostName + '-restart',
|
|
|
|
|
|
|
|
restartListener
|
|
|
|
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if ( reason !== APP_STARTUP ) {
|
|
|
|
if ( reason !== APP_STARTUP ) {
|
|
|
@ -85,8 +71,8 @@ function startup(data, reason) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let ww = Cc['@mozilla.org/embedcomp/window-watcher;1']
|
|
|
|
let ww = Components.classes['@mozilla.org/embedcomp/window-watcher;1']
|
|
|
|
.getService(Ci.nsIWindowWatcher);
|
|
|
|
.getService(Components.interfaces.nsIWindowWatcher);
|
|
|
|
|
|
|
|
|
|
|
|
ww.registerNotification({
|
|
|
|
ww.registerNotification({
|
|
|
|
observe: function(win) {
|
|
|
|
observe: function(win) {
|
|
|
@ -107,7 +93,10 @@ function shutdown(data, reason) {
|
|
|
|
|
|
|
|
|
|
|
|
// Remove the restartObserver only when the extension is being disabled
|
|
|
|
// Remove the restartObserver only when the extension is being disabled
|
|
|
|
if ( data !== undefined ) {
|
|
|
|
if ( data !== undefined ) {
|
|
|
|
restartObserver.unregister();
|
|
|
|
restartListener.messageManager.removeMessageListener(
|
|
|
|
|
|
|
|
hostName + '-restart',
|
|
|
|
|
|
|
|
restartListener
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -115,8 +104,8 @@ function shutdown(data, reason) {
|
|
|
|
|
|
|
|
|
|
|
|
function install() {
|
|
|
|
function install() {
|
|
|
|
// https://bugzil.la/719376
|
|
|
|
// https://bugzil.la/719376
|
|
|
|
Cc['@mozilla.org/intl/stringbundle;1']
|
|
|
|
Components.classes['@mozilla.org/intl/stringbundle;1']
|
|
|
|
.getService(Ci.nsIStringBundleService).flushBundles();
|
|
|
|
.getService(Components.interfaces.nsIStringBundleService).flushBundles();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|