Register shutdown handler to call Scholar.shutdown() on exit
This commit is contained in:
parent
635d2e48b9
commit
9a0457b43e
|
@ -14,10 +14,12 @@ const SCHOLAR_CONFIG = {
|
||||||
*/
|
*/
|
||||||
var Scholar = new function(){
|
var Scholar = new function(){
|
||||||
var _initialized = false;
|
var _initialized = false;
|
||||||
|
var _shutdown = false;
|
||||||
var _localizedStringBundle;
|
var _localizedStringBundle;
|
||||||
|
|
||||||
// Privileged (public) methods
|
// Privileged (public) methods
|
||||||
this.init = init;
|
this.init = init;
|
||||||
|
this.shutdown = shutdown;
|
||||||
this.getProfileDirectory = getProfileDirectory;
|
this.getProfileDirectory = getProfileDirectory;
|
||||||
this.getScholarDirectory = getScholarDirectory;
|
this.getScholarDirectory = getScholarDirectory;
|
||||||
this.getStorageDirectory = getStorageDirectory;
|
this.getStorageDirectory = getStorageDirectory;
|
||||||
|
@ -42,6 +44,15 @@ var Scholar = new function(){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register shutdown handler to call Scholar.shutdown()
|
||||||
|
var observerService = Components.classes["@mozilla.org/observer-service;1"]
|
||||||
|
.getService(Components.interfaces.nsIObserverService);
|
||||||
|
observerService.addObserver({
|
||||||
|
observe: function(subject, topic, data){
|
||||||
|
Scholar.shutdown(subject, topic, data)
|
||||||
|
}
|
||||||
|
}, "xpcom-shutdown", false);
|
||||||
|
|
||||||
// Load in the preferences branch for the extension
|
// Load in the preferences branch for the extension
|
||||||
Scholar.Prefs.init();
|
Scholar.Prefs.init();
|
||||||
|
|
||||||
|
@ -75,6 +86,16 @@ var Scholar = new function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function shutdown(subject, topic, data){
|
||||||
|
// Called twice otherwise, for some reason
|
||||||
|
if (_shutdown){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_shutdown = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function getProfileDirectory(){
|
function getProfileDirectory(){
|
||||||
return Components.classes["@mozilla.org/file/directory_service;1"]
|
return Components.classes["@mozilla.org/file/directory_service;1"]
|
||||||
.getService(Components.interfaces.nsIProperties)
|
.getService(Components.interfaces.nsIProperties)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user