views:

28

answers:

1

Hello guys / gals,

First off, this is my first attempt at writing an add-on. That being said, I am attempting to write an add-on that makes some configuration changes and needs to restart Firefox in order to have the changes take effect. I am currently restarting Firefox using the following code:

        var boot = Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(Components.interfaces.nsIAppStartup);  
    boot.quit(Components.interfaces.nsIAppStartup.eForceQuit|Components.interfaces.nsIAppStartup.eRestart);  

The problem is, it restarts and opens the browser window(s) to whatever the users homepage is currently set to. I want it to re-open all windows / tabs that were previously open before the restart (similar to what happens when you install a new add-on).

Anyone ever messed with this type of functionality before?

A: 

If you're targeting Firefox 3+ you could try the FUEL Application.restart() function. It might just call the same underlying code that you've already tried but it's worth a try.

https://developer.mozilla.org/en/Toolkit_API/extIApplication#restart.28.29

You might also be interested in monitoring preferences (maybe it could remove the need for a restart):

https://developer.mozilla.org/en/Code_snippets/Preferences#Using_preference_observers

Don't use FUEL preference observers - I've just discovered they fail intermittently (https://bugzilla.mozilla.org/show_bug.cgi?id=488587) so use the XPCOM observer instead.

Luckyrat