summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-29 21:55:35 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-29 21:55:35 +0000
commita8b7972ea8835724e353d20e6fd85ebb0fb1d2e3 (patch)
tree70791525ae488e67605aad246617d3d67dfa6277 /content
parent9ed07f8831639f9d6c74b9633262710af532df5b (diff)
downloadchromium_src-a8b7972ea8835724e353d20e6fd85ebb0fb1d2e3.zip
chromium_src-a8b7972ea8835724e353d20e6fd85ebb0fb1d2e3.tar.gz
chromium_src-a8b7972ea8835724e353d20e6fd85ebb0fb1d2e3.tar.bz2
Issue 121063 fixed: Drag and dropping a file named [something].[andmore].[ext] from Chrome to a folder results in a filename named [something].[ext]
Method WebContentsDragWin::PrepareDragForFileContents has been updated to deal with filenames like [something].[andmore].[ext] correctly. BUG=121063 TEST=1. Find a file named with the following pattern [something].[andmore].[ext] 2. Drag and drop the file(picture) to a folder You can use the picture attached to the issue page at http://code.google.com/p/chromium/issues/detail?id=121063 Review URL: https://chromiumcodereview.appspot.com/10257025 Patch from Alexey Korepanov <alexkorep@gmail.com>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139386 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/web_contents/web_contents_drag_win.cc8
-rw-r--r--content/browser/web_contents/web_drag_source_mac.mm6
2 files changed, 7 insertions, 7 deletions
diff --git a/content/browser/web_contents/web_contents_drag_win.cc b/content/browser/web_contents/web_contents_drag_win.cc
index a07c61f..4dbac90 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 98a2120..21e05c3 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