How can I embed firefox in a GUI application? - firefox

Has anyone ever embedded the firefox web browser technology in their own [unmanaged] C/C++ GUI application in the same way that IE can be embedded as a COM object? (I would like to do this on Linux, not Windows). Are there "better" alternatives to firefox? I'm open to anything as long as I can use it with non-GPL code. My needs are fairly basic; I only need fundamental HTML parsing and display of static local files, but I'd take advantage of more sophisticated technology, if I can get it. I'd like to be able to use JavaScript, but I can get by without it.

First you need to differentiate between HTML engine and JavaScript Engine.
Firefoxs HTML rendering engine is called Gecko. And here is a guide about Embedding Gecko in your application.
Firefoxs JavaScript engine is called SpiderMonkey and here is How to Embed SpiderMonkey in your C application

Check out webkitgtk. It's not Gecko, but Webkit based. It basically provides a web browser widget that can be used in GTK+ applications. If you want to embed mozilla, there are things in the mercurial repositories for Mozilla repository that let you do it, but it didn't seem heavily supported last I checked.

as stated by Mozilla
Embedding of Gecko is no longer supported
so have a look on either previous mentioned Chromium Embedded Framework or WebKit. Alternatively, you can follow Mozilla's new project https://servo.org/.
You will find some more up to date information on Is it possible to Embed Gecko or Webkit in a Windows Form just like a WebView?

It is possible to use parts of Firefox (such as the Gecko renderer) in other apps. There are various approaches to this, including wxWebConnect, a web browser control for wxWidgets. See also Embedding Gecko
Another popular solution is WebKit. Again, there are various ways you can use this, including QtWebKit (a wrapper for the Qt toolkit) and webkitgtk (already mentioned by SB).

Have a look at CEF (Chromium Embedded Framework). It is very similar to WebKit and it also has built-in HTML and JavaScript engines embedded but has better WebGL and HTML5 Canvas support. It is released under BSD license.

Related

Compiling WebKit for Windows8-Metro Environment

I would like to ask the SO community for the following information:
- Is it possible to compile WebKit for Windows8-Metro Environment, either in the form of a WinRT component or just as a linked library in a C++/XAML application?
- Which are the main steps to achieve this goal?
- Which are the possible things that would make this not possible or very difficult?
- Is it an endeavour someone is working on just now?
- Is it possible to gather interested people so they work on this?
I think you will not be able to just "compile" Webkit for WinRT/Metro Style. Metro Style applications are restricted in the kind of API calls they can make, for example there is no GDI/GDI+/MFC for WinRT. WebKit has several building modes that you can use, you can either build it using QT as rendering engine, or using GTK, or plain GDI, but on all those cases, when you create new builds for Windows OSes you will be using GDI at the very end.
Nevertheless, you could modify Webkit source code and add a new rendering engine that uses WinRT new APIs. You could probably become famous if you do.
As a side note, even when there is a "Windows Store" version of Chrome, by looking at the source code of Chromium it seems to me that this version is just a simple app launcher that communicates with the "normal" desktop version using an IPC channel. It does not appear to be a real Windows Store build of the whole source code.
I am not sure if the WinRT environment will allow this, but there is a project called Awesomium that is a wrapper around Google Chrome and Google Chrome is based on WebKit I think. It also has a .NET wrapper, so you can embedd it onto your .NET app.
I never tried using it, neither I know about if this library is applicable with WinRT, but at least it is a start.
Awesomium
Awesomium .NET samples
DownMakerWPF, an application embedding it to display markdown.
WinRT is a combination of managed and native code, so, you have a chance to port WebKit, but remember - native code have some sandbox restrictions.
Also you can choose XNA instead.

Is there an Adobe AIR like product for just HTML5 (no flash) on Windows

I would like to create a Windows desktop app using HTML5 features, specifically H.264 video,Web SQL Database,FileReader API. I don't want to use AIR (which currently does not support the video tag, instead uses Flash). Ideally I would like an exe file that just wraps the latest version of webkit in a basic window. It should be stand alone, not rely on the user having Chrome etc. installed. It could load an index.html file in the same directory as the exe. That is it.
I have been unable to find anything like this. I was going to build it myself using QTWebkit but the latest version (4.8.0) does not support the Video tag due to some kind of build issue. I assume the 4.8.1 version will fix this.
Does anyone out there know of something like this that is available now?
For anyone coming across this, Titanium for desktop is no longer supported by Appcelerator, but the project is still supported as an open source initiative. As of today (10/14/2012), it is called TideSDK. According to their Twitter account, they're behind in the 1.3 release due to some sponsored work that will end up in the code base.
Additional options not yet mentioned include AppJS (OSS, requires node.js) and Sencha Desktop Packager (quite pricey).
I think titanium is not totally gone. There is this stuff called tideSdk
I couldn't try it out yet also , so video support and the codec are open for your exploration. Here is how they say:
Create multi-platform desktop apps with HTML5, CSS3 and JavaScript
TideSDK is the new standard for creating beautiful and unique desktop
apps using your web development skills.
I recently thought about doing the same thing, you can still do it with air without using flash, but you could also use Chrome Packaged apps, mozilla prism (although inactive today) or Microsoft HTA (html application).
You can think of using a framework that does the browser embedding for you like Titanium. It's mostly used for creating apps that can be published to iphone, android, and windows devices. It will create a windows MSI install.
Another option is to use the CEF project ( Chromium Embedded Framework for C/C++). I havn't looked at it much, so I can't tell you how difficult/easy it is to work with. Their main site also has wrappers for Java, .NET, and other languages.

Fastest/easiest way to build a WebKit based Windows application?

I am a web developer. I don't know how to build native Windows applications. I recently built a Mac desktop application (using MacRuby) which is a WebKit wrapper around one of my web applications. I'd like to do the same thing for Windows (preferably in Ruby, but whatever is easiest).
Since this is not the core of the application, I'd rather not spend a lot of time trying to build and maintain it. I just need a Windows application that can:
Open a specific website on application launch using an embedded WebKit WebView
Trigger Growl notifications via JavaScript (with some sort of named bridge)
What is the easiest, fastest, cleanest way to do this?
Update: So far I've come across some frameworks like Qt and Awesomium. I don't know how these frameworks compare to other options available, so if you have any opinions or advice, I would appreciate it.
Check out http://appjs.org/ it's built with NodeJS at its core! And it uses chromium webkit at it's core :D
Well, this is a very old question, but if you are still interested...
I'd recommend Qt. There are some very good books available with a lot of boilerplate code and wizard-type tools. You will be able to find example code demonstrating the embedded Webkit that you can modify to suit your needs. It is free and redistribution is free (last I knew). You won't have to know anything about native Windows development, nor even use any native Windows dev tools.
Good luck!

firefox add-on vs. extensions vs. plugins

I want to write scripts for firefox. It seems that firefox has different terms, like add-on, extensions, plugins. and I have a feeling they're not all the same. Can you sum up the difference between in a few words?
Add-on: essentially anything that can be installed into the browser. This includes for example extensions, themes, plugins, dictionaries, language packs, search engines.
Extension: a package extending browser functionality, the extension format used by Firefox works in Gecko-based browsers only. Extensions typically use XUL and CSS for their user interface as well as JavaScript for dynamic actions. They have full access to XPCOM and can provide their own XPCOM components as well. Recently the Add-on SDK has been added as an alternative way to generate simple extensions, it uses HTML instead of XUL but limits the ways in which the browser's user interface can be extended significantly. As of Firefox 57, all extensions have to be based on the WebExtensions API.
Plugin: means NPAPI plugins that are supported by all browsers but Internet Explorer (the latter uses the proprietary ActiveX technology instead). Such plugins are binary libraries that are invoked if a website uses an <embed> or <object> tag with a type that is handled by the plugin. The plugin can either draw some content for the tag (windowed plugins) or stay in background and simply provide an API for the webpage's JavaScript code to use (windowless plugins). Typical examples are Flash or Silverlight. Support for plugins is being phased out, as of 2018 Flash is the only plugin still supported to some degree.
Augmenting the useful answer above, I found this high-level summary helpful:
Extensions differ slightly from plug-ins. Plug-ins usually have a narrow set of abilities. [..] Since plug-ins and extensions both increase the utility of the original application, Mozilla uses the term "add-on" as an inclusive category of augmentation modules that consists of plug-ins, themes, and search engines.
(from http://en.wikipedia.org/wiki/Plug-in_(computing))
According to Firefox:
Extensions
Extensions add new features to Firefox or modify existing ones. There are extensions that allow you to block advertisements, download videos from websites, integrate Firefox with websites like Facebook or Twitter and add features included in other browsers, such as translator.
Plugins
Plugins add support for all kinds of Internet content. These usually include patented formats like Flash that are used for video, audio, online games, presentations and more. Plugins are created and distributed by other companies.
add-ons
They are - Extensions, Plugnis, Themes, Search engines and Dictionaries & Language Packs.
Source: Firefox - https://support.mozilla.org/en-US/kb/find-and-install-add-ons-add-features-to-firefox
Extending the Augmentation above
Extension(s) is ment to extend the functionality of software
where a plug-in is ment to solve a problem of the software (to be able to do something it wasent designed to do already).
both types extends the program abilitys,
... and i guess this is why it can be so comfusing.
An Extension can be (and often are) a(n) option from the company that made the software (Usually cost money),
a plug-in can be from the company that made the software or a third party to add abilities to the software.

What skill sets are required to write a firefox or chrome extensions? (like Adblock )

Does it require knowledge of C/C++ ?
Going to their developers suggests they are purely based on XML/XUL/Javascript.
Want to confirm before I decide to write one.
Chrome extensions are HTML, CSS, and JavaScript. Firefox extensions can be written with native, platform-specific C++ code, but the vast majority are XUL and JavaScript (and some XBL for the more advanced extensions).
Probably the most unusual aspect of Firefox extension code compared to web-oriented JavaScript is that Firefox uses XPCOM to organize its components internally. But it is a stretch to call familiarity with QueryInterface a "skill set."
Extensions in general (Firefox, Chrome, Safari) are all done using HTML + CSS + JS, and you can take advantage of HTML5 features which is pretty cool!
But, if you want to add C++, you can do that as well using NPAPI (Plugins). You can develop a NPAPI plugin and package it up with your extension. Remember, once you expose NPAPI, your extension will be tagged non secure because you just exposed your extension to native code. In the near future PPAPI will be a sandboxed way doing plugins.
So use HTML, JS, CSS (You can even make an abstraction layer to develop them all at once, since they are same technology, just the front end and APIs integration differs. So do not use C++ (NPAPI) unless there is absolutely no other way.

Resources