External Helper App Service¶
The external helper app service is responsible for deciding how to handle an attempt to load come content that cannot be loaded by the browser itself.
Part of this involves using the Handler Service which manages the users preferences for what to do by default with different content.
During a Load¶
When content is already being loaded the URI Loader Service
determines whether the browser can handle the content or not. If not it calls
into the external helper app server through
The content type of the loading content is retrieved from the channel. A file extension is also generated using the Content-Disposition header or if the load is not a HTTP POST request the file extension is generated from the requested URL.
We then query the MIME Service for an nsIMIMEInfo to find information about
apps that can handle the content type or file extension based on OS and user
settings, see below for further details. The result is
used to create a
nsExternalAppHandler which is then used as a stream listener
for the content.
The MIME info object contains settings that control whether to prompt the user before doing anything and what the default action should be. If we need to ask the user then a dialog is shown offering to let users cancel the load, save the content to disk or send it to a registered application handler.
Assuming the load isn’t canceled the content is streamed to disk using a background
file saver with a target
nsITransfer is responsible for
showing the download in the UI.
If the user opted to open the file with an application then once the transfer is
nsIMIMEInfo::LaunchWithFile is used to
launch the application.
The MIME service is responsible for getting an
nsIMIMEInfo object for a
content type or file extension:
Fills out an
nsIMIMEInfobased on OS provided information. This is platform specific but should try to find the default application registered to handle the content.
Ask the handler service to fill out the
nsIMIMEInfowith information held in browser settings. This will not overwrite a any application found from the OS.
If one has not been found already then try to find a type description from a lookup table or just by appending ” File” to the file extension.