diff options
| author | Android (Google) Code Review <android-gerrit@google.com> | 2009-11-09 12:42:35 -0800 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-11-09 12:42:35 -0800 |
| commit | 521123e0ed91348be81d3d754d3ee13ecf454ced (patch) | |
| tree | 5df752d10e77cb9d1974d53cd132d69967b5f518 /core/java | |
| parent | 9882f38584882461dbfef229e4fe316dacebd9c5 (diff) | |
| parent | 9e28c4ce666f1b8c5e5355d739e37480856ef509 (diff) | |
| download | frameworks_base-521123e0ed91348be81d3d754d3ee13ecf454ced.zip frameworks_base-521123e0ed91348be81d3d754d3ee13ecf454ced.tar.gz frameworks_base-521123e0ed91348be81d3d754d3ee13ecf454ced.tar.bz2 | |
Merge change I9e28c4ce into eclair-mr2
* changes:
Allow plugins to load java classes from their apk.
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/webkit/PluginUtil.java | 20 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewCore.java | 27 |
2 files changed, 38 insertions, 9 deletions
diff --git a/core/java/android/webkit/PluginUtil.java b/core/java/android/webkit/PluginUtil.java index 8fdbd67..33ccf9d 100644 --- a/core/java/android/webkit/PluginUtil.java +++ b/core/java/android/webkit/PluginUtil.java @@ -19,9 +19,6 @@ import android.content.Context; import android.content.pm.PackageManager.NameNotFoundException; import android.util.Log; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - class PluginUtil { private static final String LOGTAG = "PluginUtil"; @@ -35,12 +32,7 @@ class PluginUtil { static PluginStub getPluginStub(Context context, String packageName, String className) { try { - Context pluginContext = context.createPackageContext(packageName, - Context.CONTEXT_INCLUDE_CODE | - Context.CONTEXT_IGNORE_SECURITY); - ClassLoader pluginCL = pluginContext.getClassLoader(); - - Class<?> stubClass = pluginCL.loadClass(className); + Class<?> stubClass = getPluginClass(context, packageName, className); Object stubObject = stubClass.newInstance(); if (stubObject instanceof PluginStub) { @@ -56,4 +48,14 @@ class PluginUtil { } return null; } + + /* package */ + static Class<?> getPluginClass(Context context, String packageName, + String className) throws NameNotFoundException, ClassNotFoundException { + Context pluginContext = context.createPackageContext(packageName, + Context.CONTEXT_INCLUDE_CODE | + Context.CONTEXT_IGNORE_SECURITY); + ClassLoader pluginCL = pluginContext.getClassLoader(); + return pluginCL.loadClass(className); + } } diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index bfaa353..5460a47 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -18,6 +18,7 @@ package android.webkit; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager.NameNotFoundException; import android.database.Cursor; import android.graphics.Canvas; import android.graphics.DrawFilter; @@ -2167,6 +2168,32 @@ final class WebViewCore { } } + // called by JNI + private Class<?> getPluginClass(String libName, String clsName) { + + if (mWebView == null) { + return null; + } + + String pkgName = PluginManager.getInstance(null).getPluginsAPKName(libName); + if (pkgName == null) { + Log.w(LOGTAG, "Unable to resolve " + libName + " to a plugin APK"); + return null; + } + + Class<?> pluginClass = null; + try { + pluginClass = PluginUtil.getPluginClass(mWebView.getContext(), pkgName, clsName); + } catch (NameNotFoundException e) { + Log.e(LOGTAG, "Unable to find plugin classloader for the apk (" + pkgName + ")"); + } catch (ClassNotFoundException e) { + Log.e(LOGTAG, "Unable to find plugin class (" + clsName + + ") in the apk (" + pkgName + ")"); + } + + return pluginClass; + } + // called by JNI. PluginWidget function to launch an activity and overlays // the activity with the View provided by the plugin class. private void startFullScreenPluginActivity(String libName, String clsName, int npp) { |
