Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9803d7f8 authored by Kristian Monsen's avatar Kristian Monsen Committed by Android (Google) Code Review
Browse files

Merge "Find mime from file extension if the mime is empty"

parents a8bbc11a 9d005a10
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -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,