Add-on Manager

The Add-on Manager is responsible for managing all of the add-ons installed in the application. Through its APIs information about all installed add-ons can be retrieved and new add-ons can be installed. The APIs are designed to be generic and support many different types of add-ons.

Many functions in the Add-on Manager interface operate asynchronously returning results through callbacks passed to the functions. The callbacks may be called immediately while the initial function is still executing or shortly after, depending on when the requested data becomes available.

Accessing installed add-ons

Information about installed add-ons can be retrieved through the main AddonManager API. All of its functions are asynchronous, meaning that a callback function must be passed to receive the Addon instances. The callback may well only be called after the API function returns. For example:

Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAllAddons(function(aAddons) {
// Here aAddons is an array of Addon objects
});
// This code will execute before the code inside the callback

Finding updates

Add-ons can be checked for updates using the Addon.findUpdates() method. It must be passed an UpdateListener to receive information about compatibility information and new update information. Any available update is returned as an AddonInstall which is ready to be downloaded and installed.

(Firefox 7.0 / Thunderbird 7.0 / SeaMonkey 2.4)

Detecting add-on changes

You can also get lists of add-ons that, at startup, were changed in various ways. The AddonManager.getStartupChanges() method lets you find out which add-ons were installed, removed, updated, enabled, or disabled at application startup.

For example, to take a look at the add-ons that were disabled at startup:

Components.utils.import("resource://gre/modules/AddonManager.jsm");
let addonIDs = AddonManager.getStartupChanges(AddonManager.STARTUP_CHANGE_DISABLED);
if (addonIDs.length > 0) {
// addonIDs is now an array of the add-on IDs that have been disabled
alert("Note: " + addonIDs.length + " add-ons have been disabled.");
}

Open Add-on Manager Tab

The add-on manager tab can be opened programatically with the function BrowserOpenAddonsMgr which is availble on chrome window of "navigator:browser" type. You can pass the url to a page in the add-on manager tab to load that page.