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

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
« no previous file with comments | « chrome/browser/download/download_util.h ('k') | chrome/browser/download/save_package.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_util.cc
===================================================================
--- chrome/browser/download/download_util.cc (revision 85826)
+++ chrome/browser/download/download_util.cc (working copy)
@@ -167,6 +167,38 @@
}
#endif // OS_WIN
+void GenerateFileNameInternal(const GURL& url,
+ 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 --------------------------------------------
@@ -251,40 +283,26 @@
void GenerateFileNameFromInfo(DownloadCreateInfo* info,
FilePath* generated_name) {
- GenerateFileName(GURL(info->url()),
- info->content_disposition,
- info->referrer_charset,
- info->mime_type,
- generated_name);
+ GenerateFileNameInternal(GURL(info->url()), info->content_disposition,
+ info->referrer_charset, std::string(),
+ info->mime_type, 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) {
« no previous file with comments | « chrome/browser/download/download_util.h ('k') | chrome/browser/download/save_package.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698