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

Unified Diff: chrome/browser/views/tab_contents/tab_contents_view_win.cc

Issue 267063: Shorten the generated file name to be less than MAX_PATH (on Windows). (Closed)
Patch Set: 'null char also needs to exist' Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/tab_contents/tab_contents_view_win.cc
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.cc b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
index 7352951aa469c1aef1daa3f2d615136ad4ee6b49..e4218df0bfee8b00b872ce2d9dd1ad455960e1f6 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_win.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
@@ -153,8 +153,10 @@ void TabContentsViewWin::StartDragging(const WebDropData& drop_data,
file_name = file_name.BaseName().RemoveExtension();
if (file_name.value().empty()) {
// Retrieve the name from the URL.
- file_name = FilePath::FromWStringHack(
- net::GetSuggestedFilename(drop_data.url, "", "", L""));
+ std::wstring fn = net::GetSuggestedFilename(drop_data.url, "", "", L"");
+ if ((fn.size() + drop_data.file_extension.size() + 1) > MAX_PATH)
+ fn = fn.substr(0, MAX_PATH - drop_data.file_extension.size() - 2);
+ file_name = FilePath::FromWStringHack(fn);
}
file_name = file_name.ReplaceExtension(drop_data.file_extension);
data.SetFileContents(file_name.value(), drop_data.file_contents);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698