diff --git a/AUTHORS b/AUTHORS index 9c870435beceb4..45d562d4310d42 100644 --- a/AUTHORS +++ b/AUTHORS @@ -175,3 +175,4 @@ Eric Rescorla Alexandre Abreu Erik Sjölund Simon Arlott +Alexey Korepanov diff --git a/content/browser/web_contents/web_contents_drag_win.cc b/content/browser/web_contents/web_contents_drag_win.cc index a07c61f7d019fd..4dbac90526b943 100644 --- a/content/browser/web_contents/web_contents_drag_win.cc +++ b/content/browser/web_contents/web_contents_drag_win.cc @@ -234,11 +234,11 @@ void WebContentsDragWin::PrepareDragForFileContents( const WebDropData& drop_data, ui::OSExchangeData* data) { static const int kMaxFilenameLength = 255; // FAT and NTFS FilePath file_name(drop_data.file_description_filename); - string16 extension = file_name.Extension(); - file_name = file_name.BaseName().RemoveExtension(); + // 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.value().empty()) { + if (file_name.BaseName().RemoveExtension().empty()) { + const string16 extension = file_name.Extension(); // Retrieve the name from the URL. file_name = FilePath( net::GetSuggestedFilename(drop_data.url, "", "", "", "", "")); @@ -246,8 +246,8 @@ void WebContentsDragWin::PrepareDragForFileContents( file_name = FilePath(file_name.value().substr( 0, kMaxFilenameLength - extension.size())); } + file_name = file_name.ReplaceExtension(extension); } - file_name = file_name.ReplaceExtension(extension); data->SetFileContents(file_name, drop_data.file_contents); } diff --git a/content/browser/web_contents/web_drag_source_mac.mm b/content/browser/web_contents/web_drag_source_mac.mm index 98a21204e79e69..21e05c34938fa4 100644 --- a/content/browser/web_contents/web_drag_source_mac.mm +++ b/content/browser/web_contents/web_drag_source_mac.mm @@ -57,8 +57,6 @@ FilePath FilePathFromFilename(const string16& filename) { // and move it somewhere sensible. FilePath GetFileNameFromDragData(const WebDropData& drop_data) { FilePath file_name(FilePathFromFilename(drop_data.file_description_filename)); - std::string extension = file_name.Extension(); - file_name = file_name.BaseName().RemoveExtension(); // Images without ALT text will only have a file extension so we need to // synthesize one from the provided extension and URL. @@ -66,10 +64,12 @@ FilePath GetFileNameFromDragData(const WebDropData& drop_data) { // Retrieve the name from the URL. string16 suggested_filename = net::GetSuggestedFilename(drop_data.url, "", "", "", "", ""); + const std::string extension = file_name.Extension(); file_name = FilePathFromFilename(suggested_filename); + file_name = file_name.ReplaceExtension(extension); } - return file_name.ReplaceExtension(extension); + return file_name; } // This helper's sole task is to write out data for a promised file; the caller