cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject [1/2] android commit: CB-3504: Fixing issue with the use of WebResourceResponse on pre-Honeycomb devices.
Date Fri, 14 Jun 2013 22:29:57 GMT
Updated Branches:
  refs/heads/master 32d74f862 -> b679672c0


CB-3504: Fixing issue with the use of WebResourceResponse on pre-Honeycomb devices.


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

Branch: refs/heads/master
Commit: 90f83db9c9de2dffb3a4db965d7221e83b0e917e
Parents: add1075
Author: Joe Bowser <bowserj@apache.org>
Authored: Fri Jun 14 15:29:30 2013 -0700
Committer: Joe Bowser <bowserj@apache.org>
Committed: Fri Jun 14 15:29:30 2013 -0700

----------------------------------------------------------------------
 .../apache/cordova/CordovaWebViewClient.java    | 28 --------------------
 .../cordova/IceCreamCordovaWebViewClient.java   | 19 ++++++++++++-
 2 files changed, 18 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/90f83db9/framework/src/org/apache/cordova/CordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebViewClient.java b/framework/src/org/apache/cordova/CordovaWebViewClient.java
index 4b00615..eef961c 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

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/90f83db9/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 847972e..259f20b 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/")) {


Mime
View raw message