How to write a C++ FireFox 3 plugin (not extension) on Windows? How to write a C++ FireFox 3 plugin (not extension) on Windows? windows windows

How to write a C++ FireFox 3 plugin (not extension) on Windows?


If you need something that works cross-browser (firefox and ie), you could look at firebreath: http://www.firebreath.org

For general "how to build a npapi plugin on windows" information, I have a few blog posts on the subject (linked to from some of the above sources as well)

http://colonelpanic.net/2009/03/building-a-firefox-plugin-part-one/

I really recommend firebreath, however, since we created it exactly for people who don't have time to do the months (literally) of research that it took us to figure out how it all works. If you don't want to use it as a basis for your plugin, though, you can still find a lot of good example code there.

should work on chrome, firefox, and safari on windows too! =]

good luck!


See also http://developer.mozilla.org/en/Plugins . And yes, NPAPI plugins should work in Google Chrome as well.

[edit 2015: Chrome removes support for NPAPI soon http://blog.chromium.org/2014/11/the-final-countdown-for-npapi.html ]


It's fairly simple to make a plugin using NPAPI. The key header files you'll need from the Gecko distribution are npapi.h and npupp.h. You'll export functions from your plugin DLL or shared library with the names NP_Initialize, NP_Shutdown, NP_GetMIMEDescription, and NP_GetValue, and you'll need to also fill in the symbol table given to you in the NP_Initialize call with handlers for all of the NPP functions.

The key functions to implement from that set are NPP_New and NPP_Destroy. Those define the lifecycle of a plugin instance. If you're going to handle a media file linked from an <object> or <embed>, you'll need to also deal with NPP_NewStream, NPP_WriteReady, NPP_Write, and NPP_DestroyStream as a way for your plugin to get the file's data from the browser. There's plenty more in the Gecko Plugin developer's guide.