Installing an NPAPI plugin for "calling C ++ code" is actually not very good. NPAPI plugins will be available for all websites, and not just for your add-on ... Are you sure that the material will not break if random sites access it in a way that you did not expect?
Anyway, there are various mechanisms for running binary code in Firefox today:
- js-ctypes is the least painful and recommended way. Basically, you would define a C API / ABI with which you can import and interact with Javascript.
- binary components of XPCOM. Basically, the entire Firefox backend is written or glued together using the XPCOM binary components. They can also be implemented in add-ons, although this is a pretty steep learning curve for getting started, and the documentation is scattered in many places and largely “incomplete”. Another huge drawback is that you need to recompile and re-test the modules for each new version of Firefox (not the case with js-ctypes).
Using the Add-on SDK will make things even more complicated, but you should use it already since you have been using NPAPI plugins right now.
I would recommend first determining if you really need the binaries in your add-on or the JS implementation (with modern features like typed arrays and possibly even asm.js via emscripten) and HTML5 (canvas, audio / video). And if not, if only lightweight js-ctypes were executed.
In addition, NPAPI plugins in Firefox no longer go away. While they will be available, but the user will need to enable them (click to play). Perhaps add-ons could get around this, and now they will allow them as needed. Therefore, there is no need to rush things.
source share