cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [3/5] android commit: CB-8386 Don't fallback on system webview if custom webview fails to construct
Date Fri, 30 Jan 2015 16:43:37 GMT
CB-8386 Don't fallback on system webview if custom webview fails to construct


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/137fe12c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/137fe12c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/137fe12c

Branch: refs/heads/master
Commit: 137fe12c43a00a11d8b163e2b634165e108420f2
Parents: a2fed20
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Fri Jan 30 11:03:56 2015 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Fri Jan 30 11:03:56 2015 -0500

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaActivity.java | 41 ++++++--------------
 1 file changed, 11 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/137fe12c/framework/src/org/apache/cordova/CordovaActivity.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java
index c4e1fa0..18bc43d 100755
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -217,40 +217,21 @@ public class CordovaActivity extends Activity implements CordovaInterface
{
     }
 
     /**
-     * Construct the default web view object.
+     * Construct the CordovaWebView object.
      *
-     * This is intended to be overridable by subclasses of CordovaIntent which
-     * require a more specialized web view.
+     * Override this to customize the webview that is used.
      */
     protected CordovaWebView makeWebView() {
-        String r = preferences.getString("webView", null);
-        CordovaWebView ret = null;
-        if (r != null) {
-            try {
-                Class<?> webViewClass = Class.forName(r);
-                Constructor<?> constructor = webViewClass.getConstructor(Context.class);
-                ret = (CordovaWebView) constructor.newInstance((Context)this);
-            } catch (ClassNotFoundException e) {
-                e.printStackTrace();
-            } catch (InstantiationException e) {
-                e.printStackTrace();
-            } catch (IllegalAccessException e) {
-                e.printStackTrace();
-            } catch (IllegalArgumentException e) {
-                e.printStackTrace();
-            } catch (InvocationTargetException e) {
-                e.printStackTrace();
-            } catch (NoSuchMethodException e) {
-                e.printStackTrace();
-            }
-        }
-
-        if (ret == null) {
-            // If all else fails, return a default WebView
-            ret = new AndroidWebView(this);
+        String webViewClassName = preferences.getString("webView", AndroidWebView.class.getCanonicalName());
+        try {
+            Class<?> webViewClass = Class.forName(webViewClassName);
+            Constructor<?> constructor = webViewClass.getConstructor(Context.class);
+            CordovaWebView ret = (CordovaWebView) constructor.newInstance((Context)this);
+            ret.init(this, pluginEntries, internalWhitelist, externalWhitelist, preferences);
+            return ret;
+        } catch (Exception e) {
+            throw new RuntimeException("Failed to create webview. ", e);
         }
-        ret.init(this, pluginEntries, internalWhitelist, externalWhitelist, preferences);
-        return ret;
     }
 
     /**


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message