Creating a web browser
This fragment instantiates a nsWebBrowser component and sets your window as the container for this nsWebBrowser.
// include core Mozilla system headers
#include "nsComponentManager.h"
// include pertinent embedding interfaces
#include "nsIBaseWindow.h"
#include "nsIWebBrowser.h"
...
nsCOMPtr<nsIBaseWindow> baseWindow;
nsCOMPtr<nsIWebBrowser> webBrowser;
// Create a nsWebBrowser instance
webBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
// Register embedding component which implements the
// window level callback interface.
rv = webBrowser->SetContainerWindow(
NS_STATIC_CAST(nsIWebBrowserChrome*, this));
if (NS_FAILED(rv)) return rv;
|