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

Side by Side 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, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2009 Google Inc. 3 * Copyright (C) 2008, 2009 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 CachedImage* cachedImage = getCachedImage(element); 217 CachedImage* cachedImage = getCachedImage(element);
218 if (!cachedImage || !cachedImage->image() || !cachedImage->isLoaded()) 218 if (!cachedImage || !cachedImage->image() || !cachedImage->isLoaded())
219 return; 219 return;
220 220
221 SharedBuffer* imageBuffer = cachedImage->image()->data(); 221 SharedBuffer* imageBuffer = cachedImage->image()->data();
222 if (!imageBuffer || !imageBuffer->size()) 222 if (!imageBuffer || !imageBuffer->size())
223 return; 223 return;
224 224
225 dataObject->setFileContent(imageBuffer); 225 dataObject->setFileContent(imageBuffer);
226 226
227 // Determine the filename for the file contents of the image. We try to 227 // Determine the filename for the file contents of the image.
228 // use the alt tag if one exists, otherwise we fall back on the suggested 228 String filename = cachedImage->response().suggestedFilename();
229 // filename in the http header, and finally we resort to using the filename 229 if (filename.isEmpty())
230 // in the URL. 230 filename = url.lastPathComponent();
231 if (filename.isEmpty())
232 filename = element->getAttribute(altAttr);
233 else {
234 // Strip any existing extension. Assume that alt text is usually not a f ilename.
235 int extensionIndex = filename.reverseFind('.');
236 if (extensionIndex != -1)
237 filename.truncate(extensionIndex);
238 }
239 filename = ClipboardChromium::validateFileName(filename, dataObject);
240
231 String extension = MIMETypeRegistry::getPreferredExtensionForMIMEType( 241 String extension = MIMETypeRegistry::getPreferredExtensionForMIMEType(
232 cachedImage->response().mimeType()); 242 cachedImage->response().mimeType());
233 dataObject->setFileExtension(extension.isEmpty() ? emptyString() : "." + ext ension); 243 dataObject->setFileExtension(extension.isEmpty() ? emptyString() : "." + ext ension);
234 String title = element->getAttribute(altAttr);
235 if (title.isEmpty())
236 title = cachedImage->response().suggestedFilename();
237 244
238 title = ClipboardChromium::validateFileName(title, dataObject); 245 dataObject->setFileContentFilename(filename + dataObject->fileExtension());
239 dataObject->setFileContentFilename(title + dataObject->fileExtension());
240 } 246 }
241 247
242 void ClipboardChromium::declareAndWriteDragImage(Element* element, const KURL& u rl, const String& title, Frame* frame) 248 void ClipboardChromium::declareAndWriteDragImage(Element* element, const KURL& u rl, const String& title, Frame* frame)
243 { 249 {
244 if (!m_dataObject) 250 if (!m_dataObject)
245 return; 251 return;
246 252
247 m_dataObject->setData(mimeTypeURL, url); 253 m_dataObject->setData(mimeTypeURL, url);
248 m_dataObject->setUrlTitle(title); 254 m_dataObject->setUrlTitle(title);
249 255
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 // Iterate through the types and add them. 334 // Iterate through the types and add them.
329 HashSet<String> types = m_dataObject->types(); 335 HashSet<String> types = m_dataObject->types();
330 for (HashSet<String>::const_iterator it = types.begin(); it != types.end (); ++it) 336 for (HashSet<String>::const_iterator it = types.begin(); it != types.end (); ++it)
331 items->addPasteboardItem(*it); 337 items->addPasteboardItem(*it);
332 } 338 }
333 return items; 339 return items;
334 } 340 }
335 #endif 341 #endif
336 342
337 } // namespace WebCore 343 } // namespace WebCore
OLDNEW
« 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