How to write a browser plugin?
Asked Answered
C

4

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.

Cle answered 15/4, 2010 at 21:19 Comment(2)
A plugin similar to how Flash and Adobe Reader have plugins to handle specific content-types?Chlorophyll
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, 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.Fungal
P
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
Prothalamium answered 23/9, 2010 at 17:52 Comment(8)
"npsimple"'s link seems to be incorrect. Is this the correct one: github.com/mikma/npsimple?Seedtime
@RobW Yes, the other link was completely irrelevant. It appears to be a website about a smartphone application called "Web of Cam".Edee
For the frameworks, could you comment on them about their features and simplicity? Which one do you recommend for a complex browser plugin?Westbound
@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.Prothalamium
@GeorgFritzsche Thank you for the kind reply. Actually I already built the plugin with Firebreath: 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.Westbound
@Tyler: You can still use boost.locale with Firebreath, right? It's just not in the libraries included by default there.Prothalamium
@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.Westbound
@GeorgFritzsche Please read this question: #15457555 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.Westbound
W
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.

Westbound answered 20/3, 2013 at 15:51 Comment(0)
V
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

Venepuncture answered 16/4, 2010 at 1:48 Comment(0)
G
0

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

Georg answered 27/4, 2010 at 14:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.