Correct way to restore Firefox preferences when uninstalling an app by external app

I wrote a suite of Windows applications that, among other things, installs a Firefox add-on that, once launched, changes Firefox's network preferences by interacting with nsIPrefService.

The extension itself is located in the Program Files folder along with other parts of the application that work together with each other.

Since the app consists of several components, the correct way to uninstall it is through the control panel or using the uninstall shortcut that I provide to users.

I have no control over whether Firefox will run or not when the user wants to uninstall (perhaps I can try to determine if it's running in the uninstaller and ask the user to close it to continue).

Since the purpose of the uninstaller is to remove all traces of the program from the end-user system, ie:

  • all files in the Program Files folder, including extension components
  • remove the add-on from Firefox (by deleting the registry key under HKEY_CURRENT_USER \ Software \ Mozilla \ Firefox \ Extensions, which will cause the add-on to be canceled the next time you restart Firefox)
  • remove special registry keys for an application

Then, after deleting the users on the system, there is no my code that can restore the network settings to what they were before the component was installed. This leads to the fact that end users cannot browse the web and be very frustrated!

The only way I can figure out how to do this at the moment is to include my component in the registry of the window where the user profile folder is located - which I can do with my addition:

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

      

And then my uninstaller will directly modify the prefs.js file at that location. But this will only work if I can guarantee that Firefox will not work during uninstall (as prefs.js is overwritten when FF is closed)

For me, this is not an elegant solution:

  • This does not seem to be future proof as it depends on the format and symbols used by prefs.js, which may change in future releases of FF.
  • Firefox has the nasty habit of not always closing properly (sometimes other installed add-ons prevent it from completely unloading from memory. This will break my uninstaller).
  • It won't work (without detailed modification) if the user has multiple FF profiles, all with my addon.

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

+2


source to share


2 answers


Have you tried packing the default files ( defaults/preferences/myprefs.js

) in your extension? I haven't tested if it works for Firefox default override, but it should.



0


source


Could 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 had several installers who did this to me. However, not unistallers that I can remember.

In addition, it does not guarantee a future solution and does not apply to profiles.

0


source







All Articles