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

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: Maybe? 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
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 ab629389b8f6571681c4223d935dbad5d5bcc4a0..d1e4cdd037ecef4020e16931a01e047d69d233b5 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

Powered by Google App Engine
This is Rietveld 408576698