diff options
| author | Derek Sollenberger <djsollen@google.com> | 2009-11-09 14:41:06 -0500 |
|---|---|---|
| committer | Derek Sollenberger <djsollen@google.com> | 2009-11-09 15:33:35 -0500 |
| commit | f2a6f2e2f867d06fd84e859cdc37c3293357a6ff (patch) | |
| tree | e4b0462ee7324be66c7df1419e060c16ff8dd805 /WebKit/android/plugins | |
| parent | de2098fbe71502df93eb3228ceaabd698aef0542 (diff) | |
| download | external_webkit-f2a6f2e2f867d06fd84e859cdc37c3293357a6ff.zip external_webkit-f2a6f2e2f867d06fd84e859cdc37c3293357a6ff.tar.gz external_webkit-f2a6f2e2f867d06fd84e859cdc37c3293357a6ff.tar.bz2 | |
Allow plugins to load java classes from their apk.
Relocate ANPSystemInterface into its own file and provide the
ability to call into java and load a plugin's java class from
their apk.
see http://b/2215696
Diffstat (limited to 'WebKit/android/plugins')
| -rw-r--r-- | WebKit/android/plugins/ANPSystemInterface.cpp | 28 | ||||
| -rw-r--r-- | WebKit/android/plugins/ANPSystem_npapi.h | 25 | ||||
| -rw-r--r-- | WebKit/android/plugins/ANPWindowInterface.cpp | 6 | ||||
| -rw-r--r-- | WebKit/android/plugins/android_npapi.h | 7 |
4 files changed, 55 insertions, 11 deletions
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 |
