summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2010-11-19 06:58:01 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-11-19 06:58:01 -0800
commit9803d7f87054ad67b62011e5b84e8963c5930e51 (patch)
tree2805972653d5d90c82077235d86206d1faae6301 /core
parenta8bbc11afc0f93143c1fd200108a51c95507cc43 (diff)
parent9d005a10397c0c68f52d01035f59de7598881166 (diff)
downloadframeworks_base-9803d7f87054ad67b62011e5b84e8963c5930e51.zip
frameworks_base-9803d7f87054ad67b62011e5b84e8963c5930e51.tar.gz
frameworks_base-9803d7f87054ad67b62011e5b84e8963c5930e51.tar.bz2
Merge "Find mime from file extension if the mime is empty"
Diffstat (limited to 'core')
-rw-r--r--core/java/android/webkit/BrowserFrame.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index d3c0ffd..61a30ab 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -1075,6 +1075,18 @@ class BrowserFrame extends Handler {
*/
private void downloadStart(String url, String userAgent,
String contentDisposition, String mimeType, long contentLength) {
+ // This will only work if the url ends with the filename
+ if (mimeType.isEmpty()) {
+ try {
+ String extension = url.substring(url.lastIndexOf('.') + 1);
+ mimeType = libcore.net.MimeUtils.guessMimeTypeFromExtension(extension);
+ // MimeUtils might return null, not sure if downloadmanager is happy with that
+ if (mimeType == null)
+ mimeType = "";
+ } catch(IndexOutOfBoundsException exception) {
+ // mimeType string end with a '.', not much to do
+ }
+ }
mimeType = MimeTypeMap.getSingleton().remapGenericMimeType(
mimeType, url, contentDisposition);
mCallbackProxy.onDownloadStart(url, userAgent,