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

Side by Side Diff: third_party/WebKit/Source/core/clipboard/DataTransfer.cpp

Issue 2398053003: Compute ResourceResponse::suggestedFileName on the fly. (Closed)
Patch Set: clean up vestigial changes (trybots previous) Created 4 years, 2 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, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 25 matching lines...) Expand all
36 #include "core/fileapi/FileList.h" 36 #include "core/fileapi/FileList.h"
37 #include "core/frame/LocalFrame.h" 37 #include "core/frame/LocalFrame.h"
38 #include "core/html/HTMLImageElement.h" 38 #include "core/html/HTMLImageElement.h"
39 #include "core/html/HTMLTextFormControlElement.h" 39 #include "core/html/HTMLTextFormControlElement.h"
40 #include "core/layout/LayoutImage.h" 40 #include "core/layout/LayoutImage.h"
41 #include "core/layout/LayoutObject.h" 41 #include "core/layout/LayoutObject.h"
42 #include "platform/DragImage.h" 42 #include "platform/DragImage.h"
43 #include "platform/MIMETypeRegistry.h" 43 #include "platform/MIMETypeRegistry.h"
44 #include "platform/clipboard/ClipboardMimeTypes.h" 44 #include "platform/clipboard/ClipboardMimeTypes.h"
45 #include "platform/clipboard/ClipboardUtilities.h" 45 #include "platform/clipboard/ClipboardUtilities.h"
46 #include "platform/network/NetworkUtils.h"
46 #include <memory> 47 #include <memory>
47 48
48 namespace blink { 49 namespace blink {
49 50
50 static DragOperation convertEffectAllowedToDragOperation(const String& op) { 51 static DragOperation convertEffectAllowedToDragOperation(const String& op) {
51 // Values specified in http://www.whatwg.org/specs/web-apps/current-work/multi page/dnd.html#dom-datatransfer-effectallowed 52 // Values specified in http://www.whatwg.org/specs/web-apps/current-work/multi page/dnd.html#dom-datatransfer-effectallowed
52 if (op == "uninitialized") 53 if (op == "uninitialized")
53 return DragOperationEvery; 54 return DragOperationEvery;
54 if (op == "none") 55 if (op == "none")
55 return DragOperationNone; 56 return DragOperationNone;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 if (!cachedImage || !cachedImage->getImage() || !cachedImage->isLoaded()) 270 if (!cachedImage || !cachedImage->getImage() || !cachedImage->isLoaded())
270 return; 271 return;
271 272
272 RefPtr<SharedBuffer> imageBuffer = cachedImage->getImage()->data(); 273 RefPtr<SharedBuffer> imageBuffer = cachedImage->getImage()->data();
273 if (!imageBuffer || !imageBuffer->size()) 274 if (!imageBuffer || !imageBuffer->size())
274 return; 275 return;
275 276
276 String imageExtension = cachedImage->getImage()->filenameExtension(); 277 String imageExtension = cachedImage->getImage()->filenameExtension();
277 ASSERT(!imageExtension.isEmpty()); 278 ASSERT(!imageExtension.isEmpty());
278 279
279 // Determine the filename for the file contents of the image. 280 String filename = NetworkUtils::getSuggestedFilename(
280 String filename = cachedImage->response().suggestedFilename(); 281 url, cachedImage->response().httpHeaderField("content-disposition"));
281 if (filename.isEmpty()) 282 if (filename.isEmpty())
282 filename = url.lastPathComponent(); 283 filename = url.lastPathComponent();
283 284
284 String fileExtension; 285 String fileExtension;
285 if (filename.isEmpty()) { 286 if (filename.isEmpty()) {
286 filename = element->getAttribute(HTMLNames::altAttr); 287 filename = element->getAttribute(HTMLNames::altAttr);
287 } else { 288 } else {
288 // Strip any existing extension. Assume that alt text is usually not a filen ame. 289 // Strip any existing extension. Assume that alt text is usually not a filen ame.
289 int extensionIndex = filename.reverseFind('.'); 290 int extensionIndex = filename.reverseFind('.');
290 if (extensionIndex != -1) { 291 if (extensionIndex != -1) {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } 499 }
499 } 500 }
500 501
501 DEFINE_TRACE(DataTransfer) { 502 DEFINE_TRACE(DataTransfer) {
502 visitor->trace(m_dataObject); 503 visitor->trace(m_dataObject);
503 visitor->trace(m_dragImage); 504 visitor->trace(m_dragImage);
504 visitor->trace(m_dragImageElement); 505 visitor->trace(m_dragImageElement);
505 } 506 }
506 507
507 } // namespace blink 508 } // namespace blink
OLDNEW
« no previous file with comments | « content/child/web_url_loader_impl.cc ('k') | third_party/WebKit/Source/platform/exported/WebURLResponse.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698