Changeset 106802 in webkit


Ignore:
Timestamp:
Feb 6, 2012 5:55:14 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[BlackBerry]Use extension for a mimetype as the suggested extension
if the url file doesn't have an extension.
https://bugs.webkit.org/show_bug.cgi?id=76779

Patch by Charles Wei <charles.wei@torchmobile.com.cn> on 2012-02-06
Reviewed by Antonio Gomes.

No new tests.

  • platform/network/blackberry/NetworkJob.cpp:

(WebCore::NetworkJob::sendResponseIfNeeded):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r106798 r106802  
     12012-02-06  Charles Wei  <charles.wei@torchmobile.com.cn>
     2
     3        [BlackBerry]Use extension for a mimetype as the suggested extension
     4        if the url file doesn't have an extension.
     5        https://bugs.webkit.org/show_bug.cgi?id=76779
     6
     7        Reviewed by Antonio Gomes.
     8
     9        No new tests.
     10
     11        * platform/network/blackberry/NetworkJob.cpp:
     12        (WebCore::NetworkJob::sendResponseIfNeeded):
     13
    1142012-02-06  Kentaro Hara  <haraken@chromium.org>
    215
  • trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp

    r106307 r106802  
    611611        m_response.setExpectedContentLength(contentLength.toInt64());
    612612
    613     // Set suggested filename for downloads from the Content-Disposition header; if this fails, fill it in from the url
    614     // skip this for data url's, because they have no Content-Disposition header and the format is wrong to be a filename.
     613    // Set suggested filename for downloads from the Content-Disposition header; if this fails,
     614    // fill it in from the url and sniffed mime type;Skip this for data and about URLs,
     615    // because they have no Content-Disposition header and the format is wrong to be a filename.
    615616    if (!m_isData && !m_isAbout) {
    616617        String suggestedFilename = filenameFromHTTPContentDisposition(m_contentDisposition);
    617         if (suggestedFilename.isNull())
    618             suggestedFilename = urlFilename;
     618        if (suggestedFilename.isEmpty()) {
     619            // Check and see if an extension already exists.
     620            String mimeExtension = MIMETypeRegistry::getPreferredExtensionForMIMEType(mimeType);
     621            if (urlFilename.isEmpty()) {
     622                if (mimeExtension.isEmpty()) // No extension found for the mimeType.
     623                    suggestedFilename = String("Untitled");
     624                else
     625                    suggestedFilename = String("Untitled") + "." + mimeExtension;
     626            } else {
     627                if (urlFilename.reverseFind('.') == notFound && !mimeExtension.isEmpty())
     628                   suggestedFilename = urlFilename + '.' + mimeExtension;
     629                else
     630                   suggestedFilename = urlFilename;
     631            }
     632        }
    619633        m_response.setSuggestedFilename(suggestedFilename);
    620634    }
Note: See TracChangeset for help on using the changeset viewer.