Search code examples
firefoxfirefox-addonthunderbirdthunderbird-addonamo

Programatically install add-on supporting automatic updates


I'm developing a desktop application that can integrate with some Mozilla application¹ through an add-on. I'd like to provide users the option to install the add-on through my application, but I haven't been able to find an official way fulfilling my requirements:

  1. The add-on, once installed, must receive automatic updates
  2. There should be no complex user interaction required
  3. The method must not be forbidden by Mozilla (as in, must not result in blacklisting)

Is there a method to install an add-on fulfilling these requirements?


Options I considered, that do not fulfill these requirements:

  • Global installation of add-ons – this does, however, not permit automatic updates through AMO's infrastructure or updateURLs in install.rdf (violates 1)
  • Copying the XPI into the default profile and enabling it – does not cause the Opt-in dialog to show up, which is a violation of the Add-on Guidelines and thus a ticket to blacklisting² (violates 3)
  • Executing the application with the URL of the XPI – does only work for applications with a browser component, such as Firefox, but not for Thunderbird

I run into some profile-related bugs while testing, this option is better than my initial tests suggested:

  • Copying the XPI into the default profile – results in the add-on starting in disabled state, thus not being any better than telling the user to download the extension manually (violates 2) and the user will be asked to permit (or decline) the installation in a new tab (sadly, this tab is sometimes opened in the background, thus not optimal for condition 2)

¹ In my case, that is Thunderbird; but I'd like to keep the question open for Firefox as well, if possible.

² I do not think the issue could be resolved by using a custom opt-in dialog within my application, as Mozilla is known to blindly enforce policies for the Mozilla-defined "greater good" (see add-on signing).


Solution

  • While not an optimal solution, additional testing suggests the one of the initial approaches mentioned in the question works better than my initial tests suggested:

    Copy the XPI into the extension folder of all profiles that shall be affected, using the filename ID.xpi where ID is the id of the add-on (if the add-on requires unpacking, unpack it into a ID folder instead).

    This will install the add-on in a disabled state, but the user will be asked on the next application start whether he/she wishes to permit the installation. Upon user confirmation, the add-on will be enabled.


    I'd welcome additional answers addressing the issues of this solution:

    • The tab asking for user confirmation is shown in the background in some cases (for example in Thunderbird if the add-on tab was the foreground tab when closing before the restart)
    • The installer thus needs logic to parse profiles.ini in order to determine profile folder locations
    • Only profiles at install time may be affected