Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Unified Diff: Source/WebCore/platform/chromium/ClipboardChromium.cpp

Issue 7054067: Merge 87848 - 2011-06-01 Daniel Cheng <dcheng@chromium.org> (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/782/
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/platform/win/Skipped ('k') | Source/WebCore/platform/chromium/ClipboardChromiumMac.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/platform/chromium/ClipboardChromium.cpp
===================================================================
--- Source/WebCore/platform/chromium/ClipboardChromium.cpp (revision 88116)
+++ Source/WebCore/platform/chromium/ClipboardChromium.cpp (working copy)
@@ -224,19 +224,25 @@
dataObject->setFileContent(imageBuffer);
- // Determine the filename for the file contents of the image. We try to
- // 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.
+ // Determine the filename for the file contents of the image.
+ String filename = cachedImage->response().suggestedFilename();
+ if (filename.isEmpty())
+ filename = url.lastPathComponent();
+ if (filename.isEmpty())
+ filename = element->getAttribute(altAttr);
+ else {
+ // Strip any existing extension. Assume that alt text is usually not a filename.
+ int extensionIndex = filename.reverseFind('.');
+ if (extensionIndex != -1)
+ filename.truncate(extensionIndex);
+ }
+ filename = ClipboardChromium::validateFileName(filename, dataObject);
+
String extension = MIMETypeRegistry::getPreferredExtensionForMIMEType(
cachedImage->response().mimeType());
dataObject->setFileExtension(extension.isEmpty() ? emptyString() : "." + extension);
- String title = element->getAttribute(altAttr);
- if (title.isEmpty())
- title = cachedImage->response().suggestedFilename();
- title = ClipboardChromium::validateFileName(title, dataObject);
- dataObject->setFileContentFilename(title + dataObject->fileExtension());
+ dataObject->setFileContentFilename(filename + dataObject->fileExtension());
}
void ClipboardChromium::declareAndWriteDragImage(Element* element, const KURL& url, const String& title, Frame* frame)
« no previous file with comments | « LayoutTests/platform/win/Skipped ('k') | Source/WebCore/platform/chromium/ClipboardChromiumMac.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698