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

Unified Diff: content/browser/web_contents/web_contents_view_aura.cc

Issue 2674953003: Only generate suggested filenames when actually dragging an image. (Closed)
Patch Set: rebase Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/test_runner/event_sender.cc ('k') | content/browser/web_contents/web_drag_source_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_view_aura.cc
diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc
index b9e17baec4a63ef759a4d82e1e21f39dfcdcbba1..1273c58e7a43ed11b7f5ae2b57fe311678765ade 100644
--- a/content/browser/web_contents/web_contents_view_aura.cc
+++ b/content/browser/web_contents/web_contents_view_aura.cc
@@ -156,17 +156,10 @@ class WebDragSourceAura : public NotificationObserver {
// necessary.
void PrepareDragForFileContents(const DropData& drop_data,
ui::OSExchangeData::Provider* provider) {
- base::FilePath file_name =
- base::FilePath::FromUTF16Unsafe(drop_data.file_description_filename);
- // Images without ALT text will only have a file extension so we need to
- // synthesize one from the provided extension and URL.
- if (file_name.BaseName().RemoveExtension().empty()) {
- const base::FilePath::StringType extension = file_name.Extension();
- // Retrieve the name from the URL.
- file_name = net::GenerateFileName(drop_data.url, "", "", "", "", "")
- .ReplaceExtension(extension);
- }
- provider->SetFileContents(file_name, drop_data.file_contents);
+ base::Optional<base::FilePath> filename =
+ drop_data.GetSafeFilenameForImageFileContents();
+ if (filename)
+ provider->SetFileContents(*filename, drop_data.file_contents);
}
#endif
« no previous file with comments | « components/test_runner/event_sender.cc ('k') | content/browser/web_contents/web_drag_source_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698