2009-01-27 Paul Godavari <paul@chromium.org>
authordglazkov@chromium.org <dglazkov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Jan 2009 17:30:52 +0000 (17:30 +0000)
committerdglazkov@chromium.org <dglazkov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Jan 2009 17:30:52 +0000 (17:30 +0000)
        Reviewed by Eric Seidel.

        https://bugs.webkit.org/show_bug.cgi?id=23561
        Explicitly send the MIME type from an image dragged from a web
        page to the desktop, to Chromium so that it can properly generate
        a file name.

        * platform/chromium/ChromiumDataObject.cpp:
        (WebCore::ChromiumDataObject::clear):
        (WebCore::ChromiumDataObject::hasData):
        * platform/chromium/ChromiumDataObject.h:
        * platform/chromium/ClipboardChromium.cpp:
        (WebCore::writeImageToDataObject):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@40294 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/chromium/ChromiumDataObject.cpp
WebCore/platform/chromium/ChromiumDataObject.h
WebCore/platform/chromium/ClipboardChromium.cpp

index 8923373f58f08de6e41a4b73e7680f00e5de4a08..4a68fad54bf1b33997af8db82f4b2f2e375e155b 100644 (file)
@@ -1,3 +1,19 @@
+2009-01-27  Paul Godavari  <paul@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        https://bugs.webkit.org/show_bug.cgi?id=23561
+        Explicitly send the MIME type from an image dragged from a web
+        page to the desktop, to Chromium so that it can properly generate
+        a file name.
+
+        * platform/chromium/ChromiumDataObject.cpp:
+        (WebCore::ChromiumDataObject::clear):
+        (WebCore::ChromiumDataObject::hasData):
+        * platform/chromium/ChromiumDataObject.h:
+        * platform/chromium/ClipboardChromium.cpp:
+        (WebCore::writeImageToDataObject):
+
 2009-01-27  Mads Ager  <ager@chromium.org>
 
         Reviewed by Darin Adler.
index 67e9d00ec94c844b1c5cc43c50ef2df778758e66..dee456848d67d540afc6afa454461a5d57576ffe 100644 (file)
@@ -37,6 +37,7 @@ void ChromiumDataObject::clear()
 {
     url = KURL();
     urlTitle = "";
+    fileExtension = "";
     filenames.clear();
     plainText = "";
     textHtml = "";
@@ -49,6 +50,7 @@ void ChromiumDataObject::clear()
 bool ChromiumDataObject::hasData()
 {
     return !url.isEmpty()
+        || !fileExtension.isEmpty()
         || !filenames.isEmpty()
         || !plainText.isEmpty()
         || !textHtml.isEmpty()
index 448e7639177e21e49497e30fd54e3f1229c2cb17..19b91c4675a6a310624f8dee5447593aed666dd1 100644 (file)
@@ -54,6 +54,7 @@ namespace WebCore {
         KURL url;
         String urlTitle;
 
+        String fileExtension;
         Vector<String> filenames;
 
         String plainText;
index 7fc156ed57e56f57211bd5ef188aa8b56c736533..2fcc6df27cc8c77b853b539af78843a73a3c6a9a 100644 (file)
@@ -268,15 +268,14 @@ static void writeImageToDataObject(ChromiumDataObject* dataObject, Element* elem
     // use the alt tag if one exists, otherwise we fall back on the suggested
     // filename in the http header, and finally we resort to using the filename
     // in the URL.
-    String extension(".");
-    extension += MIMETypeRegistry::getPreferredExtensionForMIMEType(
+    dataObject->fileExtension = ".";
+    dataObject->fileExtension += MIMETypeRegistry::getPreferredExtensionForMIMEType(
         cachedImage->response().mimeType());
     String title = element->getAttribute(altAttr);
     if (title.isEmpty()) {
         title = cachedImage->response().suggestedFilename();
-        // FIXME: If title is empty, get the filename from the URL.
     }
-    dataObject->fileContentFilename = title + extension;
+    dataObject->fileContentFilename = title + dataObject->fileExtension;
 }
 
 void ClipboardChromium::declareAndWriteDragImage(Element* element, const KURL& url, const String& title, Frame* frame)