In the previous article I mentioned two rendering modes of browser plug-ins: http://blog.csdn.net/qyqzj/archive/2010/06/14/5670816.aspx,
Recently, I downloaded the 2.2 source code package, observed the relevant code, and found that the loading process of the surface mode has changed.
First, the original 2.1 surface was loaded like this:
In short, plugin informs webkit of the Java class of its own View, and webkit obtains the View of the plug-in on the Java side.
By 2.2, the surface is loaded as follows:
By 2.2, the underlying layer of the Android browser plug-in has gained more rights to operate JAVA objects. If webkit needs to obtain the view of the plug-in, it will call NPP_GetValue (NPPVariable = kw.urface_anpgetvalue) (this is newly defined in android_npapi.h of 2.2 ). At this time, the Plugin side will call the loadJavaClass function in ANPSystemInterface to obtain the Class Object of the PluginStub. This function returns a jclass C/C ++ object (corresponding to the Class Object in Java ), then, the plug-in directly calls the constructor of this class (through JNI) on the Native side to obtain a new PluginStub object and return it to the browser as the result of NPP_GetValue. After the native side of the browser obtains this object, JNI calls the JAVA side (WebViewCore. addSurface function) to add the view to the page view, and the surface is loaded here.
For specific procedures, refer to Version 2.2's BrowserPlugin.