I currently have a Firefox extension/plugin combo that works well, and was written with a combination of NPAPI (Firebreath) C++ code and Javascript. The extension works by defining a browser overlay (overlay.xul/overlay.js) that is loaded on every webpage via a script src="overlay.js" tag.
I need to adapt it for the upcoming changes for Firefox Webextensions and deprecation of XPCOM/XUL.
From what I understand, Webextensions will be primarily Javascript based. How would I be able to continue using the C++ portion of my extension? Note that porting the C++ NPAPI library to Javascript would be a non-starter for various reasons.
You have to use Native messaging to keep some part of your code in C++.
Be aware only the background script can directly communicate with your native/C++ code. But these messages can later be dispatched to your content scripts.
The communication between your C++ code and the background script is through the stdin/stdout.
There is a nice example between python script and web-extension on github: https://github.com/mdn/webextensions-examples/tree/master/native-messaging
Related
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.
I need to create an application for all versions of windows (XP, Vista, 7) without the need to install .NET or other 3rd party tools.
The application needs to download files asynchronous which are received in a json format and display a html page which can communicate with the application using javascript.
Is there a way to do that using an advanced IDE like Visual Studio but without requiring anything besides the application exe?
Are there any open source alternatives?
Thank you.
Look into the WebBrowser control. It's basically an Internet Explorer control you can embed in your application, and it has an interface that allows all sorts of manipulations. And given Internet Explorer is always a part of windows, it'll always be available without further installations.
Using the control requires some work. You can start by looking at Using the WebBrowser control, simplified. It uses MFC, but you can use the control with plain C++ as well.
The way I'd use it is push as many complicated tasks as possible to the browser control, and run them using JavaScript. A-synchronously downloading JSON is a pain in C++, but a no-brainer in JS. So you can basically divide your logic between C++ and JavaScript, and figure out some interface (by using, say, the DOM).
I don't get it. I'm a C/C++ programmer, what's the possible use of V8 for me? There are few examples and tutorials out there, and they all lack substance - I don't want to use another library to just add a couple of numbers or print something in a console window.
My question is: is there a real use for this technology, and if yes, then would be the scenario?
Also, can I do any part of GUI this way?
Help is appreciated.
"V8 is Google's open source JavaScript engine"
So the whole point is ability to write code in JavaScript, and run it quite fast (for an interpreted dynamic language). Google Chrome, which is written in C++, uses it for internal scripting — not only for regular web page scripting, but also for extension code. Let's consider this as a 'real use'.
So, if your app needs scripting, V8 may be good for you (JS is not a perfect language, but stil quite decent). As for GUI, you'll need to bind your GUI components with JS first, there's no built-in UI components (as Tk in TCL).
One real use of v8 is node.js. I hope that is good enough
Google V8 is a JavaScript engine.
I don't really think it is what you are looking for.
V8 is a JavaScript engine. The most common use for it is to allow users of your software to write scripts in simpler language than that your software was written with (C++ in your case).
It´s the same approach of Matlab, AutoCad, Microsoft Office, and etc.
If you write any kind of commercial application, you can expose some APIs and allow other developer to create addons for your applications without require them to know C/C++.
How about this for real use: You can use javascript as a debugging or testing tool - add a javascript console to your app and bind the commands of your GUI application to javascript functions, and you'll be able to test your UI application using javascript scripts. This way you'll reduce the amount of manual testing needed - manual testing would only have to verify that a correct command was excutes as a result of user action.
You can do GUI in javascript the same way that Qt is being used in Python and other scripting languages (see PyQt, and QtRuby, PerlQt, etc.). For how to create bindings for V8 you may want to check out this
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.
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.