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++.
A开发者_开发知识库re 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.
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:
- MDC plugin section
- three part NPAPI tutorial
- memory management in NPAPI
- npsimple - the "Hello World" of NPAPI plugins
- npapi-sdk - the source for the canonical NPAPI headers
- Mozillas test plugin - good for looking up specific NPAPI use cases
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
I investigated some frameworks listed by Georg, here is what I get:
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.
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
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.
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.
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
If you know Qt then they have got some classes that makes it easier to implement browser plug-ins
精彩评论