Anna,
I think Benjamin Smedberg is right: XULRunner is now the way to go. I
found this out the hard way, which I have described below hoping that
some of it might be useful to you.
I am making a C++ application (in Ubuntu) with a browser embedded in it.
This application is a port of an MS Windows C++ application, where
embedding an IE browser was a simple matter. Embedding Mozilla is rather
more complex. Here is what I have found out:
I started off in April 2008 trying to make an embedding build (in Ubuntu
and Gnome/GTK) according to instructions contained in:
https://developer.mozilla.org/en/Mozilla_Embedding_FAQ
Please note that the current instructions have been updated compared to
the ones I used. In summary, the instruction I followed made me:
1. Download the Mozilla source tree from one of the "nightly" directories
2. Configure the build options using a ".mozconfig" file
3. Compile the source code into a suite of libraries and a sample
embedding application called TestGtkEmbed
It took me a long time and I had to overcome a number of problems, but
by June 2008 I had a working version of TestGtkEmbed. After that, I
wanted to move the example to wxWidgets, i.e. embed the browser in a
wxWidgets application rather than in GTK, which is lower-level than
wxWidgets.
After a frustrating time trying to find the right documentation on the
Mozilla side I gave up and tried another approach (see below). The
problem with the documentation is that there is no proper versioning and
a confusing evolution of terms. I gave up on TestGtkEmbed because I
found a complete worked example of an embedded browser using XULRunner
1.9. As Benjamin Smedberg says below, XULRunner is now the preferred way
to embed Mozilla. Some of the terms I found confusing are:
- "*Gecko*" once meant the Mozilla browser core of which Firefox is an
implementation. It fell into disuse in recent years, being replaced by
terms like "embedded Mozilla browser" and plain Mozilla. In the last six
months, however, it seems to have been revived.
- *XULRunner*. XULRunner is a revamp of the previous ways of using Gecko
and, confusingly, applies to two different things:
1. An XML-based scripting language which can be read by Firefox. As
far as I can make out without having done it, you write an XML
script and at the command line type something like "$> firefox -XUL
Myscript" and instead of starting up normally, Firefox executes the
commands in the script. It seems that XUL scripts can be very
powerful and can customize the way Firefox works in a wide range of
ways.
2. Embedding Mozilla/Gecko in a C++ application (my goal).
- *Chrome:* jargon for the window in which Mozilla/Gecko is embedded.
Using the first embedding method I attempted, it was compulsory to
implement an interface called nsIWebBroswerChrome. In other words the
embedding application had to pass the embedded browser a pointer to an
object containing a method called nsIWebBroswerChrome. This would enable
the embedded browser to call the embedding application and get it to do
things. Failure to implement this interface presumably meant that your
embedding application would try to call a non-existent interface and
thus crash. nsIWebBrowserChrome was one of three compulsory interfaces,
the others being nsIEmbeddingSiteWindow and nsIWebProgressListener.
However, it is not clear whether nsIWebBrowserChrome is still
compulsory. There are very few mentions of it in conjunction with XULRunner.
*
Success with XULRunner.* Thanks to Amith Raravi, there is a complete
worked example of a minimal wxWidgets embedding application here
http://groups.google.com/group/mozilla.dev.embedding/browse_thread/thread/31a22e981127c878
I successfully reproduced this example and therefore gave up on my
previous approach. There is a similar worked example for GTK here:
http://groups.google.com/group/mozilla.dev.embedding/browse_thread/thread/fb275315aff3c0dd/39fd5a3b572e5af6
It seems that with XULRunner, Mozilla/Gecko has been ready-compiled and
packaged up into a set of libraries that are easier to embed. Also, it
seems that XULRunner has packaged up some of the code needed to
initialize the embedded browser. For example XRE_InitEmbedding (a
function pointer with a fairly complex type governed by a pre-processor
macro) seems to have superseded NS_InitEmbedding() as the preferred way
of starting the embedding layer.
I am currently trying to find out which interfaces need to be
implemented in my containing application, and will then move onto trying
to navigate and read and write data via the DOM.
I hope this account is helpful.
Regards
Francis.
Anna Nachesa wrote:
To finalize this question, as I am still a bit lost here:
do you mean that in order to embed Mozilla one should now _always_ take
xulrunner (not the firefox), build it and take (some part of ) the contents
of /dist/bin (instead of dist/embed as it was before)?
Which application is supposed to be enabled for xulrunner build, then?
browser or xulrunner? And what is the difference?
Benjamin Smedberg wrote:
On 2/5/09 7:17 AM, Anna Nachesa wrote:
Hi,
I have tried to create the "embedding build": i.e. after a successful
build,
I do the following:
cd <builddir>/embedding
make
cd <builddir>/embedding/config
make
Don't do this. It may have been the right thing to do some time long ago
in
the past. Now XULRunner is the embedding solution, and you should just
build
it normally.
--BDS
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding