diff options
Diffstat (limited to 'WebKit/android/plugins')
-rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.cpp | 64 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.h | 8 | ||||
-rw-r--r-- | WebKit/android/plugins/android_npapi.h | 48 |
3 files changed, 77 insertions, 43 deletions
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp index cd7076d..5ee3e0f 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -54,7 +54,6 @@ PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view) m_hasFocus = false; m_isFullScreen = false; m_zoomLevel = 0; - m_webkitPlugin = NULL; m_embeddedView = NULL; } @@ -68,9 +67,6 @@ PluginWidgetAndroid::~PluginWidgetAndroid() { // cleanup any remaining JNI References JNIEnv* env = JSC::Bindings::getJNIEnv(); - if (m_webkitPlugin) { - env->DeleteGlobalRef(m_webkitPlugin); - } if (m_embeddedView) { env->DeleteGlobalRef(m_embeddedView); } @@ -83,19 +79,6 @@ void PluginWidgetAndroid::init(android::WebViewCore* core) { m_core->addPlugin(this); } -jobject PluginWidgetAndroid::getJavaPluginInstance() { - if (m_webkitPlugin == NULL && m_core != NULL) { - - jobject tempObj = m_core->createPluginJavaInstance(m_pluginView->plugin()->path(), - m_pluginView->instance()); - if (tempObj) { - JNIEnv* env = JSC::Bindings::getJNIEnv(); - m_webkitPlugin = env->NewGlobalRef(tempObj); - } - } - return m_webkitPlugin; -} - static SkBitmap::Config computeConfig(bool isTransparent) { return isTransparent ? SkBitmap::kARGB_8888_Config : SkBitmap::kRGB_565_Config; @@ -127,9 +110,18 @@ void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) { // if the surface does not exist then create a new surface } else if(!m_embeddedView) { - jobject tempObj = m_core->createSurface(getJavaPluginInstance(), - docPoint.x(), docPoint.y(), - window->width, window->height); + + WebCore::PluginPackage* pkg = m_pluginView->plugin(); + NPP instance = m_pluginView->instance(); + + + jobject pluginSurface; + pkg->pluginFuncs()->getvalue(instance, kJavaSurface_ANPGetValue, + static_cast<void*>(&pluginSurface)); + + jobject tempObj = m_core->addSurface(pluginSurface, + docPoint.x(), docPoint.y(), + window->width, window->height); if (tempObj) { JNIEnv* env = JSC::Bindings::getJNIEnv(); m_embeddedView = env->NewGlobalRef(tempObj); @@ -437,21 +429,47 @@ IntPoint PluginWidgetAndroid::frameToDocumentCoords(int frameX, int frameY) cons } void PluginWidgetAndroid::requestFullScreen() { - if (m_isFullScreen || !m_webkitPlugin) { + if (m_isFullScreen || !m_embeddedView) { return; } + // send event to notify plugin of full screen change + ANPEvent event; + SkANP::InitEvent(&event, kLifecycle_ANPEventType); + event.data.lifecycle.action = kEnterFullScreen_ANPLifecycleAction; + sendEvent(event); + + // remove the embedded surface from the view hierarchy + m_core->destroySurface(m_embeddedView); + + // add the full screen view IntPoint docPoint = frameToDocumentCoords(m_pluginWindow->x, m_pluginWindow->y); - m_core->showFullScreenPlugin(m_webkitPlugin, m_pluginView->instance(), + m_core->showFullScreenPlugin(m_embeddedView, m_pluginView->instance(), docPoint.x(), docPoint.y(), m_pluginWindow->width, m_pluginWindow->height); m_isFullScreen = true; } void PluginWidgetAndroid::exitFullScreen(bool pluginInitiated) { - if (m_isFullScreen && pluginInitiated) { + if (!m_isFullScreen || !m_embeddedView) { + return; + } + + // remove the full screen surface from the view hierarchy + if (pluginInitiated) { m_core->hideFullScreenPlugin(); } + // add the embedded view back + IntPoint docPoint = frameToDocumentCoords(m_pluginWindow->x, m_pluginWindow->y); + m_core->updateSurface(m_embeddedView, docPoint.x(), docPoint.y(), + m_pluginWindow->width, m_pluginWindow->height); + + // send event to notify plugin of full screen change + ANPEvent event; + SkANP::InitEvent(&event, kLifecycle_ANPEventType); + event.data.lifecycle.action = kExitFullScreen_ANPLifecycleAction; + sendEvent(event); + m_isFullScreen = false; } diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h index 3a76073..c7cccd1 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.h +++ b/WebKit/android/plugins/PluginWidgetAndroid.h @@ -125,13 +125,6 @@ struct PluginWidgetAndroid { */ void setVisibleRects(const ANPRectI rects[], int32_t count); - /** Returns a java object that implements the WebkitPlugin interface. The - implementation is located in the plugin's apk and is described in the - apk's manifest file. For each plugin instance in webkit there is at - most one instance of the java object associated with that plugin. - */ - jobject getJavaPluginInstance(); - /** Called when a plugin wishes to enter into full screen mode. It invokes the plugin's Java class (defined in the plugin's apk manifest), which is called asynchronously and provides a View to be displayed full screen. @@ -164,7 +157,6 @@ private: bool m_hasFocus; bool m_isFullScreen; float m_zoomLevel; - jobject m_webkitPlugin; jobject m_embeddedView; /* We limit the number of rectangles to minimize storage and ensure adequate diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h index 1111836..10f7ac9 100644 --- a/WebKit/android/plugins/android_npapi.h +++ b/WebKit/android/plugins/android_npapi.h @@ -120,14 +120,18 @@ typedef uint32_t ANPMatrixFlag; #define kSystemInterfaceV0_ANPGetValue ((NPNVariable)1010) #define kEventInterfaceV0_ANPGetValue ((NPNVariable)1011) -/** queries for which drawing model is desired (for the draw event) +/** queries for the drawing models supported on this device. - Should be called inside NPP_New(...) - - NPN_GetValue(inst, ANPSupportedDrawingModel_EnumValue, uint32_t* bits) + NPN_GetValue(inst, kSupportedDrawingModel_ANPGetValue, uint32_t* bits) */ #define kSupportedDrawingModel_ANPGetValue ((NPNVariable)2000) +/** queries for the context (android.content.Context) in which the plugin resides + + NPN_GetValue(inst, kJavaContext_ANPGetValue, jobject context) + */ +#define kJavaContext_ANPGetValue ((NPNVariable)2001) + /////////////////////////////////////////////////////////////////////////////// // NPN_SetValue @@ -147,7 +151,7 @@ enum ANPDrawingModels { /** Draw into a bitmap from the browser thread in response to a Draw event. NPWindow->window is reserved (ignore) */ - kBitmap_ANPDrawingModel = 0, + kBitmap_ANPDrawingModel = 1 << 0, /** Draw into a surface (e.g. raster, openGL, etc.) using the Java surface interface. When this model is used the browser will invoke the Java class specified in the plugin's apk manifest. From that class the browser @@ -168,7 +172,7 @@ enum ANPDrawingModels { unlock the surface in native code without making JNI calls to the Java surface object. */ - kSurface_ANPDrawingModel = 0x01, + kSurface_ANPDrawingModel = 1 << 1, }; typedef int32_t ANPDrawingModel; @@ -190,6 +194,16 @@ enum ANPEventFlag { }; typedef uint32_t ANPEventFlags; +/////////////////////////////////////////////////////////////////////////////// +// NPP_GetValue + +/** Requests that the plugin return a java surface to be displayed. This will + only be used if the plugin has choosen the kSurface_ANPDrawingModel. + + NPP_GetValue(inst, kJavaSurface_ANPGetValue, jobject surface) + */ +#define kJavaSurface_ANPGetValue ((NPPVariable)2000) + /////////////////////////////////////////////////////////////////////////////// // ANDROID INTERFACE DEFINITIONS @@ -833,28 +847,38 @@ enum ANPLifecycleActions { /** The web view containing this plugin has been paused. See documentation on the android activity lifecycle for more information. */ - kPause_ANPLifecycleAction = 0, + kPause_ANPLifecycleAction = 0, /** The web view containing this plugin has been resumed. See documentation on the android activity lifecycle for more information. */ - kResume_ANPLifecycleAction = 1, + kResume_ANPLifecycleAction = 1, /** The plugin has focus and is now the recipient of input events (e.g. key, touch, etc.) */ - kGainFocus_ANPLifecycleAction = 2, + kGainFocus_ANPLifecycleAction = 2, /** The plugin has lost focus and will not receive any input events until it regains focus. This event is always preceded by a GainFocus action. */ - kLoseFocus_ANPLifecycleAction = 3, + kLoseFocus_ANPLifecycleAction = 3, /** The browser is running low on available memory and is requesting that the plugin free any unused/inactive resources to prevent a performance degradation. */ - kFreeMemory_ANPLifecycleAction = 4, + kFreeMemory_ANPLifecycleAction = 4, /** The page has finished loading. This happens when the page's top level frame reports that it has completed loading. */ - kOnLoad_ANPLifecycleAction = 5, + kOnLoad_ANPLifecycleAction = 5, + /** The browser is honoring the plugin's request to go full screen. Upon + returning from this event the browser will resize the plugin's java + surface to full-screen coordinates. + */ + kEnterFullScreen_ANPLifecycleAction = 6, + /** The browser has exited from full screen mode. Immediately prior to + sending this event the browser has resized the plugin's java surface to + its original coordinates. + */ + kExitFullScreen_ANPLifecycleAction = 7, }; typedef uint32_t ANPLifecycleAction; |