views:

252

answers:

2

I have written an application suite on Windows which amongst other things installs a Firefox add-on which once run modifies the Firefox network preferences by interfacing with nsIPrefService.

The extension itself resides in a folder under Program Files along with other parts of the application which work together with each other.

Since the application consists of a number of components, the correct way to uninstall it is via the Control Panel or via an uninstall shortcut I provide for the users.

I have no control over whether Firefox will be running or not when the user chooses to uninstall (possibly I could try to detect if it's running in the uninstaller and request the user close it to continue).

Since the purposes of the uninstaller is to remove all traces of the program from the end-users system i.e:

  • all the files under the Program Files folder, including the extension components
  • remove the add-on from Firefox (by removing the registry key under HKEY_CURRENT_USER\Software\Mozilla\Firefox\Extensions, causing the add-on to unregister on next Firefox restart)
  • remove application specific registry keys

Then after uninstall there isn't any of my code left on the users system capable of restoring the network preferences to what they were before the component was installed. This results in end-users not being able to browse the web and being very frustrated!

The only way I can figure out how to do this at the moment is to have my component write to the window's registry the location of the users profile folder - which I can do with my add-on:

Components.classes["@mozilla.org/file/directory_service;1"]
   .getService(Components.interfaces.nsIProperties).get("ProfD", 
    Components.interfaces.nsIFile).path

And then have my uninstaller modify the prefs.js file in that location directly. But this will only work if I can guarantee Firefox isn't running during uninstall (since prefs.js is re-written on FF close)

To me this is not an elegant solution:

  • It seems not to be future proof since it is dependent on the format and symbols used prefs.js which may change in future FF releases.
  • Firefox has a nasty habbit of not always closing properlly (sometimes other installed add-ons prevent it from completely unloading from memory. This would break my uninstaller).
  • This wouldn't work (without elaborate modification) if the user has multiple FF profiles setup all using my add-on.

Is there a better or "standard" way to achieve this simple task?

A: 

Did you try to package defaults files (defaults/preferences/myprefs.js) in your extension? I didn't check if it works for overriding Firefox-wide defaults, but it should.

Nickolay
A: 

Can't the uninstaller "insist" that Firefox be closed? eg,

check if FireFox is open
  if open, inform user "FF must be closed, or cancel uninstall" ok/cancel
  loop

I've had several installers do this to me. Not unistallers, though, that I can remember.

Also, this doesn't future-proof the solution, nor deal with profiles.

Michael Paulukonis