The Mozilla Public API consists of a collection of services and components which are accessed via XPCOM interfaces. Mozilla's XPCOM layer consists of a component model (called XPCOM) and the infrastructure necessary to support dynamic registration, instantiation and manipulation of XPCOM components.
At the heart of XPCOM's implementation is the Service Manager and the Component Manager. Together, these two services provide a centralized point for gaining access to all of the public Mozilla interfaces.
The Service Manager exposes all of the available XPCOM services - each service represents a global object which provides some piece of functionality. The Component Manager allows new instances of registered XPCOM components to be instantiated.
The embedding layer consists of several components built on top of XPCOM and its services. Much of the Gecko functionality is exposed through a component called the nsWebBrowser. Embedding applications can leverage this component to easily access many of Gecko's features. Each WebBrowser instance represents the "client-area" of a typical browser window. The WebBrowser exposes a set of interfaces which allow the embedding application to control activity and respond to changes within this client area. Using these interfaces an embedding application can build up its own user interface around a WebBrowser instance.
The following utility classes are available from the XPCOM DLL. They provide some basic functionality which should be leveraged when building new XPCOM components.
These are templatized smart pointers which transparently deal with XPCOM reference counting issues. See the nsCOMPtr User's Manual for more information.
There are a collection of string classes which support both unicode and ASCII strings. These classes provide a variety of string operations as well as dealing with the memory management issues of storing the underlying data. See the String Guide for more details.
This is an nsCOMPtr which encapsulates XPCOM weak reference support. See the nsIWeakReference document for more information.
Public Return Codes
* NS_SUCCEEDED * NS_ERROR_FAILURE * NS_ERROR_NOT_IMPLEMENTED
The following functions are available from the XPCOM DLL.
This function initializes the Gecko embedding support. This must be the first function call made into Gecko.
This function shuts down Gecko and cleans up any remaining resources... Currently, once Gecko has been shutdown, it cannot be restarted in the same process space... This should change in the future.
This helper class provides static accessors to the global nsMemory Service.
This function returns an instance of the Component Manager service.
This is a helper class which converts an ASCII string into a UCS2 string. Typically, instances of this class are stack allocated, and wrap ASCII arguments which must be converted into UCS2.
This is a helper class which works in conjunction with nsCOMPtr to perform a simplified call to nsISupports::QueryInterface(...) with a typesafe assignment.
This function simplfies retrieving interfaces via the nsIInterfaceRequestor::GetInterface(...) method. Using this function, one can use nsISupports instances and still easily access other interfaces via nsIInterfaceRequestor.
Internally, this function tries to convert the nsISupports argument into an nsIInterfaceRequestor and then calls GetInterface(...) to retrieve the requested interface.
This function is the equivilent of do_QueryInterface except that it performs the QI through a weak reference.http://www.mozilla.org/projects/embedding/PublicAPIs.html Mozilla Embedding APIs
This function simplifies accessing services from the Service Manager.
This function simplifies creating new component instances.
This template helper class allows easy access to an interface's nsIID. Typically the NS_GET_IID(...) macro is used instead of using the nsCOMTypeInfo template directly.
This function creates a weak reference to a component which implements the nsIWeakReference interface.
The Service Manager is the central repository for accessing instances of the various XPCOM services. Each service is represented by a singleton object which is instantiated the first time it is requested and remains alive until the Service Manager is shut down, or the service is explicitly unloaded.
Through the Service Manager, individual services can be loaded, unloaded and accessed.
The nsMemory service provides the global memory manager implementation for XPCOM. In addition to memory allocation and release, this service provides low memory notifications, called a memory pressure observers, which are notified when memory is low - thus allowing cached resources to be freed.
All heap access should be done via the nsMemory service. To facilitate this, a set of global functions are available to access the nsMemory methods without requiring an instance of the nsMemory service (see nsMemory.h).
The nsComponentManager service is responsible for creating new instances of XPCOM components. The Component Manager is also responsible for registering and managing the class factories used for component creation...
The nsURILoader service is responsible for targeting a URI at an appropriate content handler. A content handler may be an existing or new window, a helper application or the Unknown Content Handler - if no other handler can be found for the content-type.
The UnknownContentTypeHandler service is the last resort of the URILoader when no other content handler can be located. If no registered content handlers are available, the UnknownContentTypeHandler is notified.
The default implementation of this service displays a dialog box asking the user if the content should be saved to disk...
HelperApp Launch Dialog
The Preferences service provides access to persistent data stored within a user's profile directory.
Profile Manager Service
Document Loader Service (WebProgress)
Eventually, this service will be replaced by theWebProgress service...
The nsWebBrowser is the main embedding component which Gecko exposes. Conceptually, each nsWebBrowser instance represents a HTML content area.
Conceptually, for each document being rendered, Gecko creates a container called a DOMWindow. Each WebBrowser exposes a tree of DOMWindows - representing the frame hierarchy for the current document. As such, access to individual document frames is done via the DOMWindow interfaces. Manipulation of the entire document structure is done via the various WebBrowser interfaces.
Contract-id: NS_WEBBROWSER_CONTRACTID Implemented Interfaces: o nsIWebBrowser o nsIWebNavigation o nsIWebBrowserSetup o nsIWebBrowserPersist o nsIWebBrowserFind o nsIWebBrowserPrint o nsIWebBrowserFocus o nsIBaseWindow
Requestor Interfaces: o nsIDOMWindow o nsIDOMDocument o nsIWebProgress o nsIClipboardCommands o nsIPrompt Related Interfaces: o nsIPrompt o nsIWebBrowserChrome o nsIWebBrowserSiteWindow o nsIWebProgressListener o nsIContextMenuListener o nsIPrintOptions
Most of Gecko's functionality is exposed through the nsWebBrowser component. The WebBrowser provides a simple mechanism for other applications to leverage Gecko functionality. Each instance of a WebBrowser encapsulates a full featured HTML content area.
The embedding application receives notifications from Gecko through a set of callback interfaces it may choose to implement.
Original Document Information
- Author(s): rpotts, alecf, oeschger at netscape.com
- Last Updated Date: March 5, 2003
- Copyright Information: Creative Commons