Plugin file and functions

来源:互联网 发布:兄弟连php pdf 编辑:程序博客网 时间:2024/05/16 17:51

Plugin files


1. Npapi.h

declaration of NPP_XXX and NPN_XXX, also NPP and NPStream

in external/webkit/webcore/bridge/Npapi.h

2.Npfunctions.h

declaration function pointer of NPP_XXX and NPN_XXX, like NPP_XXXProcPtr and NPN_XXXProcPtr,

also define structor holding these pointers

in external/webkit/webcore/plugins/Npfunctions.h

3.Npapi.cpp

definition of all NPN_XXX functions, some are directly defined, some are calling function in

other files such as ANPSystemInterface.cpp/ANPPathInterface.cpp and so on.

4. platform porting

PluginPackage.h PluginPackage.cpp PluginPackageAndroid.cpp

PluginView.h PluginView.cpp PluginViewAndroid.cpp

ps:webkit platform adapting

A class with one .h file and two .cpp file

one cpp for generic function, the other cpp is for the specific Platform, like the examples above.


PluginFunction

1. function name

NPN_XXX, function defined in the browser and passed in to plugin.

NPP_XXX, function defined in the plugin and called by the browser.

2. NP_GetValue and NPP_GetValue

NP_GetValue is a dll function exposed to the caller, get discribtion of the plugin. 

NPP_GetValue is a function of plugin structure and will passed to the browser, called by the structure pointer, get object of the plugin.

3.NP_GetMIMEDescription,return the mime type discribtion

the return value may be many parts seperated by ";" and each part has three items seperated by":" which are

a. mimetype

b.file extentions

c.readable discribtion


4. the place "NPP_XXX" function is called

a.NP_Initialize¡ NP_GetValue called through "dlsym"

b.NPP_New newp PluginView::start

c.NPP_SetWindow setwindow PluginView::setNPWindowIfNeeded

d.NPP_NewStream newstream PluginStream::startStream

e.NPP_StreamAsFile asfile PluginStream::destroyStream

f.NPP_Write write PluginStream::deliverData()

g.NPP_HandleEvent event PluginWidgetAndroid::sendEvent

h.NPP_URLNotify urlnotify PluginView::performRequest

   PluginStream::destroyStream

i.NPP_GetValue getvalue PluginView::npObject..

g.NPP_SetValue setvalue PluginView::privateBrowsingStateChanged




others

a.

pluginViewForInstance(),get PluginView.
it was exposed in the "NPN" function, and registed to the NP function

b.
NP_Initialize,function in lib.
NP_Initialize(m_browserFuncs), initialize with browser function.

requestTimerFired(it's a timer, it will be created at PluginView's constructor function)

performRequest (working mode, put a request to a queue and start a timer 0, handle the request in the timer out fun)