summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2013-04-05 17:17:25 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-04-05 17:17:25 +0000
commit4ac0462e7121c89f5cd76136fda7f14874dfd787 (patch)
tree90175258faca70d18f4d41b6d118b799696a44a6
parent65f420ec98f451cb17e55c6ace3f249d73b33399 (diff)
parentb0e35846b818bdf0db9cafe881a8a535116d596e (diff)
downloadframeworks_base-4ac0462e7121c89f5cd76136fda7f14874dfd787.zip
frameworks_base-4ac0462e7121c89f5cd76136fda7f14874dfd787.tar.gz
frameworks_base-4ac0462e7121c89f5cd76136fda7f14874dfd787.tar.bz2
Merge "Adding new Chomium-WebView property key, and deprecating old key." into jb-mr2-dev
-rw-r--r--core/java/android/webkit/WebViewFactory.java30
1 files changed, 25 insertions, 5 deletions
diff --git a/core/java/android/webkit/WebViewFactory.java b/core/java/android/webkit/WebViewFactory.java
index 18df0b1..00d87bd 100644
--- a/core/java/android/webkit/WebViewFactory.java
+++ b/core/java/android/webkit/WebViewFactory.java
@@ -25,8 +25,13 @@ import dalvik.system.PathClassLoader;
/**
* Top level factory, used creating all the main WebView implementation classes.
+ *
+ * @hide
*/
-class WebViewFactory {
+public final class WebViewFactory {
+ public static final String WEBVIEW_EXPERIMENTAL_PROPERTY = "persist.sys.webview.exp";
+ private static final String DEPRECATED_CHROMIUM_PROPERTY = "webview.use_chromium";
+
// Default Provider factory class name.
// TODO: When the Chromium powered WebView is ready, it should be the default factory class.
private static final String DEFAULT_WEBVIEW_FACTORY = "android.webkit.WebViewClassic$Factory";
@@ -43,16 +48,17 @@ class WebViewFactory {
private static WebViewFactoryProvider sProviderInstance;
private static final Object sProviderLock = new Object();
+ public static boolean isExperimentalWebViewAvailable() {
+ return Build.IS_DEBUGGABLE && (new java.io.File(CHROMIUM_WEBVIEW_JAR).exists());
+ }
+
static WebViewFactoryProvider getProvider() {
synchronized (sProviderLock) {
// For now the main purpose of this function (and the factory abstraction) is to keep
// us honest and minimize usage of WebViewClassic internals when binding the proxy.
if (sProviderInstance != null) return sProviderInstance;
- // For debug builds, we allow a system property to specify that we should use the
- // Chromium powered WebView. This enables us to switch between implementations
- // at runtime. For user (release) builds, don't allow this.
- if (Build.IS_DEBUGGABLE && SystemProperties.getBoolean("webview.use_chromium", false)) {
+ if (isExperimentalWebViewEnabled()) {
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
try {
sProviderInstance = loadChromiumProvider();
@@ -76,6 +82,20 @@ class WebViewFactory {
}
}
+ // For debug builds, we allow a system property to specify that we should use the
+ // experimtanl Chromium powered WebView. This enables us to switch between
+ // implementations at runtime. For user (release) builds, don't allow this.
+ private static boolean isExperimentalWebViewEnabled() {
+ if (!isExperimentalWebViewAvailable())
+ return false;
+ if (SystemProperties.getBoolean(DEPRECATED_CHROMIUM_PROPERTY, false)) {
+ Log.w(LOGTAG, String.format("The property %s has been deprecated. Please use %s.",
+ DEPRECATED_CHROMIUM_PROPERTY, WEBVIEW_EXPERIMENTAL_PROPERTY));
+ return true;
+ }
+ return SystemProperties.getBoolean(WEBVIEW_EXPERIMENTAL_PROPERTY, false);
+ }
+
// TODO: This allows us to have the legacy and Chromium WebView coexist for development
// and side-by-side testing. After transition, remove this when no longer required.
private static WebViewFactoryProvider loadChromiumProvider() {