diff options
author | Kristian Monsen <kristianm@google.com> | 2010-11-19 06:58:01 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-11-19 06:58:01 -0800 |
commit | 9803d7f87054ad67b62011e5b84e8963c5930e51 (patch) | |
tree | 2805972653d5d90c82077235d86206d1faae6301 /core | |
parent | a8bbc11afc0f93143c1fd200108a51c95507cc43 (diff) | |
parent | 9d005a10397c0c68f52d01035f59de7598881166 (diff) | |
download | frameworks_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.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, |