summaryrefslogtreecommitdiffstats
path: root/printing
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-22 23:06:12 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-22 23:06:12 +0000
commitde29433580baeecc204edc9ca0c2aa47c51aa93a (patch)
treeec55f655f63f7e09fb373c1e7d784c2e721c6119 /printing
parent2c1639589b5932b565c9d420cb79b56a4212a706 (diff)
downloadchromium_src-de29433580baeecc204edc9ca0c2aa47c51aa93a.zip
chromium_src-de29433580baeecc204edc9ca0c2aa47c51aa93a.tar.gz
chromium_src-de29433580baeecc204edc9ca0c2aa47c51aa93a.tar.bz2
Do some cleanup of file path name handling.
This started trying to cleanup DownloadManager::GenerateFilename which asserts if your system locale isn't UTF-8 (I ran into this when mine got messed up). The solution is to have GetSuggestedFilename return a FilePath rather than calling FromWStringHack. The rest of the patch is a result of trying to write GetSuggestedFilename in a reasonable way. I changed ReplaceIllegalCharacters to work on a FilePath::StringType. Some places in the code calling these functions got cleaner, some got messier. I think overall the ones that got messier are the ones doing sketchy things with paths and the ones that got cleaner are the ones doing things more properly. The only code here that gets called a nontrivial number of times is the weburlloader, and I think the new code does about the same number of string conversions overall (though on certain platforms the number will be higher or lower). BUG=none TEST=none Review URL: http://codereview.chromium.org/271056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29832 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
-rw-r--r--printing/printed_document.cc8
-rw-r--r--printing/printing_context_win.cc2
2 files changed, 8 insertions, 2 deletions
diff --git a/printing/printed_document.cc b/printing/printed_document.cc
index aa9ab5b..785b846 100644
--- a/printing/printed_document.cc
+++ b/printing/printed_document.cc
@@ -263,7 +263,13 @@ void PrintedDocument::DebugDump(const PrintedPage& page) {
filename += L"_";
filename += StringPrintf(L"%02d", page.page_number());
filename += L"_.emf";
- file_util::ReplaceIllegalCharacters(&filename, '_');
+#if defined(OS_WIN)
+ file_util::ReplaceIllegalCharactersInPath(&filename, '_');
+#else
+ std::string narrow_filename = WideToUTF8(filename);
+ file_util::ReplaceIllegalCharactersInPath(&narrow_filename, '_');
+ filename = UTF8ToWide(narrow_filename);
+#endif
std::wstring path(g_debug_dump_info->debug_dump_path);
file_util::AppendToPath(&path, filename);
#if defined(OS_WIN)
diff --git a/printing/printing_context_win.cc b/printing/printing_context_win.cc
index 99232a9..6c49da2 100644
--- a/printing/printing_context_win.cc
+++ b/printing/printing_context_win.cc
@@ -284,7 +284,7 @@ PrintingContext::Result PrintingContext::NewDocument(
filename += document_name;
filename += L"_";
filename += L"buffer.prn";
- file_util::ReplaceIllegalCharacters(&filename, '_');
+ file_util::ReplaceIllegalCharactersInPath(&filename, '_');
file_util::AppendToPath(&debug_dump_path, filename);
di.lpszOutput = debug_dump_path.c_str();
}