From 488f069d3b03408357b832864e6dc7aca885fb8e Mon Sep 17 00:00:00 2001 From: "dglazkov@chromium.org" Date: Tue, 27 Jan 2009 17:30:52 +0000 Subject: [PATCH] 2009-01-27 Paul Godavari 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 | 16 ++++++++++++++++ WebCore/platform/chromium/ChromiumDataObject.cpp | 2 ++ WebCore/platform/chromium/ChromiumDataObject.h | 1 + WebCore/platform/chromium/ClipboardChromium.cpp | 7 +++---- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 8923373f58f0..4a68fad54bf1 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,19 @@ +2009-01-27 Paul Godavari + + 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 Reviewed by Darin Adler. diff --git a/WebCore/platform/chromium/ChromiumDataObject.cpp b/WebCore/platform/chromium/ChromiumDataObject.cpp index 67e9d00ec94c..dee456848d67 100644 --- a/WebCore/platform/chromium/ChromiumDataObject.cpp +++ b/WebCore/platform/chromium/ChromiumDataObject.cpp @@ -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() diff --git a/WebCore/platform/chromium/ChromiumDataObject.h b/WebCore/platform/chromium/ChromiumDataObject.h index 448e7639177e..19b91c4675a6 100644 --- a/WebCore/platform/chromium/ChromiumDataObject.h +++ b/WebCore/platform/chromium/ChromiumDataObject.h @@ -54,6 +54,7 @@ namespace WebCore { KURL url; String urlTitle; + String fileExtension; Vector filenames; String plainText; diff --git a/WebCore/platform/chromium/ClipboardChromium.cpp b/WebCore/platform/chromium/ClipboardChromium.cpp index 7fc156ed57e5..2fcc6df27cc8 100644 --- a/WebCore/platform/chromium/ClipboardChromium.cpp +++ b/WebCore/platform/chromium/ClipboardChromium.cpp @@ -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) -- 2.36.0