You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2014/10/14 23:23:48 UTC

[01/11] android commit: Defer whitelist decisions to plugins

Repository: cordova-android
Updated Branches:
  refs/heads/unplug-whitelist [created] 7672bd10c


Defer whitelist decisions to plugins


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

Branch: refs/heads/unplug-whitelist
Commit: a3e8a777bc18b316ae77e26ce90b2b30661c4acf
Parents: 7ad16e5
Author: Ian Clelland <ic...@chromium.org>
Authored: Fri Oct 10 15:11:17 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Fri Oct 10 15:11:17 2014 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaPlugin.java   | 11 +++++++++
 .../org/apache/cordova/CordovaUriHelper.java    | 26 +++-----------------
 .../cordova/IceCreamCordovaWebViewClient.java   |  4 +--
 .../src/org/apache/cordova/PluginManager.java   | 16 ++++++++++++
 4 files changed, 32 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a3e8a777/framework/src/org/apache/cordova/CordovaPlugin.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaPlugin.java b/framework/src/org/apache/cordova/CordovaPlugin.java
index f467bdf..b811295 100644
--- a/framework/src/org/apache/cordova/CordovaPlugin.java
+++ b/framework/src/org/apache/cordova/CordovaPlugin.java
@@ -171,6 +171,17 @@ public class CordovaPlugin {
     }
 
     /**
+     * Hook for blocking the loading of external resources.
+     *
+     * This will be called when the WebView's shouldInterceptRequest wants to know whether to
+     * open a connection to an external resource. Return true to block the request. If all plugins
+     * return false, the request will proceed.
+     */
+    public boolean shouldBlockRequest(String url) {
+        return false;
+    }
+
+    /**
      * By specifying a <url-filter> in config.xml you can map a URL (using startsWith atm) to this method.
      *
      * @param url				The URL that is trying to be loaded in the Cordova webview.

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a3e8a777/framework/src/org/apache/cordova/CordovaUriHelper.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaUriHelper.java b/framework/src/org/apache/cordova/CordovaUriHelper.java
index 6c1c4fa..848fe52 100644
--- a/framework/src/org/apache/cordova/CordovaUriHelper.java
+++ b/framework/src/org/apache/cordova/CordovaUriHelper.java
@@ -54,33 +54,13 @@ public class CordovaUriHelper {
             // If any returned true, then the request was handled.
             return true;
         }
-        else if(url.startsWith("file://") | url.startsWith("data:"))
+        else if(url.startsWith("file://") || url.startsWith("data:"))
         {
             //This directory on WebKit/Blink based webviews contains SQLite databases!
             //DON'T CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING!
             return url.contains("app_webview");
         }
-        else if (appView.getWhitelist().isUrlWhiteListed(url)) {
-            // Allow internal navigation
-            return false;
-        }
-        else if (appView.getExternalWhitelist().isUrlWhiteListed(url))
-        {
-            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);
-                }
-                this.cordova.getActivity().startActivity(intent);
-                return true;
-            } catch (android.content.ActivityNotFoundException e) {
-                LOG.e(TAG, "Error loading url " + url, e);
-            }
-        }
-        // Intercept the request and do nothing with it -- block it
-        return true;
+        // Allow internal navigation
+        return false;
     }
 }

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a3e8a777/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
index 68f8741..f1f7689 100644
--- a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
@@ -72,8 +72,8 @@ public class IceCreamCordovaWebViewClient extends AndroidWebViewClient {
     }
 
     private boolean isUrlHarmful(String url) {
-        return ((url.startsWith("http:") || url.startsWith("https:")) && !appView.getWhitelist().isUrlWhiteListed(url))
-            || url.contains("app_webview");
+        return (appView.getPluginManager().shouldBlockRequest(url)) ||
+            ((url.startsWith("file://") || url.startsWith("data:")) && url.contains("app_webview"));
     }
 
     private static boolean needsKitKatContentUrlFix(Uri uri) {

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a3e8a777/framework/src/org/apache/cordova/PluginManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/PluginManager.java b/framework/src/org/apache/cordova/PluginManager.java
index bf69314..452a21d 100755
--- a/framework/src/org/apache/cordova/PluginManager.java
+++ b/framework/src/org/apache/cordova/PluginManager.java
@@ -254,6 +254,22 @@ public class PluginManager {
     }
 
     /**
+     * Called when the webview is going to request an external resource.
+     *
+     * @param url               The URL that is being requested.
+     * @return                  Return false to allow the URL to load, return true to prevent the URL from loading.
+     */
+    public boolean shouldBlockRequest(String url) {
+        for (PluginEntry entry : this.entryMap.values()) {
+            CordovaPlugin plugin = pluginMap.get(entry.service);
+            if (plugin != null && plugin.shouldBlockRequest(url)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
      * Called when the URL of the webview changes.
      *
      * @param url               The URL that is being changed to.


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


[07/11] android commit: Remove whitelists from WebView constructors

Posted by ia...@apache.org.
Remove whitelists from WebView constructors


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

Branch: refs/heads/unplug-whitelist
Commit: dd7aa72d85ef30669697dd73257f8929ac6b7672
Parents: 7530eee
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Oct 9 15:30:57 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Tue Oct 14 13:48:59 2014 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/AndroidWebView.java  | 3 ---
 framework/src/org/apache/cordova/CordovaActivity.java | 2 +-
 framework/src/org/apache/cordova/CordovaWebView.java  | 1 -
 3 files changed, 1 insertion(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/dd7aa72d/framework/src/org/apache/cordova/AndroidWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/AndroidWebView.java b/framework/src/org/apache/cordova/AndroidWebView.java
index fb9cda0..fbe7d2c 100755
--- a/framework/src/org/apache/cordova/AndroidWebView.java
+++ b/framework/src/org/apache/cordova/AndroidWebView.java
@@ -111,14 +111,11 @@ public class AndroidWebView extends WebView implements CordovaWebView {
     // Use two-phase init so that the control will work with XML layouts.
     @Override
     public void init(CordovaInterface cordova, List<PluginEntry> pluginEntries,
-            Whitelist internalWhitelist, Whitelist externalWhitelist,
             CordovaPreferences preferences) {
         if (this.cordova != null) {
             throw new IllegalStateException();
         }
         this.cordova = cordova;
-        this.internalWhitelist = internalWhitelist;
-        this.externalWhitelist = externalWhitelist;
         this.preferences = preferences;
 
         pluginManager = new PluginManager(this, this.cordova, pluginEntries);

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/dd7aa72d/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 e065a9b..0aea8de 100755
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -266,7 +266,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
             // If all else fails, return a default WebView
             ret = new AndroidWebView(this);
         }
-        ret.init(this, pluginEntries, internalWhitelist, externalWhitelist, preferences);
+        ret.init(this, pluginEntries, preferences);
         return ret;
     }
 

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/dd7aa72d/framework/src/org/apache/cordova/CordovaWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java
index 5184939..91ed494 100644
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -13,7 +13,6 @@ public interface CordovaWebView {
     public static final String CORDOVA_VERSION = "4.0.0-dev";
 
     void init(CordovaInterface cordova, List<PluginEntry> pluginEntries,
-            Whitelist internalWhitelist, Whitelist externalWhitelist,
             CordovaPreferences preferences);
 
     View getView();


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


[09/11] android commit: Remove whitelist objects

Posted by ia...@apache.org.
Remove whitelist objects


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

Branch: refs/heads/unplug-whitelist
Commit: 0fb106557767e4058916fd8c971d5f41b5574034
Parents: 204a3e6
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Oct 9 15:34:39 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Tue Oct 14 13:49:17 2014 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/AndroidWebView.java  | 2 --
 framework/src/org/apache/cordova/ConfigXmlParser.java | 2 --
 framework/src/org/apache/cordova/CordovaActivity.java | 4 ----
 3 files changed, 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/0fb10655/framework/src/org/apache/cordova/AndroidWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/AndroidWebView.java b/framework/src/org/apache/cordova/AndroidWebView.java
index fbe7d2c..4b8ad97 100755
--- a/framework/src/org/apache/cordova/AndroidWebView.java
+++ b/framework/src/org/apache/cordova/AndroidWebView.java
@@ -86,8 +86,6 @@ public class AndroidWebView extends WebView implements CordovaWebView {
     private WebChromeClient.CustomViewCallback mCustomViewCallback;
 
     private CordovaResourceApi resourceApi;
-    private Whitelist internalWhitelist;
-    private Whitelist externalWhitelist;
     private CordovaPreferences preferences;
     // The URL passed to loadUrl(), not necessarily the URL of the current page.
     String loadedUrl;

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/0fb10655/framework/src/org/apache/cordova/ConfigXmlParser.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/ConfigXmlParser.java b/framework/src/org/apache/cordova/ConfigXmlParser.java
index 8a2cfc5..1ea30b0 100644
--- a/framework/src/org/apache/cordova/ConfigXmlParser.java
+++ b/framework/src/org/apache/cordova/ConfigXmlParser.java
@@ -36,8 +36,6 @@ public class ConfigXmlParser {
 
     private String launchUrl = "file:///android_asset/www/index.html";
     private CordovaPreferences prefs = new CordovaPreferences();
-    private Whitelist internalWhitelist = new Whitelist();
-    private Whitelist externalWhitelist = new Whitelist();
     private ArrayList<PluginEntry> pluginEntries = new ArrayList<PluginEntry>(20);
 
     public CordovaPreferences getPreferences() {

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/0fb10655/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 0aea8de..8775cda 100755
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -123,8 +123,6 @@ public class CordovaActivity extends Activity implements CordovaInterface {
 
     // Read from config.xml:
     protected CordovaPreferences preferences;
-    protected Whitelist internalWhitelist;
-    protected Whitelist externalWhitelist;
     protected String launchUrl;
     protected ArrayList<PluginEntry> pluginEntries;
 
@@ -185,8 +183,6 @@ public class CordovaActivity extends Activity implements CordovaInterface {
         preferences = parser.getPreferences();
         preferences.setPreferencesBundle(getIntent().getExtras());
         preferences.copyIntoIntentExtras(this);
-        internalWhitelist = parser.getInternalWhitelist();
-        externalWhitelist = parser.getExternalWhitelist();
         launchUrl = parser.getLaunchUrl();
         pluginEntries = parser.getPluginEntries();
         Config.parser = parser;


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


[11/11] android commit: Allow Cordova to implement a default network policy

Posted by ia...@apache.org.
Allow Cordova to implement a default network policy


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

Branch: refs/heads/unplug-whitelist
Commit: 7672bd10c0389dbfc1a9c5815e3f6454c14f25ff
Parents: f36b5a1
Author: Ian Clelland <ic...@chromium.org>
Authored: Tue Oct 14 17:22:49 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Tue Oct 14 17:22:49 2014 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaPlugin.java   | 10 ++--
 .../org/apache/cordova/CordovaUriHelper.java    | 55 ++++++++++++++++----
 .../src/org/apache/cordova/PluginManager.java   | 52 +++++++++++++-----
 3 files changed, 89 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/7672bd10/framework/src/org/apache/cordova/CordovaPlugin.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaPlugin.java b/framework/src/org/apache/cordova/CordovaPlugin.java
index fb4ae99..1485dad 100644
--- a/framework/src/org/apache/cordova/CordovaPlugin.java
+++ b/framework/src/org/apache/cordova/CordovaPlugin.java
@@ -178,7 +178,7 @@ public class CordovaPlugin {
      * open a connection to an external resource. Return false to block the request. Only if
      * all plugins return true, then the request will proceed.
      */
-    public boolean shouldAllowRequest(String url) {
+    public Boolean shouldAllowRequest(String url) {
         return true;
     }
 
@@ -189,8 +189,8 @@ public class CordovaPlugin {
      * Return false to block the navigation. Only if all plugins return true, then the navigation
      * will proceed.
      */
-    public boolean shouldAllowNavigation(String url) {
-        return true;
+    public Boolean shouldAllowNavigation(String url) {
+        return null;
     }
 
     /**
@@ -200,8 +200,8 @@ public class CordovaPlugin {
      * to handle the URL. Return false to block the navigation. Only if all plugins return true,
      * then the URL be opened.
      */
-    public boolean shouldOpenExternalUrl(String url) {
-        return true;
+    public Boolean shouldOpenExternalUrl(String url) {
+        return null;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/7672bd10/framework/src/org/apache/cordova/CordovaUriHelper.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaUriHelper.java b/framework/src/org/apache/cordova/CordovaUriHelper.java
index b2be1b8..89e07a2 100644
--- a/framework/src/org/apache/cordova/CordovaUriHelper.java
+++ b/framework/src/org/apache/cordova/CordovaUriHelper.java
@@ -38,11 +38,54 @@ public class CordovaUriHelper {
         appView = webView;
         cordova = cdv;
     }
-    
+
+    /**
+     * Determine whether the webview should be allowed to navigate to a given URL.
+     *
+     * This method implements the default whitelist policy when no plugins override
+     * shouldAllowNavigation
+     */
+    public boolean shouldAllowNavigation(String url) {
+        Boolean pluginManagerAllowsNavigation = this.appView.getPluginManager().shouldAllowNavigation(url);
+        if (pluginManagerAllowsNavigation == null) {
+            // Default policy:
+            // Internal urls on file:// or data:// that do not contain "app_webview" are allowed for navigation
+            if(url.startsWith("file://") || url.startsWith("data:"))
+            {
+                //This directory on WebKit/Blink based webviews contains SQLite databases!
+                //DON'T CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING!
+                return !url.contains("app_webview");
+            }
+            return false;
+        }
+        return pluginManagerAllowsNavigation;
+    }
+
+    /**
+     * Determine whether the webview should be allowed to launch an intent for a given URL.
+     *
+     * This method implements the default whitelist policy when no plugins override
+     * shouldOpenExternalUrl
+     */
+    public boolean shouldOpenExternalUrl(String url) {
+        Boolean pluginManagerAllowsExternalUrl = this.appView.getPluginManager().shouldOpenExternalUrl(url);
+        if (pluginManagerAllowsExternalUrl == null) {
+            // Default policy:
+            // External URLs are not allowed
+            return false;
+        }
+        return pluginManagerAllowsExternalUrl;
+    }
+
     /**
      * Give the host application a chance to take over the control when a new url
      * is about to be loaded in the current WebView.
      *
+     * This method implements the default whitelist policy when no plugins override
+     * the whitelist methods:
+     *   Internal urls on file:// or data:// that do not contain "app_webview" are allowed for navigation
+     *   External urls are not allowed.
+     *
      * @param view          The WebView that is initiating the callback.
      * @param url           The url to be loaded.
      * @return              true to override, false for default behavior
@@ -50,11 +93,11 @@ public class CordovaUriHelper {
     @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
     public boolean shouldOverrideUrlLoading(String url) {
         // Give plugins the chance to handle the url
-        if (this.appView.getPluginManager().shouldAllowNavigation(url)) {
+        if (shouldAllowNavigation(url)) {
             // Allow internal navigation
             return false;
         }
-        if (this.appView.getPluginManager().shouldOpenExternalUrl(url)) {
+        if (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
@@ -74,12 +117,6 @@ public class CordovaUriHelper {
             }
             return true;
         }
-        if(url.startsWith("file://") || url.startsWith("data:"))
-        {
-            //This directory on WebKit/Blink based webviews contains SQLite databases!
-            //DON'T CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING!
-            return url.contains("app_webview");
-        }
         // Block by default
         return true;
     }

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/7672bd10/framework/src/org/apache/cordova/PluginManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/PluginManager.java b/framework/src/org/apache/cordova/PluginManager.java
index 4c3c5b6..ab75280 100755
--- a/framework/src/org/apache/cordova/PluginManager.java
+++ b/framework/src/org/apache/cordova/PluginManager.java
@@ -276,19 +276,31 @@ public class PluginManager {
      * Called when the webview is going to change the URL of the loaded content.
      *
      * This delegates to the installed plugins, which must all return true for
-     * this method to return true.
+     * this method to return true. A true result will allow the new page to load;
+     * a false result will prevent the page from loading.
      *
-     * @param url               The URL that is being requested.
-     * @return                  Return true to allow the URL to load, return false to prevent the URL from loading.
+     * @param url       The URL that is being requested.
+     * @return          Returns null if all plugins return null (the default).
+     *                  This indicates that the default policy should be followed.
+     *                  Otherwise, returns true if all plugins have returned true,
+     *                  or false if any returned false.
      */
-    public boolean shouldAllowNavigation(String url) {
+    public Boolean shouldAllowNavigation(String url) {
+        Boolean anyResponded = null;
         for (PluginEntry entry : this.entryMap.values()) {
             CordovaPlugin plugin = pluginMap.get(entry.service);
-            if (plugin != null && !plugin.shouldAllowNavigation(url)) {
-                return false;
+            if (plugin != null) {
+                Boolean result = plugin.shouldAllowNavigation(url);
+                if (result != null) {
+                    anyResponded = true;
+                    if (!result) {
+                        return false;
+                    }
+                }
             }
         }
-        return true;
+        // This will be true if all plugins allow the request, or null if no plugins override the method
+        return anyResponded;
     }
 
     /**
@@ -296,19 +308,31 @@ public class PluginManager {
      * an Intent for an URL.
      *
      * This delegates to the installed plugins, which must all return true for
-     * this method to return true.
+     * this method to return true. A true result will allow the URL to launch;
+     * a false result will prevent the URL from loading.
      *
-     * @param url               The URL that is being requested.
-     * @return                  Return true to allow the URL to load, return false to prevent the URL from loading.
+     * @param url       The URL that is being requested.
+     * @return          Returns null if all plugins return null (the default).
+     *                  This indicates that the default policy should be followed.
+     *                  Otherwise, returns true if all plugins have returned true,
+     *                  or false if any returned false.
      */
-    public boolean shouldOpenExternalUrl(String url) {
+    public Boolean shouldOpenExternalUrl(String url) {
+        Boolean anyResponded = null;
         for (PluginEntry entry : this.entryMap.values()) {
             CordovaPlugin plugin = pluginMap.get(entry.service);
-            if (plugin != null && !plugin.shouldOpenExternalUrl(url)) {
-                return false;
+            if (plugin != null) {
+                Boolean result = plugin.shouldOpenExternalUrl(url);
+                if (result != null) {
+                    anyResponded = true;
+                    if (!result) {
+                        return false;
+                    }
+                }
             }
         }
-        return true;
+        // This will be true if all plugins allow the request, or null if no plugins override the method
+        return anyResponded;
     }
 
     /**


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


[02/11] android commit: Refactor ConfigXmlParser to allow subclasses

Posted by ia...@apache.org.
Refactor ConfigXmlParser to allow subclasses


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

Branch: refs/heads/unplug-whitelist
Commit: a0cbee09980d5eb7e859b3d131412ba14a8b2291
Parents: a3e8a77
Author: Ian Clelland <ic...@chromium.org>
Authored: Tue Oct 14 13:46:36 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Tue Oct 14 13:46:36 2014 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/ConfigXmlParser.java | 114 ++++++++-----------
 1 file changed, 49 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a0cbee09/framework/src/org/apache/cordova/ConfigXmlParser.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/ConfigXmlParser.java b/framework/src/org/apache/cordova/ConfigXmlParser.java
index 0b1f529..3bea5ae 100644
--- a/framework/src/org/apache/cordova/ConfigXmlParser.java
+++ b/framework/src/org/apache/cordova/ConfigXmlParser.java
@@ -59,7 +59,7 @@ public class ConfigXmlParser {
     public String getLaunchUrl() {
         return launchUrl;
     }
-    
+
     public void parse(Activity action) {
         // First checking the class namespace for config.xml
         int id = action.getResources().getIdentifier("config", "xml", action.getClass().getPackage().getName());
@@ -74,78 +74,20 @@ public class ConfigXmlParser {
         parse(action.getResources().getXml(id));
     }
 
+    boolean insideFeature = false;
+    String service = "", pluginClass = "", paramType = "";
+    boolean onload = false;
+
     public void parse(XmlResourceParser xml) {
         int eventType = -1;
-        String service = "", pluginClass = "", paramType = "";
-        boolean onload = false;
-        boolean insideFeature = false;
-
-        // Add implicitly allowed URLs
-        internalWhitelist.addWhiteListEntry("file:///*", false);
-        internalWhitelist.addWhiteListEntry("content:///*", false);
-        internalWhitelist.addWhiteListEntry("data:*", false);
 
         while (eventType != XmlResourceParser.END_DOCUMENT) {
             if (eventType == XmlResourceParser.START_TAG) {
-                String strNode = xml.getName();
-                if (strNode.equals("feature")) {
-                    //Check for supported feature sets  aka. plugins (Accelerometer, Geolocation, etc)
-                    //Set the bit for reading params
-                    insideFeature = true;
-                    service = xml.getAttributeValue(null, "name");
-                }
-                else if (insideFeature && strNode.equals("param")) {
-                    paramType = xml.getAttributeValue(null, "name");
-                    if (paramType.equals("service")) // check if it is using the older service param
-                        service = xml.getAttributeValue(null, "value");
-                    else if (paramType.equals("package") || paramType.equals("android-package"))
-                        pluginClass = xml.getAttributeValue(null,"value");
-                    else if (paramType.equals("onload"))
-                        onload = "true".equals(xml.getAttributeValue(null, "value"));
-                }
-                else if (strNode.equals("access")) {
-                    String origin = xml.getAttributeValue(null, "origin");
-                    String subdomains = xml.getAttributeValue(null, "subdomains");
-                    boolean external = (xml.getAttributeValue(null, "launch-external") != null);
-                    if (origin != null) {
-                        if (external) {
-                            externalWhitelist.addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0));
-                        } else {
-                            if ("*".equals(origin)) {
-                                // Special-case * origin to mean http and https when used for internal
-                                // whitelist. This prevents external urls like sms: and geo: from being
-                                // handled internally.
-                                internalWhitelist.addWhiteListEntry("http://*/*", false);
-                                internalWhitelist.addWhiteListEntry("https://*/*", false);
-                            } else {
-                                internalWhitelist.addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0));
-                            }
-                        }
-                    }
-                }
-                else if (strNode.equals("preference")) {
-                    String name = xml.getAttributeValue(null, "name").toLowerCase(Locale.ENGLISH);
-                    String value = xml.getAttributeValue(null, "value");
-                    prefs.set(name, value);
-                }
-                else if (strNode.equals("content")) {
-                    String src = xml.getAttributeValue(null, "src");
-                    if (src != null) {
-                        setStartUrl(src);
-                    }
-                }
+                handleStartTag(xml);
             }
             else if (eventType == XmlResourceParser.END_TAG)
             {
-                String strNode = xml.getName();
-                if (strNode.equals("feature")) {
-                    pluginEntries.add(new PluginEntry(service, pluginClass, onload));
-
-                    service = "";
-                    pluginClass = "";
-                    insideFeature = false;
-                    onload = false;
-                }
+                handleEndTag(xml);
             }
             try {
                 eventType = xml.next();
@@ -157,6 +99,48 @@ public class ConfigXmlParser {
         }
     }
 
+    public void handleStartTag(XmlResourceParser xml) {
+        String strNode = xml.getName();
+        if (strNode.equals("feature")) {
+            //Check for supported feature sets  aka. plugins (Accelerometer, Geolocation, etc)
+            //Set the bit for reading params
+            insideFeature = true;
+            service = xml.getAttributeValue(null, "name");
+        }
+        else if (insideFeature && strNode.equals("param")) {
+            paramType = xml.getAttributeValue(null, "name");
+            if (paramType.equals("service")) // check if it is using the older service param
+                service = xml.getAttributeValue(null, "value");
+            else if (paramType.equals("package") || paramType.equals("android-package"))
+                pluginClass = xml.getAttributeValue(null,"value");
+            else if (paramType.equals("onload"))
+                onload = "true".equals(xml.getAttributeValue(null, "value"));
+        }
+        else if (strNode.equals("preference")) {
+            String name = xml.getAttributeValue(null, "name").toLowerCase(Locale.ENGLISH);
+            String value = xml.getAttributeValue(null, "value");
+            prefs.set(name, value);
+        }
+        else if (strNode.equals("content")) {
+            String src = xml.getAttributeValue(null, "src");
+            if (src != null) {
+                setStartUrl(src);
+            }
+        }
+    }
+
+    public void handleEndTag(XmlResourceParser xml) {
+        String strNode = xml.getName();
+        if (strNode.equals("feature")) {
+            pluginEntries.add(new PluginEntry(service, pluginClass, onload));
+
+            service = "";
+            pluginClass = "";
+            insideFeature = false;
+            onload = false;
+        }
+    }
+
     private void setStartUrl(String src) {
         Pattern schemeRegex = Pattern.compile("^[a-z-]+://");
         Matcher matcher = schemeRegex.matcher(src);


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


[05/11] android commit: Remove another unused Config method (Breaking Change)

Posted by ia...@apache.org.
Remove another unused Config method (Breaking Change)


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

Branch: refs/heads/unplug-whitelist
Commit: af1518d3c83f7b511d05a2e9840b60c43552d04f
Parents: 4c6777e
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Oct 9 15:23:07 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Tue Oct 14 13:48:27 2014 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/Config.java | 14 --------------
 1 file changed, 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/af1518d3/framework/src/org/apache/cordova/Config.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/Config.java b/framework/src/org/apache/cordova/Config.java
index 1df7fd2..f261b78 100644
--- a/framework/src/org/apache/cordova/Config.java
+++ b/framework/src/org/apache/cordova/Config.java
@@ -46,20 +46,6 @@ public class Config {
             parser = new ConfigXmlParser();
         }
     }
-    
-    /**
-     * Add entry to approved list of URLs (whitelist)
-     *
-     * @param origin        URL regular expression to allow
-     * @param subdomains    T=include all subdomains under origin
-     */
-    public static void addWhiteListEntry(String origin, boolean subdomains) {
-        if (parser == null) {
-            Log.e(TAG, "Config was not initialised. Did you forget to Config.init(this)?");
-            return;
-        }
-        parser.getInternalWhitelist().addWhiteListEntry(origin, subdomains);
-    }
 
     public static String getStartUrl() {
         if (parser == null) {


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


[06/11] android commit: Remove whitelist getters from WebView classes

Posted by ia...@apache.org.
Remove whitelist getters from WebView classes


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

Branch: refs/heads/unplug-whitelist
Commit: 7530eee8b6ebbed9765462effeaf8212d6aa3bbe
Parents: af1518d
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Oct 9 15:28:29 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Tue Oct 14 13:48:50 2014 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/AndroidWebView.java | 10 ----------
 framework/src/org/apache/cordova/CordovaWebView.java |  2 --
 2 files changed, 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/7530eee8/framework/src/org/apache/cordova/AndroidWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/AndroidWebView.java b/framework/src/org/apache/cordova/AndroidWebView.java
index 9817476..fb9cda0 100755
--- a/framework/src/org/apache/cordova/AndroidWebView.java
+++ b/framework/src/org/apache/cordova/AndroidWebView.java
@@ -749,16 +749,6 @@ public class AndroidWebView extends WebView implements CordovaWebView {
     }
 
     @Override
-    public Whitelist getWhitelist() {
-        return this.internalWhitelist;
-    }
-
-    @Override
-    public Whitelist getExternalWhitelist() {
-        return this.externalWhitelist;
-    }
-
-    @Override
     public CordovaPreferences getPreferences() {
         return preferences;
     }

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/7530eee8/framework/src/org/apache/cordova/CordovaWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java
index 47abfc0..5184939 100644
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -81,8 +81,6 @@ public interface CordovaWebView {
 
     PluginManager getPluginManager();
 
-    Whitelist getWhitelist();
-    Whitelist getExternalWhitelist();
     CordovaPreferences getPreferences();
     
     void onFilePickerResult(Uri uri);


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


[04/11] android commit: Continued (Breaking Changes)

Posted by ia...@apache.org.
Continued (Breaking Changes)


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

Branch: refs/heads/unplug-whitelist
Commit: 4c6777e420ec4f1825000178aacfa82fcced60a5
Parents: 01be1f2
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Oct 9 14:54:18 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Tue Oct 14 13:48:11 2014 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/Config.java | 8 --------
 1 file changed, 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4c6777e4/framework/src/org/apache/cordova/Config.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/Config.java b/framework/src/org/apache/cordova/Config.java
index d009037..1df7fd2 100644
--- a/framework/src/org/apache/cordova/Config.java
+++ b/framework/src/org/apache/cordova/Config.java
@@ -72,14 +72,6 @@ public class Config {
         return parser.getPreferences().getString("errorurl", null);
     }
 
-    public static Whitelist getWhitelist() {
-        return parser.getInternalWhitelist();
-    }
-
-    public static Whitelist getExternalWhitelist() {
-        return parser.getExternalWhitelist();
-    }
-
     public static List<PluginEntry> getPluginEntries() {
         return parser.getPluginEntries();
     }


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


[08/11] android commit: Remove whitelist getters from ConfigXmlParser

Posted by ia...@apache.org.
Remove whitelist getters from ConfigXmlParser


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

Branch: refs/heads/unplug-whitelist
Commit: 204a3e68ee641ca8871e6b4bc2a1ba541b740992
Parents: dd7aa72
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Oct 9 15:33:48 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Tue Oct 14 13:49:08 2014 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/ConfigXmlParser.java | 8 --------
 1 file changed, 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/204a3e68/framework/src/org/apache/cordova/ConfigXmlParser.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/ConfigXmlParser.java b/framework/src/org/apache/cordova/ConfigXmlParser.java
index 3bea5ae..8a2cfc5 100644
--- a/framework/src/org/apache/cordova/ConfigXmlParser.java
+++ b/framework/src/org/apache/cordova/ConfigXmlParser.java
@@ -40,14 +40,6 @@ public class ConfigXmlParser {
     private Whitelist externalWhitelist = new Whitelist();
     private ArrayList<PluginEntry> pluginEntries = new ArrayList<PluginEntry>(20);
 
-    public Whitelist getInternalWhitelist() {
-        return internalWhitelist;
-    }
-
-    public Whitelist getExternalWhitelist() {
-        return externalWhitelist;
-    }
-
     public CordovaPreferences getPreferences() {
         return prefs;
     }


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


[03/11] android commit: Remove unused Config methods (Breaking Change)

Posted by ia...@apache.org.
Remove unused Config methods (Breaking Change)


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

Branch: refs/heads/unplug-whitelist
Commit: 01be1f27bed8171a77792b7cbc1c269d5a7d1b5f
Parents: a0cbee0
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Oct 9 14:44:09 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Tue Oct 14 13:48:01 2014 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/Config.java | 28 -----------------------
 1 file changed, 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/01be1f27/framework/src/org/apache/cordova/Config.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/Config.java b/framework/src/org/apache/cordova/Config.java
index f13292c..d009037 100644
--- a/framework/src/org/apache/cordova/Config.java
+++ b/framework/src/org/apache/cordova/Config.java
@@ -61,34 +61,6 @@ public class Config {
         parser.getInternalWhitelist().addWhiteListEntry(origin, subdomains);
     }
 
-    /**
-     * Determine if URL is in approved list of URLs to load.
-     *
-     * @param url
-     * @return true if whitelisted
-     */
-    public static boolean isUrlWhiteListed(String url) {
-        if (parser == null) {
-            Log.e(TAG, "Config was not initialised. Did you forget to Config.init(this)?");
-            return false;
-        }
-        return parser.getInternalWhitelist().isUrlWhiteListed(url);
-    }
-
-    /**
-     * Determine if URL is in approved list of URLs to launch external applications.
-     *
-     * @param url
-     * @return true if whitelisted
-     */
-    public static boolean isUrlExternallyWhiteListed(String url) {
-        if (parser == null) {
-            Log.e(TAG, "Config was not initialised. Did you forget to Config.init(this)?");
-            return false;
-        }
-        return parser.getExternalWhitelist().isUrlWhiteListed(url);
-    }
-
     public static String getStartUrl() {
         if (parser == null) {
             return "file:///android_asset/www/index.html";


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


[10/11] android commit: Switch to Whitelist / Block-by-default.

Posted by ia...@apache.org.
Switch to Whitelist / Block-by-default.

Update Whitelist protocol to include three methods:
  shouldAllowResource
  shouldAllowNavigation
  shouldOpenExternalUrl


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

Branch: refs/heads/unplug-whitelist
Commit: f36b5a1db9f0570d4dd47f938fc0b51fc7b35ccb
Parents: 0fb1065
Author: Ian Clelland <ic...@chromium.org>
Authored: Tue Oct 14 16:12:18 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Tue Oct 14 16:12:18 2014 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/AndroidWebView.java  |  4 +-
 .../src/org/apache/cordova/CordovaActivity.java |  7 ++-
 .../src/org/apache/cordova/CordovaPlugin.java   | 43 ++++++++++++----
 .../org/apache/cordova/CordovaUriHelper.java    | 30 +++++++++--
 .../cordova/IceCreamCordovaWebViewClient.java   |  2 +-
 .../src/org/apache/cordova/PluginManager.java   | 52 ++++++++++++++++++--
 6 files changed, 114 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/f36b5a1d/framework/src/org/apache/cordova/AndroidWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/AndroidWebView.java b/framework/src/org/apache/cordova/AndroidWebView.java
index 4b8ad97..729e25f 100755
--- a/framework/src/org/apache/cordova/AndroidWebView.java
+++ b/framework/src/org/apache/cordova/AndroidWebView.java
@@ -349,7 +349,7 @@ public class AndroidWebView extends WebView implements CordovaWebView {
         if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) {
             LOG.d(TAG, ">>> loadUrlNow()");
         }
-        if (url.startsWith("file://") || url.startsWith("javascript:") || internalWhitelist.isUrlWhiteListed(url)) {
+        if (url.startsWith("file://") || url.startsWith("javascript:") || pluginManager.shouldAllowNavigation(url)) {
             super.loadUrl(url);
         }
     }
@@ -424,7 +424,7 @@ public class AndroidWebView extends WebView implements CordovaWebView {
         if (!openExternal) {
 
             // Make sure url is in whitelist
-            if (url.startsWith("file://") || internalWhitelist.isUrlWhiteListed(url)) {
+            if (url.startsWith("file://") || pluginManager.shouldAllowNavigation(url)) {
                 // TODO: What about params?
                 // Load new URL
                 loadUrlIntoView(url, true);

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/f36b5a1d/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 8775cda..73dcdba 100755
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -550,7 +550,12 @@ public class CordovaActivity extends Activity implements CordovaInterface {
 
         // If errorUrl specified, then load it
         final String errorUrl = preferences.getString("errorUrl", null);
-        if ((errorUrl != null) && (errorUrl.startsWith("file://") || internalWhitelist.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {
+        if ((errorUrl != null) &&
+            (
+                errorUrl.startsWith("file://") ||
+                (appView != null && appView.getPluginManager().shouldAllowNavigation(errorUrl))
+            ) && (!failingUrl.equals(errorUrl))
+           ) {
             // Load URL on UI thread
             me.runOnUiThread(new Runnable() {
                 public void run() {

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/f36b5a1d/framework/src/org/apache/cordova/CordovaPlugin.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaPlugin.java b/framework/src/org/apache/cordova/CordovaPlugin.java
index b811295..fb4ae99 100644
--- a/framework/src/org/apache/cordova/CordovaPlugin.java
+++ b/framework/src/org/apache/cordova/CordovaPlugin.java
@@ -162,10 +162,11 @@ public class CordovaPlugin {
      * Called when an activity you launched exits, giving you the requestCode you started it with,
      * the resultCode it returned, and any additional data from it.
      *
-     * @param requestCode		The request code originally supplied to startActivityForResult(),
-     * 							allowing you to identify who this result came from.
-     * @param resultCode		The integer result code returned by the child activity through its setResult().
-     * @param intent				An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
+     * @param requestCode   The request code originally supplied to startActivityForResult(),
+     *                      allowing you to identify who this result came from.
+     * @param resultCode    The integer result code returned by the child activity through its setResult().
+     * @param intent        An Intent, which can return result data to the caller (various data can be
+     *                      attached to Intent "extras").
      */
     public void onActivityResult(int requestCode, int resultCode, Intent intent) {
     }
@@ -174,18 +175,40 @@ public class CordovaPlugin {
      * Hook for blocking the loading of external resources.
      *
      * This will be called when the WebView's shouldInterceptRequest wants to know whether to
-     * open a connection to an external resource. Return true to block the request. If all plugins
-     * return false, the request will proceed.
+     * open a connection to an external resource. Return false to block the request. Only if
+     * all plugins return true, then the request will proceed.
      */
-    public boolean shouldBlockRequest(String url) {
-        return false;
+    public boolean shouldAllowRequest(String url) {
+        return true;
+    }
+
+    /**
+     * Hook for blocking navigation by the Cordova WebView
+     *
+     * This will be called when the WebView's needs to know whether to navigate to a new page.
+     * Return false to block the navigation. Only if all plugins return true, then the navigation
+     * will proceed.
+     */
+    public boolean shouldAllowNavigation(String url) {
+        return true;
+    }
+
+    /**
+     * Hook for blocking the launching of Intents by the Cordova application
+     *
+     * This will be called when the WebView will not navigate to a page, but could launch an intent
+     * to handle the URL. Return false to block the navigation. Only if all plugins return true,
+     * then the URL be opened.
+     */
+    public boolean shouldOpenExternalUrl(String url) {
+        return true;
     }
 
     /**
      * By specifying a <url-filter> in config.xml you can map a URL (using startsWith atm) to this method.
      *
-     * @param url				The URL that is trying to be loaded in the Cordova webview.
-     * @return					Return true to prevent the URL from loading. Default is false.
+     * @param url           The URL that is trying to be loaded in the Cordova webview.
+     * @return              Return true to prevent the URL from loading. Default is false.
      */
     public boolean onOverrideUrlLoading(String url) {
         return false;

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/f36b5a1d/framework/src/org/apache/cordova/CordovaUriHelper.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaUriHelper.java b/framework/src/org/apache/cordova/CordovaUriHelper.java
index 848fe52..b2be1b8 100644
--- a/framework/src/org/apache/cordova/CordovaUriHelper.java
+++ b/framework/src/org/apache/cordova/CordovaUriHelper.java
@@ -23,6 +23,7 @@ import android.annotation.TargetApi;
 import android.content.Intent;
 import android.net.Uri;
 import android.os.Build;
+import android.util.Log;
 import android.webkit.WebView;
 
 public class CordovaUriHelper {
@@ -49,18 +50,37 @@ public class CordovaUriHelper {
     @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
     public boolean shouldOverrideUrlLoading(String url) {
         // Give plugins the chance to handle the url
-        if (this.appView.getPluginManager().onOverrideUrlLoading(url)) {
+        if (this.appView.getPluginManager().shouldAllowNavigation(url)) {
+            // Allow internal navigation
+            return false;
+        }
+        if (this.appView.getPluginManager().shouldOpenExternalUrl(url)) {
             // Do nothing other than what the plugins wanted.
-            // If any returned true, then the request was handled.
+            // 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);
+                }
+                this.cordova.getActivity().startActivity(intent);
+                return true;
+            } catch (android.content.ActivityNotFoundException e) {
+                Log.e(TAG, "Error loading url " + url, e);
+            }
             return true;
         }
-        else if(url.startsWith("file://") || url.startsWith("data:"))
+        if(url.startsWith("file://") || url.startsWith("data:"))
         {
             //This directory on WebKit/Blink based webviews contains SQLite databases!
             //DON'T CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING!
             return url.contains("app_webview");
         }
-        // Allow internal navigation
-        return false;
+        // Block by default
+        return true;
     }
 }

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/f36b5a1d/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
index f1f7689..62368df 100644
--- a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
@@ -72,7 +72,7 @@ public class IceCreamCordovaWebViewClient extends AndroidWebViewClient {
     }
 
     private boolean isUrlHarmful(String url) {
-        return (appView.getPluginManager().shouldBlockRequest(url)) ||
+        return (!appView.getPluginManager().shouldAllowRequest(url)) ||
             ((url.startsWith("file://") || url.startsWith("data:")) && url.contains("app_webview"));
     }
 

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/f36b5a1d/framework/src/org/apache/cordova/PluginManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/PluginManager.java b/framework/src/org/apache/cordova/PluginManager.java
index 452a21d..4c3c5b6 100755
--- a/framework/src/org/apache/cordova/PluginManager.java
+++ b/framework/src/org/apache/cordova/PluginManager.java
@@ -256,17 +256,59 @@ public class PluginManager {
     /**
      * Called when the webview is going to request an external resource.
      *
+     * This delegates to the installed plugins, which must all return true for
+     * this method to return true.
+     *
      * @param url               The URL that is being requested.
-     * @return                  Return false to allow the URL to load, return true to prevent the URL from loading.
+     * @return                  Return true to allow the resource to load, return false to prevent the resource from loading.
      */
-    public boolean shouldBlockRequest(String url) {
+    public boolean shouldAllowRequest(String url) {
         for (PluginEntry entry : this.entryMap.values()) {
             CordovaPlugin plugin = pluginMap.get(entry.service);
-            if (plugin != null && plugin.shouldBlockRequest(url)) {
-                return true;
+            if (plugin != null && !plugin.shouldAllowRequest(url)) {
+                return false;
             }
         }
-        return false;
+        return true;
+    }
+
+    /**
+     * Called when the webview is going to change the URL of the loaded content.
+     *
+     * This delegates to the installed plugins, which must all return true for
+     * this method to return true.
+     *
+     * @param url               The URL that is being requested.
+     * @return                  Return true to allow the URL to load, return false to prevent the URL from loading.
+     */
+    public boolean shouldAllowNavigation(String url) {
+        for (PluginEntry entry : this.entryMap.values()) {
+            CordovaPlugin plugin = pluginMap.get(entry.service);
+            if (plugin != null && !plugin.shouldAllowNavigation(url)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Called when the webview is going not going to navigate, but may launch
+     * an Intent for an URL.
+     *
+     * This delegates to the installed plugins, which must all return true for
+     * this method to return true.
+     *
+     * @param url               The URL that is being requested.
+     * @return                  Return true to allow the URL to load, return false to prevent the URL from loading.
+     */
+    public boolean shouldOpenExternalUrl(String url) {
+        for (PluginEntry entry : this.entryMap.values()) {
+            CordovaPlugin plugin = pluginMap.get(entry.service);
+            if (plugin != null && !plugin.shouldOpenExternalUrl(url)) {
+                return false;
+            }
+        }
+        return true;
     }
 
     /**


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