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

Unified Diff: chrome/browser/download/download_util.cc

Issue 7005011: Fix bug 79905: Drag and drop of "DownloadURL" type ignores specified filename for data URLs. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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: chrome/browser/download/download_util.cc
===================================================================
--- chrome/browser/download/download_util.cc (revision 85116)
+++ chrome/browser/download/download_util.cc (working copy)
@@ -167,6 +167,38 @@
}
#endif // OS_WIN
+void GenerateFileNameInternal(const GURL& url,
asanka 2011/05/13 13:32:24 Can you also change GenerateFileNameFromInfo() to
jianli 2011/05/17 00:10:44 Done.
+ const std::string& content_disposition,
+ const std::string& referrer_charset,
+ const std::string& suggested_name,
+ const std::string& mime_type,
+ FilePath* generated_name) {
+
+ string16 default_file_name(
+ l10n_util::GetStringUTF16(IDS_DEFAULT_DOWNLOAD_FILENAME));
+
+ string16 new_name = net::GetSuggestedFilename(GURL(url),
+ content_disposition,
+ referrer_charset,
+ suggested_name,
+ default_file_name);
+
+ // TODO(evan): this code is totally wrong -- we should just generate
+ // Unicode filenames and do all this encoding switching at the end.
+ // However, I'm just shuffling wrong code around, at least not adding
+ // to it.
+#if defined(OS_WIN)
+ *generated_name = FilePath(new_name);
+#else
+ *generated_name = FilePath(
+ base::SysWideToNativeMB(UTF16ToWide(new_name)));
+#endif
+
+ DCHECK(!generated_name->empty());
+
+ GenerateSafeFileName(mime_type, generated_name);
+}
+
} // namespace
// Download temporary file creation --------------------------------------------
@@ -258,33 +290,21 @@
generated_name);
}
+void GenerateFileNameFromSuggestedName(const GURL& url,
+ const std::string& suggested_name,
+ const std::string& mime_type,
+ FilePath* generated_name) {
+ GenerateFileNameInternal(url, std::string(), std::string(),
+ suggested_name, mime_type, generated_name);
+}
+
void GenerateFileName(const GURL& url,
const std::string& content_disposition,
const std::string& referrer_charset,
const std::string& mime_type,
FilePath* generated_name) {
- string16 default_file_name(
- l10n_util::GetStringUTF16(IDS_DEFAULT_DOWNLOAD_FILENAME));
-
- string16 new_name = net::GetSuggestedFilename(GURL(url),
- content_disposition,
- referrer_charset,
- default_file_name);
-
- // TODO(evan): this code is totally wrong -- we should just generate
- // Unicode filenames and do all this encoding switching at the end.
- // However, I'm just shuffling wrong code around, at least not adding
- // to it.
-#if defined(OS_WIN)
- *generated_name = FilePath(new_name);
-#else
- *generated_name = FilePath(
- base::SysWideToNativeMB(UTF16ToWide(new_name)));
-#endif
-
- DCHECK(!generated_name->empty());
-
- GenerateSafeFileName(mime_type, generated_name);
+ GenerateFileNameInternal(url, content_disposition, referrer_charset,
+ std::string(), mime_type, generated_name);
}
void GenerateSafeFileName(const std::string& mime_type, FilePath* file_name) {

Powered by Google App Engine
This is Rietveld 408576698