diff options
author | Kristian Monsen <kristianm@google.com> | 2010-11-18 18:24:38 +0000 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-11-19 14:53:44 +0000 |
commit | 9d005a10397c0c68f52d01035f59de7598881166 (patch) | |
tree | 453af469ad4ef24bceeb6959567424d8044d5d3c /core | |
parent | 558cf799293df19aab99b30d5a1579b989e0465a (diff) | |
download | frameworks_base-9d005a10397c0c68f52d01035f59de7598881166.zip frameworks_base-9d005a10397c0c68f52d01035f59de7598881166.tar.gz frameworks_base-9d005a10397c0c68f52d01035f59de7598881166.tar.bz2 |
Find mime from file extension if the mime is empty
Fix for bug 3170039
Change-Id: I6d32ae157ec276575aad8fbcd73f02c48fe219d0
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/webkit/BrowserFrame.java | 12 |
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, |