Custom Extension Installation
As described in Extension Installation and in Extension Manifests, each extension must provide an install manifest. If the extension provides only this manifest the Extension Manager system will use the data supplied by this manifest to install the Extension. In this simple mode the structure of the files within the XPI is important.
For more elaborate uses, extension authors may still use the install.js install script to more completely configure installation. They must supply the same manifest that the simple mode extensions do, but if an install.js script is present at the top level of the XPI file it will be used to actually install the extension.
An advanced install script might look like this:
// Used to generate log entries in extensions/<myExtension>/uninstall.log
var err = initInstall("My Extension 1.0 for Firefox 1.0", "@bengoodger.com/software/magpie", "4.0");
// This creates a new folder under [bin|profile]/extensions/[uid]/
...
if (verifyDiskSpace(getFolder("Profile Extension Chrome"), spaceRequired)) {
addFile("My Extension Chrome", // Registry Name
"chrome/myExtension.jar", // Source File (in XPI)
getFolder(getFolder("Profile Extension Chrome")), // Target Folder
""); // Target subdir
addFile("My Extension Component", // Registry Name
"components/myExtension.dll", // Source File (in XPI)
getFolder(getFolder("Profile Extension Components")), // Target Folder
""); // Target subdir
addFile("My Extension Default Prefs", // Registry Name
"chrome/myExtension.js", // Source File (in JAR)
getFolder(getFolder("Profile Extension Default Preferences")), // Target Folder
""); // Target subdir
var file = getFolder("Profile Extension Chrome", "myExtension.jar");
registerChrome(PACKAGE | DELAYED_CHROME, file, "content/myExtension");
registerChrome(LOCALE | DELAYED_CHROME, file, "locale/en-US/myExtension");
registerChrome(SKIN | DELAYED_CHROME, file, "skin/classic/myExtension");
// Tidy up
performInstall();
}
...
"Profile Extension Chrome", "Application Extension Components" etc are new parameters to getFolder that resolve to the appropriate folder within the profile/application extensions folder.
The second parameter to initInstall is the extension's unique identifier, the third is the extension's version. This information must match the chrome:id and chrome:version arcs in the extension manifest.
These entries are used to generate the uninstall log.