Olivier Danes wrote:
code for Firefox and compile it. It creates a /bin directory which is
what you pass NS_InitEmbedding ().
thx Niky you're right, initialisation is ok now... may you give me some
clues on how to load an URI ? nsIWebNavigation::LoadURI returns me a
NS_ERROR_UNEXPECTED ...
thx Olivier.
nsCOMPtr<nsIWebBrowser> theWebBrowser;
nsCOMPtr<nsIWebNavigation> theWebNav; // nsIWebNavigation object
theWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
printf("do_CreateInstance FAILED (rv = 0x%08x)\n", rv);
// DROP THROUGH
}
else {
printf("do_CreateInstance SUCCEEDED (rv = 0x%08x)\n", rv);
}
theWebNav = do_QueryInterface(theWebBrowser, &rv);
if (NS_FAILED(rv)) {
printf("do_QueryInterface FAILED (rv = 0x%08x)\n", rv);
// DROP THROUGH
}
else {
printf("do_QueryInterface SUCCEEDED (rv = 0x%08x)\n", rv);
}
rv = theWebNav->LoadURI((const PRUnichar*)(argv[1]),
nsIWebNavigation::LOAD_FLAGS_NONE,
nsnull, nsnull, nsnull);
if (NS_FAILED(rv)) {
printf("LoadURI FAILED (rv = 0x%08x)\n", rv);
// DROP THROUGH
}
else {
printf("LoadURI SUCCEEDED (rv = 0x%08x)\n", rv);
}
Olivier,
I'm not sure if there is a way to just create an nsIWebBrowser interface
without having an nsIWebBrowserChrome interface to attach it to. The
method below is a brief summary of how I accomplished this.
You have to have an nsIWebBrowserChrome interface to get the
nsIWebBrowser from (nsIWebBrowserChrome::GetWebBrowser ()), then you can
QI the nsIWebNavigation from the nsIWebBrowser. In my embedding app, I
create a class that implements nsIWebBrowserChrome among other
interfaces. In the initialization stage, I create the nsIWebBrowser as
you have done above, but then tell the nsIWebBrowser that the
nsIWebBrowserChrome class I have created is it's container. Once that
is done (other stuff that has to be done as well) I can load a URI with
the method you are trying above.
Here are a couple of good links I used to help me get started with
embedding.
http://www.xulplanet.com (Great reference site for all the interfaces)
http://www.mozilla.org/projects/embedding/
https://addons.mozilla.org/firefox/2230/ (This is actually a plugin to
Firefox...it lets you browse the XPCOM interfaces.)
Hope this helps!
Nik Williams
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding