Loading core/java/android/webkit/BrowserFrame.java +2 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,8 @@ class BrowserFrame extends Handler { CacheManager.init(context); // create CookieSyncManager with current Context CookieSyncManager.createInstance(context); // create PluginManager with current Context PluginManager.getInstance(context); } AssetManager am = context.getAssets(); nativeCreateFrame(w, am, proxy.getBackForwardList()); Loading core/java/android/webkit/JWebCoreJavaBridge.java +17 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,9 @@ final class JWebCoreJavaBridge extends Handler { private boolean mTimerPaused; private boolean mHasDeferredTimers; /* package */ static final int REFRESH_PLUGINS = 100; /** * Construct a new JWebCoreJavaBridge to interface with * WebCore timers and cookies. Loading Loading @@ -84,6 +87,11 @@ final class JWebCoreJavaBridge extends Handler { case FUNCPTR_MESSAGE: nativeServiceFuncPtrQueue(); break; case REFRESH_PLUGINS: nativeUpdatePluginDirectories(PluginManager.getInstance(null) .getPluginDirecoties(), ((Boolean) msg.obj) .booleanValue()); break; } } Loading Loading @@ -170,6 +178,13 @@ final class JWebCoreJavaBridge extends Handler { return CookieManager.getInstance().acceptCookie(); } /** * Returns an array of plugin directoies */ private String[] getPluginDirectories() { return PluginManager.getInstance(null).getPluginDirecoties(); } /** * setSharedTimer * @param timemillis The relative time when the timer should fire Loading Loading @@ -210,5 +225,7 @@ final class JWebCoreJavaBridge extends Handler { private native void nativeConstructor(); private native void nativeFinalize(); private native void sharedTimerFired(); private native void nativeUpdatePluginDirectories(String[] directories, boolean reload); public native void setNetworkOnLine(boolean online); } core/java/android/webkit/PluginManager.java 0 → 100644 +157 −0 Original line number Diff line number Diff line /* * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.webkit; import java.util.ArrayList; import java.util.List; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.content.Context; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.pm.Signature; import android.content.pm.PackageManager.NameNotFoundException; import android.util.Log; /** * Class for managing the relationship between the {@link WebView} and installed * plugins in the system. You can find this class through * {@link PluginManager#getInstance}. * * @hide pending API solidification */ public class PluginManager { /** * Service Action: A plugin wishes to be loaded in the WebView must provide * {@link android.content.IntentFilter IntentFilter} that accepts this * action in their AndroidManifest.xml. * <p> * TODO: we may change this to a new PLUGIN_ACTION if this is going to be * public. */ @SdkConstant(SdkConstantType.SERVICE_ACTION) public static final String PLUGIN_ACTION = "android.webkit.PLUGIN"; /** * A plugin wishes to be loaded in the WebView must provide this permission * in their AndroidManifest.xml. */ public static final String PLUGIN_PERMISSION = "android.webkit.permission.PLUGIN"; private static final String LOGTAG = "webkit"; private static PluginManager mInstance = null; private final Context mContext; private PluginManager(Context context) { mContext = context; } public static synchronized PluginManager getInstance(Context context) { if (mInstance == null) { if (context == null) { throw new IllegalStateException( "First call to PluginManager need a valid context."); } mInstance = new PluginManager(context); } return mInstance; } /** * Signal the WebCore thread to refresh its list of plugins. Use this if the * directory contents of one of the plugin directories has been modified and * needs its changes reflecting. May cause plugin load and/or unload. * * @param reloadOpenPages Set to true to reload all open pages. */ public void refreshPlugins(boolean reloadOpenPages) { BrowserFrame.sJavaBridge.obtainMessage( JWebCoreJavaBridge.REFRESH_PLUGINS, reloadOpenPages) .sendToTarget(); } String[] getPluginDirecoties() { ArrayList<String> directories = new ArrayList<String>(); PackageManager pm = mContext.getPackageManager(); List<ResolveInfo> plugins = pm.queryIntentServices(new Intent( PLUGIN_ACTION), PackageManager.GET_SERVICES); for (ResolveInfo info : plugins) { ServiceInfo serviceInfo = info.serviceInfo; if (serviceInfo == null) { Log.w(LOGTAG, "Ignore bad plugin"); continue; } PackageInfo pkgInfo; try { pkgInfo = pm.getPackageInfo(serviceInfo.packageName, PackageManager.GET_PERMISSIONS | PackageManager.GET_SIGNATURES); } catch (NameNotFoundException e) { Log.w(LOGTAG, "Cant find plugin: " + serviceInfo.packageName); continue; } if (pkgInfo == null) { continue; } String directory = pkgInfo.applicationInfo.dataDir + "/lib"; if (directories.contains(directory)) { continue; } String permissions[] = pkgInfo.requestedPermissions; if (permissions == null) { continue; } boolean permissionOk = false; for (String permit : permissions) { if (PLUGIN_PERMISSION.equals(permit)) { permissionOk = true; break; } } if (!permissionOk) { continue; } Signature signatures[] = pkgInfo.signatures; if (signatures == null) { continue; } boolean signatureMatch = false; for (Signature signature : signatures) { // TODO: check signature against Google provided one signatureMatch = true; break; } if (!signatureMatch) { continue; } directories.add(directory); } // hack for gears for now String gears = mContext.getDir("plugins", 0).getPath(); if (!directories.contains(gears)) { directories.add(gears); } return directories.toArray(new String[directories.size()]); } } core/java/android/webkit/WebSettings.java +3 −11 Original line number Diff line number Diff line Loading @@ -131,7 +131,6 @@ public class WebSettings { private String mUserAgent; private boolean mUseDefaultUserAgent; private String mAcceptLanguage; private String mPluginsPath = ""; private int mMinimumFontSize = 8; private int mMinimumLogicalFontSize = 8; private int mDefaultFontSize = 16; Loading Loading @@ -892,15 +891,9 @@ public class WebSettings { } /** * Set a custom path to plugins used by the WebView. The client * must ensure it exists before this call. * @param pluginsPath String path to the directory containing plugins. * TODO: need to add @Deprecated */ public synchronized void setPluginsPath(String pluginsPath) { if (pluginsPath != null && !pluginsPath.equals(mPluginsPath)) { mPluginsPath = pluginsPath; postSync(); } } /** Loading Loading @@ -1001,11 +994,10 @@ public class WebSettings { } /** * Return the current path used for plugins in the WebView. * @return The string path to the WebView plugins. * TODO: need to add @Deprecated */ public synchronized String getPluginsPath() { return mPluginsPath; return ""; } /** Loading core/java/android/webkit/WebView.java +2 −8 Original line number Diff line number Diff line Loading @@ -2318,16 +2318,10 @@ public class WebView extends AbsoluteLayout } /** * Signal the WebCore thread to refresh its list of plugins. Use * this if the directory contents of one of the plugin directories * has been modified and needs its changes reflecting. May cause * plugin load and/or unload. * @param reloadOpenPages Set to true to reload all open pages. * TODO: need to add @Deprecated */ public void refreshPlugins(boolean reloadOpenPages) { if (mWebViewCore != null) { mWebViewCore.sendMessage(EventHub.REFRESH_PLUGINS, reloadOpenPages); } PluginManager.getInstance(mContext).refreshPlugins(reloadOpenPages); } //------------------------------------------------------------------------- Loading Loading
core/java/android/webkit/BrowserFrame.java +2 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,8 @@ class BrowserFrame extends Handler { CacheManager.init(context); // create CookieSyncManager with current Context CookieSyncManager.createInstance(context); // create PluginManager with current Context PluginManager.getInstance(context); } AssetManager am = context.getAssets(); nativeCreateFrame(w, am, proxy.getBackForwardList()); Loading
core/java/android/webkit/JWebCoreJavaBridge.java +17 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,9 @@ final class JWebCoreJavaBridge extends Handler { private boolean mTimerPaused; private boolean mHasDeferredTimers; /* package */ static final int REFRESH_PLUGINS = 100; /** * Construct a new JWebCoreJavaBridge to interface with * WebCore timers and cookies. Loading Loading @@ -84,6 +87,11 @@ final class JWebCoreJavaBridge extends Handler { case FUNCPTR_MESSAGE: nativeServiceFuncPtrQueue(); break; case REFRESH_PLUGINS: nativeUpdatePluginDirectories(PluginManager.getInstance(null) .getPluginDirecoties(), ((Boolean) msg.obj) .booleanValue()); break; } } Loading Loading @@ -170,6 +178,13 @@ final class JWebCoreJavaBridge extends Handler { return CookieManager.getInstance().acceptCookie(); } /** * Returns an array of plugin directoies */ private String[] getPluginDirectories() { return PluginManager.getInstance(null).getPluginDirecoties(); } /** * setSharedTimer * @param timemillis The relative time when the timer should fire Loading Loading @@ -210,5 +225,7 @@ final class JWebCoreJavaBridge extends Handler { private native void nativeConstructor(); private native void nativeFinalize(); private native void sharedTimerFired(); private native void nativeUpdatePluginDirectories(String[] directories, boolean reload); public native void setNetworkOnLine(boolean online); }
core/java/android/webkit/PluginManager.java 0 → 100644 +157 −0 Original line number Diff line number Diff line /* * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.webkit; import java.util.ArrayList; import java.util.List; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.content.Context; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.pm.Signature; import android.content.pm.PackageManager.NameNotFoundException; import android.util.Log; /** * Class for managing the relationship between the {@link WebView} and installed * plugins in the system. You can find this class through * {@link PluginManager#getInstance}. * * @hide pending API solidification */ public class PluginManager { /** * Service Action: A plugin wishes to be loaded in the WebView must provide * {@link android.content.IntentFilter IntentFilter} that accepts this * action in their AndroidManifest.xml. * <p> * TODO: we may change this to a new PLUGIN_ACTION if this is going to be * public. */ @SdkConstant(SdkConstantType.SERVICE_ACTION) public static final String PLUGIN_ACTION = "android.webkit.PLUGIN"; /** * A plugin wishes to be loaded in the WebView must provide this permission * in their AndroidManifest.xml. */ public static final String PLUGIN_PERMISSION = "android.webkit.permission.PLUGIN"; private static final String LOGTAG = "webkit"; private static PluginManager mInstance = null; private final Context mContext; private PluginManager(Context context) { mContext = context; } public static synchronized PluginManager getInstance(Context context) { if (mInstance == null) { if (context == null) { throw new IllegalStateException( "First call to PluginManager need a valid context."); } mInstance = new PluginManager(context); } return mInstance; } /** * Signal the WebCore thread to refresh its list of plugins. Use this if the * directory contents of one of the plugin directories has been modified and * needs its changes reflecting. May cause plugin load and/or unload. * * @param reloadOpenPages Set to true to reload all open pages. */ public void refreshPlugins(boolean reloadOpenPages) { BrowserFrame.sJavaBridge.obtainMessage( JWebCoreJavaBridge.REFRESH_PLUGINS, reloadOpenPages) .sendToTarget(); } String[] getPluginDirecoties() { ArrayList<String> directories = new ArrayList<String>(); PackageManager pm = mContext.getPackageManager(); List<ResolveInfo> plugins = pm.queryIntentServices(new Intent( PLUGIN_ACTION), PackageManager.GET_SERVICES); for (ResolveInfo info : plugins) { ServiceInfo serviceInfo = info.serviceInfo; if (serviceInfo == null) { Log.w(LOGTAG, "Ignore bad plugin"); continue; } PackageInfo pkgInfo; try { pkgInfo = pm.getPackageInfo(serviceInfo.packageName, PackageManager.GET_PERMISSIONS | PackageManager.GET_SIGNATURES); } catch (NameNotFoundException e) { Log.w(LOGTAG, "Cant find plugin: " + serviceInfo.packageName); continue; } if (pkgInfo == null) { continue; } String directory = pkgInfo.applicationInfo.dataDir + "/lib"; if (directories.contains(directory)) { continue; } String permissions[] = pkgInfo.requestedPermissions; if (permissions == null) { continue; } boolean permissionOk = false; for (String permit : permissions) { if (PLUGIN_PERMISSION.equals(permit)) { permissionOk = true; break; } } if (!permissionOk) { continue; } Signature signatures[] = pkgInfo.signatures; if (signatures == null) { continue; } boolean signatureMatch = false; for (Signature signature : signatures) { // TODO: check signature against Google provided one signatureMatch = true; break; } if (!signatureMatch) { continue; } directories.add(directory); } // hack for gears for now String gears = mContext.getDir("plugins", 0).getPath(); if (!directories.contains(gears)) { directories.add(gears); } return directories.toArray(new String[directories.size()]); } }
core/java/android/webkit/WebSettings.java +3 −11 Original line number Diff line number Diff line Loading @@ -131,7 +131,6 @@ public class WebSettings { private String mUserAgent; private boolean mUseDefaultUserAgent; private String mAcceptLanguage; private String mPluginsPath = ""; private int mMinimumFontSize = 8; private int mMinimumLogicalFontSize = 8; private int mDefaultFontSize = 16; Loading Loading @@ -892,15 +891,9 @@ public class WebSettings { } /** * Set a custom path to plugins used by the WebView. The client * must ensure it exists before this call. * @param pluginsPath String path to the directory containing plugins. * TODO: need to add @Deprecated */ public synchronized void setPluginsPath(String pluginsPath) { if (pluginsPath != null && !pluginsPath.equals(mPluginsPath)) { mPluginsPath = pluginsPath; postSync(); } } /** Loading Loading @@ -1001,11 +994,10 @@ public class WebSettings { } /** * Return the current path used for plugins in the WebView. * @return The string path to the WebView plugins. * TODO: need to add @Deprecated */ public synchronized String getPluginsPath() { return mPluginsPath; return ""; } /** Loading
core/java/android/webkit/WebView.java +2 −8 Original line number Diff line number Diff line Loading @@ -2318,16 +2318,10 @@ public class WebView extends AbsoluteLayout } /** * Signal the WebCore thread to refresh its list of plugins. Use * this if the directory contents of one of the plugin directories * has been modified and needs its changes reflecting. May cause * plugin load and/or unload. * @param reloadOpenPages Set to true to reload all open pages. * TODO: need to add @Deprecated */ public void refreshPlugins(boolean reloadOpenPages) { if (mWebViewCore != null) { mWebViewCore.sendMessage(EventHub.REFRESH_PLUGINS, reloadOpenPages); } PluginManager.getInstance(mContext).refreshPlugins(reloadOpenPages); } //------------------------------------------------------------------------- Loading