Letting add-ons perform work during install and uninstall

One of the biggest requested items I see in the add-ons newsgroups and IRC channel is from developers asking how to perform some work when their add-on is installed or uninstalled. Previously it has been vaguely possible to do this, but there is a lot of hassle involved and it wouldn’t always work right.

As part of my roadmap for improving the extension manager we are talking about adding real support for these sorts of activities. The draft specification covers the proposal in more details but in draft it allows the following:

  • Add-ons will be able to provide code to run when their add-on is installed, uninstalled, disabled, enabled or upgraded.
  • Add-ons will be able to provide a list of files in the profile folder and preferences to be removed when the add-on is uninstalled.

There are a few restrictions so if you are interested check out the full specification and let me know what you think. There’s still room for change, but I think the proposal provides real benefits for add-on developers as it stands.

5 thoughts on “Letting add-ons perform work during install and uninstall”

  1. As a user, I don’t necessarily want to delete all settings when uninstalling an extension. I’d really want a checkbox in the uninstall confirmation (which already exists) asking me whether to remove all settings or not. The wiki doesn’t say anything about this, so I thought I’d just throw this in…

  2. The specification looks solid. I wonder however what kind of actions hooks *are* permitted to do. In particular whether they will run in a sandbox – because if they don’t, preventing them from messing with the extension manager will be very hard (if not impossible). But if they do run in a sandbox, it will be very hard to define a sufficiently useful API.

  3. Oh, and I agree with Malte – removing preferences would be a very useful thing if made optional. Currently, people often have the problem that they reinstall Adblock Plus in the hope its settings would reset themselves – but this doesn’t happen. However, most people won’t want the settings to be purged on uninstall.

  4. Yeah I failed to mention anything about user choice during the uninstall process but it is something I have been considering, I’ll have to update it with some thoughts on that in the near future.

    As for sandboxing, I don’t think we’ll be sandboxing much, which yes does give rise to the potential for the add-on hook to do something to the extension manager, however I think we can be quite careful and restrict that if we need to. Perhaps by putting locks in place so the various API calls that can install/uninstall extensions cannot be used during the call to the hook. Perhaps even going so far as saving the state of the extensions database and restoring it afterwards.

    I’m hoping that we won’t need to go too far though. Ultimately if an add-on wants to cause problems then it has adequate time to do it while installed, I’m not sure that we would have a particular problem during uninstall, and likely the only way to stop such problems would be a complete sandbox as you say, making the feature essentially useless.

  5. Yes, even if you implement locks – a hook that isn’t sandboxed can easily install a delayed action, e.g. one that enables the add-on again. So if an add-on wants to cause trouble it will be able to do that no matter what.

Comments are closed.