+ refactored Raymond's fix to Bug 576424

This commit is contained in:
Ian Gilman 2010-07-02 16:33:33 -07:00
parent e33aa7ca0a
commit dbd70f1265
3 changed files with 41 additions and 17 deletions

View File

@ -45,6 +45,41 @@ Storage = {
TAB_DATA_IDENTIFIER: "tabcandy-tab",
UI_DATA_IDENTIFIER: "tabcandy-ui",
// ----------
// Function: onReady
// Calls callback when Storage is ready for business. Could be immediately if it's already ready
// or later if needed.
onReady: function(callback) {
try {
var alreadyReady = false; // TODO: actually check
if(alreadyReady)
callback();
else {
let obsService =
Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
let observer = {
observe: function(subject, topic, data) {
try {
if (topic == "browser-delayed-startup-finished") {
if (subject == Utils.getCurrentWindow()) {
callback();
}
}
} catch(e) {
Utils.log(e);
}
}
};
obsService.addObserver(observer, "browser-delayed-startup-finished", false);
}
} catch(e) {
Utils.log(e);
}
},
// ----------
init: function() {
this._sessionStore = Components.classes["@mozilla.org/browser/sessionstore;1"]

View File

@ -531,11 +531,6 @@ UIClass.prototype = {
try {
Utils.log('TabCandy init --------------------');
let obsService =
Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
obsService.addObserver(this, "browser-delayed-startup-finished", false);
// Variable: navBar
// A reference to the <Navbar>, for manipulating the browser's nav bar.
this.navBar = Navbar;
@ -599,6 +594,11 @@ UIClass.prototype = {
currentWindow.addEventListener(
"resize", function() { Page.setCloseButtonOnTabs(); }, false);
// ___ delay init
Storage.onReady(function() {
self.delayInit();
});
}catch(e) {
Utils.log("Error in UIClass(): " + e);
Utils.log(e.fileName);
@ -1026,17 +1026,6 @@ UIClass.prototype = {
} catch(e) {
Utils.log(e);
}
},
// ----------
observe: function(subject, topic, data) {
// once the browser delayed startup finished,we can run the rest of init
// code.
if (topic == "browser-delayed-startup-finished") {
if (subject == Utils.getCurrentWindow()) {
this.delayInit();
}
}
}
};