Question

Could someone write-up a step by step guide to developing a C++ based plugin for FireFox on Windows?

The links and examples on http://www.mozilla.org/projects/plugins/ are all old and inaccurate - the "NEW" link was added to the page in 2004.

The example could be anything, but I was thinking a plugin that lets JavaScript set the name and then displays "Hello {Name}". To show 2-way communication, it could have a property that returns the full salutation.

Though not as important, it would be nice if the plugin would work in Chrome too.

Was it helpful?

Solution

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 ]

OTHER TIPS

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!

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.

Check out Nixysa http://code.google.com/p/nixysa/. I tried to build the samples in the Mozilla SDK but they were hard to build. The Nixysa sample is easy to build. Plus the code is much neater than directly using NPAPI. The only drawback is that as of today Nixysa is not well documented. I have a Nixysa sample that implements callbacks if you want it (I do plan on submitting a patch to Nixysa when I get around to it).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top