cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [14/22] android commit: DataResource bugfix WebviewClient logs error for http urls.
Date Fri, 17 May 2013 00:55:06 GMT
DataResource bugfix WebviewClient logs error for http urls.


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

Branch: refs/heads/3.0.0
Commit: 8f91ebf194baa8028367e9e41f2e5ee2ff099b88
Parents: 230c635
Author: Shravan Narayan <shravanrn@google.com>
Authored: Fri May 10 17:08:50 2013 -0400
Committer: Braden Shepherdson <braden@google.com>
Committed: Thu May 16 14:29:04 2013 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/FileHelper.java   |    4 +++-
 .../cordova/IceCreamCordovaWebViewClient.java      |    8 +++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/8f91ebf1/framework/src/org/apache/cordova/FileHelper.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileHelper.java b/framework/src/org/apache/cordova/FileHelper.java
index 400352c..8bc24aa 100644
--- a/framework/src/org/apache/cordova/FileHelper.java
+++ b/framework/src/org/apache/cordova/FileHelper.java
@@ -98,8 +98,10 @@ public class FileHelper {
             Uri uri = Uri.parse(uriString);
             String relativePath = uri.getPath().substring(15);
             return cordova.getActivity().getAssets().open(relativePath);
-        } else {
+        } else if (uriString.startsWith("file://")) {
             return new FileInputStream(getRealPath(uriString, cordova));
+        } else {
+            return null;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/8f91ebf1/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 d9c1cd2..14c7603 100644
--- a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
@@ -19,6 +19,7 @@
 package org.apache.cordova;
 
 import java.io.IOException;
+import java.io.InputStream;
 
 import org.apache.cordova.api.CordovaInterface;
 import org.apache.cordova.api.DataResource;
@@ -55,7 +56,12 @@ public class IceCreamCordovaWebViewClient extends CordovaWebViewClient
{
 
         if(ret == null) {
             try {
-                ret = new WebResourceResponse(dataResource.getMimeType(), "UTF-8", dataResource.getInputStream());
+                InputStream is;
+                String mimeType;
+                if((is = dataResource.getInputStream()) != null && (mimeType = dataResource.getMimeType())
!= null) {
+                    // If we don't know how to open this file, let the browser continue loading
+                    ret = new WebResourceResponse(mimeType, "UTF-8", is);
+                }
             } catch(IOException e) {
                 LOG.e("IceCreamCordovaWebViewClient", "Error occurred while loading a file.",
e);
             }


Mime
View raw message