Title: [106802] trunk/Source/WebCore
Revision
106802
Author
[email protected]
Date
2012-02-06 05:55:14 -0800 (Mon, 06 Feb 2012)

Log 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 <[email protected]> on 2012-02-06
Reviewed by Antonio Gomes.

No new tests.

* platform/network/blackberry/NetworkJob.cpp:
(WebCore::NetworkJob::sendResponseIfNeeded):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (106801 => 106802)


--- trunk/Source/WebCore/ChangeLog	2012-02-06 13:24:20 UTC (rev 106801)
+++ trunk/Source/WebCore/ChangeLog	2012-02-06 13:55:14 UTC (rev 106802)
@@ -1,3 +1,16 @@
+2012-02-06  Charles Wei  <[email protected]>
+
+        [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
+
+        Reviewed by Antonio Gomes.
+
+        No new tests. 
+
+        * platform/network/blackberry/NetworkJob.cpp:
+        (WebCore::NetworkJob::sendResponseIfNeeded):
+
 2012-02-06  Kentaro Hara  <[email protected]>
 
         Rename [HasIndexGetter], [HasNameGetter] and [HasCustomIndexSetter] IDLs

Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp (106801 => 106802)


--- trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp	2012-02-06 13:24:20 UTC (rev 106801)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp	2012-02-06 13:55:14 UTC (rev 106802)
@@ -610,12 +610,26 @@
     if (!contentLength.isNull())
         m_response.setExpectedContentLength(contentLength.toInt64());
 
-    // Set suggested filename for downloads from the Content-Disposition header; if this fails, fill it in from the url
-    // skip this for data url's, because they have no Content-Disposition header and the format is wrong to be a filename.
+    // Set suggested filename for downloads from the Content-Disposition header; if this fails,
+    // fill it in from the url and sniffed mime type;Skip this for data and about URLs,
+    // because they have no Content-Disposition header and the format is wrong to be a filename.
     if (!m_isData && !m_isAbout) {
         String suggestedFilename = filenameFromHTTPContentDisposition(m_contentDisposition);
-        if (suggestedFilename.isNull())
-            suggestedFilename = urlFilename;
+        if (suggestedFilename.isEmpty()) {
+            // Check and see if an extension already exists.
+            String mimeExtension = MIMETypeRegistry::getPreferredExtensionForMIMEType(mimeType);
+            if (urlFilename.isEmpty()) {
+                if (mimeExtension.isEmpty()) // No extension found for the mimeType.
+                    suggestedFilename = String("Untitled");
+                else
+                    suggestedFilename = String("Untitled") + "." + mimeExtension;
+            } else {
+                if (urlFilename.reverseFind('.') == notFound && !mimeExtension.isEmpty())
+                   suggestedFilename = urlFilename + '.' + mimeExtension;
+                else
+                   suggestedFilename = urlFilename;
+            }
+        }
         m_response.setSuggestedFilename(suggestedFilename);
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to