From 023ad9ddf8b5a69ffe7f15fbcb83719aae77ffcc Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Tue, 3 Mar 2015 09:51:03 -0500 Subject: [PATCH] CB-8510 Enforce that CordovaWebViewImpl is instantiated with an Engine No reason to not enforce this. --- .../src/org/apache/cordova/CordovaActivity.java | 4 +--- .../org/apache/cordova/CordovaWebViewImpl.java | 15 +++------------ 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java index 79426264..5d0a5863 100755 --- a/framework/src/org/apache/cordova/CordovaActivity.java +++ b/framework/src/org/apache/cordova/CordovaActivity.java @@ -21,7 +21,6 @@ package org.apache.cordova; import java.util.ArrayList; import java.util.Locale; -import org.apache.cordova.engine.SystemWebViewEngine; import org.json.JSONException; import org.json.JSONObject; @@ -189,8 +188,7 @@ public class CordovaActivity extends Activity { } protected CordovaWebViewEngine makeWebViewEngine() { - String className = preferences.getString("webview", SystemWebViewEngine.class.getCanonicalName()); - return CordovaWebViewImpl.createEngine(className, this, preferences); + return CordovaWebViewImpl.createEngine(this, preferences); } protected CordovaInterfaceImpl makeCordovaInterface() { diff --git a/framework/src/org/apache/cordova/CordovaWebViewImpl.java b/framework/src/org/apache/cordova/CordovaWebViewImpl.java index 303f4e86..d6004408 100644 --- a/framework/src/org/apache/cordova/CordovaWebViewImpl.java +++ b/framework/src/org/apache/cordova/CordovaWebViewImpl.java @@ -21,13 +21,11 @@ package org.apache.cordova; import android.content.Context; import android.content.Intent; import android.net.Uri; -import android.os.Build; import android.util.Log; import android.view.Gravity; import android.view.KeyEvent; import android.view.View; import android.view.ViewGroup; -import android.view.inputmethod.InputMethodManager; import android.webkit.WebChromeClient; import android.widget.FrameLayout; @@ -53,7 +51,7 @@ public class CordovaWebViewImpl implements CordovaWebView { // Public for backwards-compatibility :( public PluginManager pluginManager; - protected CordovaWebViewEngine engine; + protected final CordovaWebViewEngine engine; private CordovaInterface cordova; // Flag to track that a loadUrl timeout occurred @@ -75,7 +73,8 @@ public class CordovaWebViewImpl implements CordovaWebView { private Set boundKeyCodes = new HashSet(); - public static CordovaWebViewEngine createEngine(String className, Context context, CordovaPreferences preferences) { + public static CordovaWebViewEngine createEngine(Context context, CordovaPreferences preferences) { + String className = preferences.getString("webview", SystemWebViewEngine.class.getCanonicalName()); try { Class webViewClass = Class.forName(className); Constructor constructor = webViewClass.getConstructor(Context.class, CordovaPreferences.class); @@ -85,9 +84,6 @@ public class CordovaWebViewImpl implements CordovaWebView { } } - public CordovaWebViewImpl(Context context) { - this(context, null); - } public CordovaWebViewImpl(Context context, CordovaWebViewEngine cordovaWebViewEngine) { this.context = context; this.engine = cordovaWebViewEngine; @@ -102,11 +98,6 @@ public class CordovaWebViewImpl implements CordovaWebView { if (this.cordova != null) { throw new IllegalStateException(); } - // Happens only when not using CordovaActivity. Usually, engine is set in the constructor. - if (engine == null) { - String className = preferences.getString("webView", SystemWebViewEngine.class.getCanonicalName()); - engine = createEngine(className, context, preferences); - } this.cordova = cordova; this.preferences = preferences; pluginManager = new PluginManager(this, this.cordova, pluginEntries);