Browser Plugins development

1. definition

    a third party library that “plugs in” to the browser that can be embedded inside a web page using an <embed> tag or a <object> tag.
Like:
    Macromedia Flash
    Apple quicktime
    Landing encryption
How about firebug ?  it’s a extension,not a plugin.

 

Above reference: 

http://colonelpanic.net/2010/08/browser-plugins-vs-extensions-the-difference/


2.what you can do with a plugin?
    register one or more MIME types
    draw into a part of a browser window
    receive keyboard and mouse events
    obtain data from the network using URLs
    post data to URLs
    add hyperlinks or hotspots that link to new URLs
    draw into sections on an HTML page
    communicate with JavaScript/DOM from native code


Above reference: 

https://developer.mozilla.org/en-US/docs/Gecko_Plugin_API_Reference/Plug-in_Basics?redirectlocale=en-US&redirectslug=Gecko_Plugin_API_Reference%3APlug-in_Basics


3.what a plugin cannot do?

    Cannot create toolbars.
    Cannot affect browser menus.
In a word,it just a part of a web page.


Above reference: 

http://colonelpanic.net/2010/08/browser-plugins-vs-extensions-the-difference/


4.how plug-ins work?

 


STEP 1: the host browser loads the library corresponding to the MIME type expressed in the embed element tag.
STEP 2: the host browser calls the NP_Initialize function of the library and passes a reference to the public API of the browser (i.e. the NPNetscapeFuncs starting with NPN_ in the Mozilla documentation). The host browser also calls the NPP_New function in order to instantiate a "plugin instance".
STEP 3: the host browser calls the NP_GetValue function (with the variable NPPVpluginScriptableNPObject ) of the library. See step 4.
STEP 4: the plugin calls the NPN_CreateObject (through the reference provided in step 2) to instantiate a "scriptable NPObject". This object serves as proxy to the embed object declared on the source web page.
STEP 5: the web page can interact with the "scriptable object".
Above reference:
http://jldupont.blogspot.com/2009/11/notes-on-npapi-based-plugins.html (need agent)


5.development cost
Use C++ to build 
    MS Windows: .DLL (Dynamic Link Library) files
    Unix: .SO or .DSO (Shared Objects) files
    Mac OS X: PPC/x86/Universal loadable Mach-O bundle
Use NPAPI to interact with javascript.
    Javascript can judge whether a plugin has been installed.
    Javascript can get version of the plugin to judge whether to update.
    Javascript can get/set properties of NP object what plugin create.
    Javascript can call methods of NP object what plugin create.

In the same time,plugin can also control the elements of dom.


6. the demo of password encryption
    This demo reference in the npruntime Sample Plugin in Visual Studio:
https://developer.mozilla.org/en-US/docs/Compiling_The_npruntime_Sample_Plugin_in_Visual_Studio
there it teach you to establish the engineering in visual studio.
6.1 result screenshot

however,it cannot run on chrome

so,i found another example.

http://npapi-chrome-plugin-helloworld-example.googlecode.com/svn/trunk


after testing,it can run on firefox,chrome and opera.


Personal stage summary...



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值