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

Side by Side Diff: third_party/WebKit/WebCore/platform/chromium/ClipboardChromium.cpp

Issue 20504: I'm expanding this to fix a couple of bugs in determining the file name for... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | Annotate | Revision Log
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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 SharedBuffer* imageBuffer = cachedImage->image()->data(); 261 SharedBuffer* imageBuffer = cachedImage->image()->data();
262 if (!imageBuffer || !imageBuffer->size()) 262 if (!imageBuffer || !imageBuffer->size())
263 return; 263 return;
264 264
265 dataObject->fileContent = imageBuffer; 265 dataObject->fileContent = imageBuffer;
266 266
267 // Determine the filename for the file contents of the image. We try to 267 // Determine the filename for the file contents of the image. We try to
268 // use the alt tag if one exists, otherwise we fall back on the suggested 268 // use the alt tag if one exists, otherwise we fall back on the suggested
269 // filename in the http header, and finally we resort to using the filename 269 // filename in the http header, and finally we resort to using the filename
270 // in the URL. 270 // in the URL.
271 dataObject->fileExtension = "."; 271 String extension = MIMETypeRegistry::getPreferredExtensionForMIMEType(
272 dataObject->fileExtension += MIMETypeRegistry::getPreferredExtensionForMIMET ype(
273 cachedImage->response().mimeType()); 272 cachedImage->response().mimeType());
273 dataObject->fileExtension = extension.isEmpty() ? "" : "." + extension;
274 String title = element->getAttribute(altAttr); 274 String title = element->getAttribute(altAttr);
275 if (title.isEmpty()) { 275 if (title.isEmpty())
276 title = cachedImage->response().suggestedFilename(); 276 title = cachedImage->response().suggestedFilename();
277 } 277
278 title = ClipboardChromium::validateFileName(title, dataObject);
278 dataObject->fileContentFilename = title + dataObject->fileExtension; 279 dataObject->fileContentFilename = title + dataObject->fileExtension;
279 } 280 }
280 281
281 void ClipboardChromium::declareAndWriteDragImage(Element* element, const KURL& u rl, const String& title, Frame* frame) 282 void ClipboardChromium::declareAndWriteDragImage(Element* element, const KURL& u rl, const String& title, Frame* frame)
282 { 283 {
283 if (!m_dataObject) 284 if (!m_dataObject)
284 return; 285 return;
285 286
286 m_dataObject->url = url; 287 m_dataObject->url = url;
287 m_dataObject->urlTitle = title; 288 m_dataObject->urlTitle = title;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 337
337 bool ClipboardChromium::hasData() 338 bool ClipboardChromium::hasData()
338 { 339 {
339 if (!m_dataObject) 340 if (!m_dataObject)
340 return false; 341 return false;
341 342
342 return m_dataObject->hasData(); 343 return m_dataObject->hasData();
343 } 344 }
344 345
345 } // namespace WebCore 346 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698