cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject android commit: CB-7747 When both allow-navigation and allow-external are set, navigate instead of opening external
Date Fri, 13 Mar 2015 15:32:58 GMT
Repository: cordova-android
Updated Branches:
  refs/heads/master f764448cc -> 679069729


CB-7747 When both allow-navigation and allow-external are set, navigate instead of opening
external

Also: Move shouldOverrideUrlLoading logic into CordovaWebViewEngine.Client


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

Branch: refs/heads/master
Commit: 679069729cca68e55677c831f5ce9eaf4136ba36
Parents: f764448
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Fri Mar 13 11:31:16 2015 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Fri Mar 13 11:32:54 2015 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaWebViewEngine.java |  1 +
 .../src/org/apache/cordova/CordovaWebViewImpl.java   | 15 +++++++++++++++
 .../apache/cordova/engine/SystemWebViewClient.java   | 14 +-------------
 3 files changed, 17 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/67906972/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 d996a1c..b31c888 100644
--- a/framework/src/org/apache/cordova/CordovaWebViewEngine.java
+++ b/framework/src/org/apache/cordova/CordovaWebViewEngine.java
@@ -77,5 +77,6 @@ public interface CordovaWebViewEngine {
         void onReceivedError(int errorCode, String description, String failingUrl);
         void onPageFinishedLoading(String url);
         void onScrollChanged(int l, int t, int oldl, int oldt);
+        boolean onNavigationAttempt(String url);
     }
 }

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/67906972/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 3b5aecd..ed9d9da 100644
--- a/framework/src/org/apache/cordova/CordovaWebViewImpl.java
+++ b/framework/src/org/apache/cordova/CordovaWebViewImpl.java
@@ -581,5 +581,20 @@ public class CordovaWebViewImpl implements CordovaWebView {
             ScrollEvent myEvent = new ScrollEvent(l, t, oldl, oldt, getView());
             pluginManager.postMessage("onScrollChanged", myEvent);
         }
+
+        @Override
+        public boolean onNavigationAttempt(String url) {
+            // Give plugins the chance to handle the url
+            if (pluginManager.onOverrideUrlLoading(url)) {
+                return true;
+            } else if (pluginManager.shouldAllowNavigation(url)) {
+                return false;
+            } else if (pluginManager.shouldOpenExternalUrl(url)) {
+                showWebPage(url, true, false, null);
+                return true;
+            }
+            LOG.w(TAG, "Blocked (possibly sub-frame) navigation to non-allowed URL: " + url);
+            return true;
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/67906972/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 6aaac75..d176502 100755
--- a/framework/src/org/apache/cordova/engine/SystemWebViewClient.java
+++ b/framework/src/org/apache/cordova/engine/SystemWebViewClient.java
@@ -76,19 +76,7 @@ public class SystemWebViewClient extends WebViewClient {
      */
 	@Override
     public boolean shouldOverrideUrlLoading(WebView view, String 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;
+        return parentEngine.client.onNavigationAttempt(url);
     }
 
     /**


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


Mime
View raw message