mirror of
https://github.com/apache/cordova-android.git
synced 2025-05-04 01:02:54 +08:00
CB-8510 Enforce that CordovaWebViewImpl is instantiated with an Engine
No reason to not enforce this.
This commit is contained in:
parent
eccf486162
commit
023ad9ddf8
@ -21,7 +21,6 @@ package org.apache.cordova;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.cordova.engine.SystemWebViewEngine;
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@ -189,8 +188,7 @@ public class CordovaActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected CordovaWebViewEngine makeWebViewEngine() {
|
protected CordovaWebViewEngine makeWebViewEngine() {
|
||||||
String className = preferences.getString("webview", SystemWebViewEngine.class.getCanonicalName());
|
return CordovaWebViewImpl.createEngine(this, preferences);
|
||||||
return CordovaWebViewImpl.createEngine(className, this, preferences);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CordovaInterfaceImpl makeCordovaInterface() {
|
protected CordovaInterfaceImpl makeCordovaInterface() {
|
||||||
|
@ -21,13 +21,11 @@ package org.apache.cordova;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
|
||||||
import android.webkit.WebChromeClient;
|
import android.webkit.WebChromeClient;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
@ -53,7 +51,7 @@ public class CordovaWebViewImpl implements CordovaWebView {
|
|||||||
// Public for backwards-compatibility :(
|
// Public for backwards-compatibility :(
|
||||||
public PluginManager pluginManager;
|
public PluginManager pluginManager;
|
||||||
|
|
||||||
protected CordovaWebViewEngine engine;
|
protected final CordovaWebViewEngine engine;
|
||||||
private CordovaInterface cordova;
|
private CordovaInterface cordova;
|
||||||
|
|
||||||
// Flag to track that a loadUrl timeout occurred
|
// Flag to track that a loadUrl timeout occurred
|
||||||
@ -75,7 +73,8 @@ public class CordovaWebViewImpl implements CordovaWebView {
|
|||||||
|
|
||||||
private Set<Integer> boundKeyCodes = new HashSet<Integer>();
|
private Set<Integer> boundKeyCodes = new HashSet<Integer>();
|
||||||
|
|
||||||
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 {
|
try {
|
||||||
Class<?> webViewClass = Class.forName(className);
|
Class<?> webViewClass = Class.forName(className);
|
||||||
Constructor<?> constructor = webViewClass.getConstructor(Context.class, CordovaPreferences.class);
|
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) {
|
public CordovaWebViewImpl(Context context, CordovaWebViewEngine cordovaWebViewEngine) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.engine = cordovaWebViewEngine;
|
this.engine = cordovaWebViewEngine;
|
||||||
@ -102,11 +98,6 @@ public class CordovaWebViewImpl implements CordovaWebView {
|
|||||||
if (this.cordova != null) {
|
if (this.cordova != null) {
|
||||||
throw new IllegalStateException();
|
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.cordova = cordova;
|
||||||
this.preferences = preferences;
|
this.preferences = preferences;
|
||||||
pluginManager = new PluginManager(this, this.cordova, pluginEntries);
|
pluginManager = new PluginManager(this, this.cordova, pluginEntries);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user