37

I'm curious as to the procedure for writing browser plugins for browsers like Chrome, Safari, and Opera. I'm thinking specifically of Windows here and would prefer working with C++.

Are there any tools or tutorials that detail the process?

Note: I am not referring to extensions or 'addons'. I'm referring to a plugin similar to how Flash and Adobe Reader have plugins to handle specific content-types.

Georg Fritzsche
  • 97,545
  • 26
  • 194
  • 236
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
  • 1
    A plugin similar to how Flash and Adobe Reader have plugins to handle specific content-types? – Ben S Apr 15 '10 at 21:20
  • 2
    As NPAPI is being phased out in Chrome, Pepper Plugin API (PPAPI), "a set of modifications to NPAPI to make plugins more portable and more secure", is the recommended replacement. I would like to reask this question now in context of PPAPI, https://en.wikipedia.org/wiki/Google_Native_Client. IIRC Firefox has not decided to support PPAPI but instead is working with plugin vendors to make similar or the same security modifications to NPAPI and plugin software. – 1.21 gigawatts Feb 14 '16 at 22:07

4 Answers4

44

As others point out, plugins for those browser are written using the NPAPI.

Note: Both Firefox and Chrome will default most plugins to click-to-play soon, with Chrome planning to phase out NPAPI entirely. NPAPI for new projects is discouraged at this point.

Resources for getting started with NPAPI:

The NPAPI itself is however relatively low-level, but there are tools and frameworks that can help you with it:

  • FireBreath - cross-browser, cross-platform frame-work for plugins
  • Nixysa - generate glue-code for NPAPI plugins
  • JUCE - application framework also providing support for plugins
  • QtBrowserPlugin - Qt based browser plugin framework
Georg Fritzsche
  • 97,545
  • 26
  • 194
  • 236
  • 1
    "npsimple"'s link seems to be incorrect. Is this the correct one: https://github.com/mikma/npsimple? – Rob W Jul 09 '12 at 09:01
  • @RobW Yes, the other link was completely irrelevant. It appears to be a website about a smartphone application called "Web of Cam". – Anderson Green Jan 05 '13 at 18:30
  • For the frameworks, could you comment on them about their features and simplicity? Which one do you recommend for a complex browser plugin? – Tyler Liu Mar 20 '13 at 09:44
  • @Tyler: It depends on your requirements. Generally i'd only consider Firebreath or writing it myself using the plain NPAPI. You most likely will want to use Firebreath to avoid the time investment required if you don't have browser plugin knowledge, especially for cross-platform projects and to also support IE from the same codebase. However, if the plugin is an important part of your project and you want fine-grained control (e.g. game engine plugins) you may want to directly write a plugin yourself. – Georg Fritzsche Mar 20 '13 at 13:33
  • @GeorgFritzsche Thank you for the kind reply. Actually I already built the plugin with Firebreath: http://slimtext.org. However I met some Chinese character encoding problem, which requires boost/locale which firebreath does not have. The author of firebreath has no plan to support i18n recently. so ... I will create an answer below to list some of my resource results. – Tyler Liu Mar 20 '13 at 15:34
  • @Tyler: You can still use boost.locale with Firebreath, right? It's just not in the libraries included by default there. – Georg Fritzsche Mar 20 '13 at 15:46
  • @GeorgFritzsche Have you ever get a FireBreath project built on Windows with external boost(and used some packages not included by FireBreath-boost project)? I just cannot get it done. I am not good at C++. I learned Cmake myself these days. But still without luch. See my answer below for more detail. – Tyler Liu Mar 20 '13 at 16:36
  • @GeorgFritzsche Please read this question: http://stackoverflow.com/questions/15457055/use-boost-locale-together-with-firebreath Today I got one of my friends who is an C++ expert to help me. So maybe I can get it done soon. Good luck to myself. – Tyler Liu Mar 20 '13 at 16:38
5

I investigated some frameworks listed by Georg, here is what I get:

  1. FireBreath. I think it is almost the best one available. You can create a cross platform browser plugin with FireBreath in a few days. I did find some cons: It does not support utf-8 characters on Windows. For example: if there are Chinese characters in a file name, you cannot read the content of that file. I believe that boost/locale can resolve this issue. But FireBreath does not contain boost/locale. Yes you can use external boost, but I spent several days configuring and tweaking and still cannot get it compiling on Windows. The author uses cmake to orgnize code and sub-projects. And he created a lot of bat or shell scripts and cmake macros, it is very hard to understand and configure. In short, if you want something that FireBreath currently does not provide, you will have a bad luck, it is very hard to add new features.

  2. Nixysa. I don't think that it is being actively developed. Documentation is poor. And from the comments of the wiki page: https://code.google.com/p/nixysa/wiki/HelloWorldWalkThru We can know that users could not get help at all and were having trouble get it running on Windows

  3. JUCE. It is not specially for creating browser plugins. It does NOT support Linux. The author thinks that NPAPI is going to die so he has no plan to support Linux or add new features.

  4. QtBrowserPlugin. You can not find it in documentation later than QT 4.5. In another word, it is not maintained(and removed from Qt 5.0)

I will update this answer once I find more.

Update: Chrome dropped NPAPI support. I think in the future it becomes harder and harder to write plugins in C++ because lacks of support from browsers.

Tyler Liu
  • 19,552
  • 11
  • 100
  • 84
2

Browsers like Netscape-based browsers, Chrome, Safari and Opera uses NPAPI plugin system, you can learn how to write NPAPI plugins in https://developer.mozilla.org/en/Plugins and http://code.google.com/chrome/extensions/npapi.html

Ming-Tang
  • 17,410
  • 8
  • 38
  • 76
0

If you know Qt then they have got some classes that makes it easier to implement browser plug-ins

Henrik Hansen
  • 2,180
  • 1
  • 14
  • 19