diff --git a/framework/src/org/apache/cordova/CordovaWebViewClient.java b/framework/src/org/apache/cordova/CordovaWebViewClient.java index 4b006153..eef961c3 100755 --- a/framework/src/org/apache/cordova/CordovaWebViewClient.java +++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java @@ -211,35 +211,7 @@ public class CordovaWebViewClient extends WebViewClient { } return true; } - - /** - * Check for intercepting any requests for resources. - * This includes images and scripts and so on, not just top-level pages. - * @param view The WebView. - * @param url The URL to be loaded. - * @return Either null to proceed as normal, or a WebResourceResponse. - */ - @Override - public WebResourceResponse shouldInterceptRequest(WebView view, String url) { - //If something isn't whitelisted, just send a blank response - if(!Config.isUrlWhiteListed(url) && (url.startsWith("http://") || url.startsWith("https://"))) - { - return getWhitelistResponse(); - } - if (this.appView.pluginManager != null) { - return this.appView.pluginManager.shouldInterceptRequest(url); - } - return null; - } - private WebResourceResponse getWhitelistResponse() - { - WebResourceResponse emptyResponse; - String empty = ""; - ByteArrayInputStream data = new ByteArrayInputStream(empty.getBytes()); - return new WebResourceResponse("text/plain", "UTF-8", data); - } - /** * 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 diff --git a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java index 847972ee..259f20b5 100644 --- a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java +++ b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java @@ -18,6 +18,7 @@ */ package org.apache.cordova; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -45,11 +46,27 @@ public class IceCreamCordovaWebViewClient extends CordovaWebViewClient { public WebResourceResponse shouldInterceptRequest(WebView view, String url) { //Check if plugins intercept the request WebResourceResponse ret = super.shouldInterceptRequest(view, url); - if(ret == null && (url.contains("?") || url.contains("#") || needsIceCreamSpaceInAssetUrlFix(url))){ + + if(!Config.isUrlWhiteListed(url) && (url.startsWith("http://") || url.startsWith("https://"))) + { + ret = getWhitelistResponse(); + } + else if(ret == null && (url.contains("?") || url.contains("#") || needsIceCreamSpaceInAssetUrlFix(url))){ ret = generateWebResourceResponse(url); } + else if (ret == null && this.appView.pluginManager != null) { + ret = this.appView.pluginManager.shouldInterceptRequest(url); + } return ret; } + + private WebResourceResponse getWhitelistResponse() + { + WebResourceResponse emptyResponse; + String empty = ""; + ByteArrayInputStream data = new ByteArrayInputStream(empty.getBytes()); + return new WebResourceResponse("text/plain", "UTF-8", data); + } private WebResourceResponse generateWebResourceResponse(String url) { if (url.startsWith("file:///android_asset/")) {