cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [3/4] android commit: CB-8510 Remove `shouldOverrideUrlLoading` from `CordovaWebViewEngine.Client`.
Date Tue, 03 Mar 2015 02:40:57 GMT
CB-8510 Remove `shouldOverrideUrlLoading` from `CordovaWebViewEngine.Client`.

It's logic that's pretty webview-specific, so it doesn't make sense to
share.


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

Branch: refs/heads/master
Commit: a6da46a00e3f4c5bb334077274e4ac4759295fc2
Parents: 747d2c9
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Mon Mar 2 20:43:45 2015 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Mon Mar 2 21:04:21 2015 -0500

----------------------------------------------------------------------
 .../apache/cordova/CordovaWebViewEngine.java    |  1 -
 .../org/apache/cordova/CordovaWebViewImpl.java  | 31 --------------------
 .../cordova/engine/SystemWebViewClient.java     | 16 ++++++++--
 3 files changed, 14 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a6da46a0/framework/src/org/apache/cordova/CordovaWebViewEngine.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebViewEngine.java b/framework/src/org/apache/cordova/CordovaWebViewEngine.java
index 8b62b1f..d996a1c 100644
--- a/framework/src/org/apache/cordova/CordovaWebViewEngine.java
+++ b/framework/src/org/apache/cordova/CordovaWebViewEngine.java
@@ -72,7 +72,6 @@ public interface CordovaWebViewEngine {
      */
     public interface Client {
         Boolean onDispatchKeyEvent(KeyEvent event);
-        boolean shouldOverrideUrlLoading(String url);
         void clearLoadTimeoutTimer();
         void onPageStarted(String newUrl);
         void onReceivedError(int errorCode, String description, String failingUrl);

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a6da46a0/framework/src/org/apache/cordova/CordovaWebViewImpl.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebViewImpl.java b/framework/src/org/apache/cordova/CordovaWebViewImpl.java
index 744bd44..303f4e8 100644
--- a/framework/src/org/apache/cordova/CordovaWebViewImpl.java
+++ b/framework/src/org/apache/cordova/CordovaWebViewImpl.java
@@ -588,37 +588,6 @@ public class CordovaWebViewImpl implements CordovaWebView {
         }
 
         @Override
-        public boolean shouldOverrideUrlLoading(String url) {
-            // Give plugins the chance to handle the url
-            if (pluginManager.shouldAllowNavigation(url)) {
-                // Allow internal navigation
-                return false;
-            } else if (pluginManager.shouldOpenExternalUrl(url)) {
-                // Do nothing other than what the plugins wanted.
-                // If any returned false, then the request was either blocked
-                // completely, or handled out-of-band by the plugin. If they all
-                // returned true, then we should open the URL here.
-                try {
-                    Intent intent = new Intent(Intent.ACTION_VIEW);
-                    intent.setData(Uri.parse(url));
-                    intent.addCategory(Intent.CATEGORY_BROWSABLE);
-                    intent.setComponent(null);
-                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
{
-                        intent.setSelector(null);
-                    }
-                    getContext().startActivity(intent);
-                    return true;
-                } catch (android.content.ActivityNotFoundException e) {
-                    Log.e(TAG, "Error loading url " + url, e);
-                }
-                return true;
-            }
-            LOG.w(TAG, "Blocked navigation because URL was not whitelisted: " + url);
-            // Block by default
-            return true;
-        }
-
-        @Override
         public void onScrollChanged(int l, int t, int oldl, int oldt) {
             // TODO: scrolling is perf-sensitive, so we'd probably be better to no use postMessage
             // here, and also not to create any new objects.

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a6da46a0/framework/src/org/apache/cordova/engine/SystemWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/engine/SystemWebViewClient.java b/framework/src/org/apache/cordova/engine/SystemWebViewClient.java
index 69dc2f2..6aaac75 100755
--- a/framework/src/org/apache/cordova/engine/SystemWebViewClient.java
+++ b/framework/src/org/apache/cordova/engine/SystemWebViewClient.java
@@ -76,9 +76,21 @@ public class SystemWebViewClient extends WebViewClient {
      */
 	@Override
     public boolean shouldOverrideUrlLoading(WebView view, String url) {
-        return parentEngine.client.shouldOverrideUrlLoading(url);
+        // Give plugins the chance to handle the url
+        if (parentEngine.pluginManager.onOverrideUrlLoading(url)) {
+            return true;
+        } else if (parentEngine.pluginManager.shouldOpenExternalUrl(url)) {
+            parentEngine.getCordovaWebView().showWebPage(url, true, false, null);
+            return true;
+        } else if (!parentEngine.pluginManager.shouldAllowNavigation(url)) {
+            // This blocks iframe navigations as well.
+            LOG.w(TAG, "Blocked (possibly sub-frame) navigation to non-allowed URL: " + url);
+            return true;
+        }
+
+        return false;
     }
-    
+
     /**
      * On received http auth request.
      * The method reacts on all registered authentication tokens. There is one and only one
authentication token for any host + realm combination


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


Mime
View raw message