summaryrefslogtreecommitdiffstats
path: root/WebKit/android
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/android')
-rw-r--r--WebKit/android/jni/WebViewCore.cpp28
-rw-r--r--WebKit/android/jni/WebViewCore.h3
-rw-r--r--WebKit/android/plugins/ANPSystemInterface.cpp28
-rw-r--r--WebKit/android/plugins/ANPSystem_npapi.h25
-rw-r--r--WebKit/android/plugins/ANPWindowInterface.cpp6
-rw-r--r--WebKit/android/plugins/android_npapi.h7
6 files changed, 84 insertions, 13 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 8f5427a..07f5d62 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -189,6 +189,7 @@ struct WebViewCore::JavaGlue {
jmethodID m_geolocationPermissionsShowPrompt;
jmethodID m_geolocationPermissionsHidePrompt;
jmethodID m_addMessageToConsole;
+ jmethodID m_getPluginClass;
jmethodID m_startFullScreenPluginActivity;
jmethodID m_createSurface;
jmethodID m_updateSurface;
@@ -267,6 +268,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
m_javaGlue->m_geolocationPermissionsShowPrompt = GetJMethod(env, clazz, "geolocationPermissionsShowPrompt", "(Ljava/lang/String;)V");
m_javaGlue->m_geolocationPermissionsHidePrompt = GetJMethod(env, clazz, "geolocationPermissionsHidePrompt", "()V");
m_javaGlue->m_addMessageToConsole = GetJMethod(env, clazz, "addMessageToConsole", "(Ljava/lang/String;ILjava/lang/String;)V");
+ m_javaGlue->m_getPluginClass = GetJMethod(env, clazz, "getPluginClass", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Class;");
m_javaGlue->m_startFullScreenPluginActivity = GetJMethod(env, clazz, "startFullScreenPluginActivity", "(Ljava/lang/String;Ljava/lang/String;I)V");
m_javaGlue->m_createSurface = GetJMethod(env, clazz, "createSurface", "(Ljava/lang/String;Ljava/lang/String;IIIII)Landroid/webkit/ViewManager$ChildView;");
m_javaGlue->m_updateSurface = GetJMethod(env, clazz, "updateSurface", "(Landroid/webkit/ViewManager$ChildView;IIII)V");
@@ -2425,18 +2427,40 @@ void WebViewCore::setBackgroundColor(SkColor c)
view->setBaseBackgroundColor(bcolor);
}
-void WebViewCore::startFullScreenPluginActivity(const char* libName,
- const char* className, NPP npp)
+jclass WebViewCore::getPluginClass(const char* libName, const char* className)
{
JNIEnv* env = JSC::Bindings::getJNIEnv();
+ AutoJObject obj = m_javaGlue->object(env);
+ // if it is called during DESTROY is handled, the real object of WebViewCore
+ // can be gone. Check before using it.
+ if (!obj.get())
+ return NULL;
jstring libString = env->NewStringUTF(libName);
+ jstring classString = env->NewStringUTF(className);
+ jobject pluginClass = env->CallObjectMethod(obj.get(),
+ m_javaGlue->m_getPluginClass,
+ libString, classString);
+ checkException(env);
+
+ if (pluginClass != NULL) {
+ return static_cast<jclass>(pluginClass);
+ } else {
+ return NULL;
+ }
+}
+
+void WebViewCore::startFullScreenPluginActivity(const char* libName,
+ const char* className, NPP npp)
+{
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
AutoJObject obj = m_javaGlue->object(env);
// if it is called during DESTROY is handled, the real object of WebViewCore
// can be gone. Check before using it.
if (!obj.get())
return;
+ jstring libString = env->NewStringUTF(libName);
jstring classString = env->NewStringUTF(className);
env->CallVoidMethod(obj.get(),
m_javaGlue->m_startFullScreenPluginActivity,
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index a7855b8..308ddfc 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -367,6 +367,9 @@ namespace android {
// Notify the Java side that webkit is requesting a keyboard
void requestKeyboard(bool);
+ // Generates a class loader that contains classes from the plugin's apk
+ jclass getPluginClass(const char* libName, const char* className);
+
// Creates a full screen surface (i.e. View on an Activity) for a plugin
void startFullScreenPluginActivity(const char* libName,
const char* className, NPP npp);
diff --git a/WebKit/android/plugins/ANPSystemInterface.cpp b/WebKit/android/plugins/ANPSystemInterface.cpp
index a5b9bcb..a7bf1cb 100644
--- a/WebKit/android/plugins/ANPSystemInterface.cpp
+++ b/WebKit/android/plugins/ANPSystemInterface.cpp
@@ -26,10 +26,16 @@
// must include config.h first for webkit to fiddle with new/delete
#include "config.h"
-#include "android_npapi.h"
#include "CString.h"
#include "JavaSharedClient.h"
#include "PluginClient.h"
+#include "PluginPackage.h"
+#include "PluginView.h"
+#include "PluginWidgetAndroid.h"
+#include "SkString.h"
+#include "WebViewCore.h"
+
+#include "ANPSystem_npapi.h"
static const char* gApplicationDataDir = NULL;
@@ -61,6 +67,25 @@ static const char* anp_getApplicationDataDirectory() {
return gApplicationDataDir;
}
+static WebCore::PluginView* pluginViewForInstance(NPP instance) {
+ if (instance && instance->ndata)
+ return static_cast<WebCore::PluginView*>(instance->ndata);
+ return PluginView::currentPluginView();
+}
+
+static jclass anp_loadJavaClass(NPP instance, const char* className) {
+ WebCore::PluginView* pluginView = pluginViewForInstance(instance);
+ PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget();
+
+ const WebCore::String& libName = pluginView->plugin()->path();
+ SkString skLibName;
+ skLibName.setUTF16(libName.characters(), libName.length());
+
+ jclass result;
+ result = pluginWidget->webViewCore()->getPluginClass(skLibName.c_str(), className);
+ return result;
+}
+
///////////////////////////////////////////////////////////////////////////////
#define ASSIGN(obj, name) (obj)->name = anp_##name
@@ -69,4 +94,5 @@ void ANPSystemInterfaceV0_Init(ANPInterface* v) {
ANPSystemInterfaceV0* i = reinterpret_cast<ANPSystemInterfaceV0*>(v);
ASSIGN(i, getApplicationDataDirectory);
+ ASSIGN(i, loadJavaClass);
}
diff --git a/WebKit/android/plugins/ANPSystem_npapi.h b/WebKit/android/plugins/ANPSystem_npapi.h
new file mode 100644
index 0000000..1507ef6
--- /dev/null
+++ b/WebKit/android/plugins/ANPSystem_npapi.h
@@ -0,0 +1,25 @@
+#ifndef ANPSystem_npapi_H
+#define ANPSystem_npapi_H
+
+#include "android_npapi.h"
+#include <jni.h>
+
+struct ANPSystemInterfaceV0 : ANPInterface {
+ /** Return the path name for the current Application's plugin data directory,
+ or NULL if not supported
+ */
+ const char* (*getApplicationDataDirectory)();
+
+ /** A helper function to load java classes from the plugin's apk. The
+ function looks for a class given the fully qualified and null terminated
+ string representing the className. For example,
+
+ const char* className = "com.android.mypackage.MyClass";
+
+ If the class cannot be found or there is a problem loading the class
+ NULL will be returned.
+ */
+ jclass (*loadJavaClass)(NPP instance, const char* className);
+};
+
+#endif //ANPSystem_npapi_H
diff --git a/WebKit/android/plugins/ANPWindowInterface.cpp b/WebKit/android/plugins/ANPWindowInterface.cpp
index 7a2f94c..3f4dff3 100644
--- a/WebKit/android/plugins/ANPWindowInterface.cpp
+++ b/WebKit/android/plugins/ANPWindowInterface.cpp
@@ -68,9 +68,9 @@ static void anp_clearVisibleRects(NPP instance) {
}
static void anp_showKeyboard(NPP instance, bool value) {
- ScrollView* scrollView = pluginViewForInstance(instance)->parent();
- android::WebViewCore* core = android::WebViewCore::getWebViewCore(scrollView);
- core->requestKeyboard(value);
+ PluginView* pluginView = pluginViewForInstance(instance);
+ PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget();
+ pluginWidget->webViewCore()->requestKeyboard(value);
}
static void anp_requestFullScreen(NPP instance) {
diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h
index 04f4ef6..9ab814f 100644
--- a/WebKit/android/plugins/android_npapi.h
+++ b/WebKit/android/plugins/android_npapi.h
@@ -764,13 +764,6 @@ struct ANPAudioTrackInterfaceV0 : ANPInterface {
bool (*isStopped)(ANPAudioTrack*);
};
-struct ANPSystemInterfaceV0 : ANPInterface {
- /** Return the path name for the current Application's plugin data directory,
- * or NULL if not supported
- */
- const char* (*getApplicationDataDirectory)();
-};
-
///////////////////////////////////////////////////////////////////////////////
// DEFINITION OF VALUES PASSED THROUGH NPP_HandleEvent