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

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

Issue 6241001: wstring: make net::GetSuggestedFilename return utf-16 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed Created 9 years, 11 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/save_package.cc
diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc
index e2cebccd418219fbe7bf0877efe21475e67b1bf7..53fc1fe2b85c138729c6e160a489bc0b8b4e9ecd 100644
--- a/chrome/browser/download/save_package.cc
+++ b/chrome/browser/download/save_package.cc
@@ -14,6 +14,7 @@
#include "base/stl_util-inl.h"
#include "base/string_piece.h"
#include "base/string_split.h"
+#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
#include "base/task.h"
#include "base/threading/thread.h"
@@ -62,8 +63,7 @@ int g_save_package_id = 0;
// Default name which will be used when we can not get proper name from
// resource URL.
-const FilePath::CharType kDefaultSaveName[] =
- FILE_PATH_LITERAL("saved_resource");
+const char kDefaultSaveName[] = "saved_resource";
const FilePath::CharType kDefaultHtmlExtension[] =
#if defined(OS_WIN)
@@ -375,8 +375,20 @@ bool SavePackage::GenerateFileName(const std::string& disposition,
FilePath::StringType* generated_name) {
// TODO(jungshik): Figure out the referrer charset when having one
// makes sense and pass it to GetSuggestedFilename.
- FilePath file_path = net::GetSuggestedFilename(url, disposition, "",
- FilePath(kDefaultSaveName));
+ string16 suggested_name =
+ net::GetSuggestedFilename(url, disposition, "",
+ ASCIIToUTF16(kDefaultSaveName));
+
+ // 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)
+ FilePath file_path = FilePath(suggested_name);
+#else
+ FilePath file_path = FilePath(
+ base::SysWideToNativeMB(UTF16ToWide(suggested_name)));
+#endif
DCHECK(!file_path.empty());
FilePath::StringType pure_file_name =
« no previous file with comments | « chrome/browser/download/download_util_unittest.cc ('k') | chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698