Reputation: 173
I am curious about the inner workings of the Firefox add-on installation procedure. I have noticed that the following steps take place when user installs an add-on from addons.mozilla.org:
What I would like to know is:
Basically, I would like to alter some files after an add-on is downloaded at step 1, but before it becomes part of the browser (step 5). I want to add this functionality in the Firefox source code.
Upvotes: 3
Views: 1135
Reputation: 57651
You analysis is mostly correct, it merely leaves out bootstrapped extensions. Bootstrapped extensions don't require a browser restart, they will be moved out of the staged
directory and activated immediately.
The Add-on Manager is all JavaScript starting with Firefox 4. The important files are amWebInstallListener.js (the component handling add-on installations from the web), AddonManager.jsm (the generic add-on management API) and XPIProvider.jsm (the provider for XPI-packaged extensions).
extWebInstallListener.onWebInstallRequested()
gets called with a bunch of AddonInstall
instances (defined in XPIInstall.jsm
) and creates an Installer
instance that calls AddonInstall.install()
for each of the installs. The downloads go into a temp file determined by getTemporaryFile()
in XPIProvider.jsm
(tmp-foo.xpi
in the OS-specific temp directory).Installer.checkAllDownloaded()
determines that all downloads finished and displays a modal confirmation dialog (URI_XPINSTALL_DIALOG
).AddonInstall.startInstall()
moves the add-on into the staging directory. Bootstrapped add-ons will be immediately installed after that. For other add-ons it continues to step 4.onInstallEnded
listeners are triggered - one of them shows the message that the browser needs to be restarted.XPIProvider.startup()
calls XPIProvider.checkForChanges()
calls XPIProvider.processPendingFileChanges()
.Upvotes: 2