diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-22 23:06:12 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-22 23:06:12 +0000 |
commit | de29433580baeecc204edc9ca0c2aa47c51aa93a (patch) | |
tree | ec55f655f63f7e09fb373c1e7d784c2e721c6119 /net/base/net_util.h | |
parent | 2c1639589b5932b565c9d420cb79b56a4212a706 (diff) | |
download | chromium_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 'net/base/net_util.h')
-rw-r--r-- | net/base/net_util.h | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/net/base/net_util.h b/net/base/net_util.h index 302a55f..1ad4ac2 100644 --- a/net/base/net_util.h +++ b/net/base/net_util.h @@ -1,9 +1,9 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef NET_BASE_NET_UTIL_H__ -#define NET_BASE_NET_UTIL_H__ +#ifndef NET_BASE_NET_UTIL_H_ +#define NET_BASE_NET_UTIL_H_ #include "build/build_config.h" @@ -126,8 +126,8 @@ std::string GetHeaderParamValue(const std::string& field, // other caller is a unit test. Need to figure out expose this function only to // net_util_unittest. // -std::wstring GetFileNameFromCD(const std::string& header, - const std::string& referrer_charset); +std::string GetFileNameFromCD(const std::string& header, + const std::string& referrer_charset); // Converts the given host name to unicode characters, APPENDING them to the // the given output string. This can be called for any host name, if the @@ -194,14 +194,17 @@ std::wstring StripWWW(const std::wstring& text); // Gets the filename from the raw Content-Disposition header (as read from the // network). Otherwise uses the last path component name or hostname from -// |url|. Note: it's possible for the suggested filename to be empty (e.g., +// |url|. If there is no filename or it can't be used, the given default name +// will be used if specified. + +// Note: it's possible for the suggested filename to be empty (e.g., // file:///). referrer_charset is used as one of charsets // to interpret a raw 8bit string in C-D header (after interpreting // as UTF-8 fails). See the comment for GetFilenameFromCD for more details. -std::wstring GetSuggestedFilename(const GURL& url, - const std::string& content_disposition, - const std::string& referrer_charset, - const std::wstring& default_name); +FilePath GetSuggestedFilename(const GURL& url, + const std::string& content_disposition, + const std::string& referrer_charset, + const char* default_name); // Checks the given port against a list of ports which are restricted by // default. Returns true if the port is allowed, false if it is restricted. @@ -259,4 +262,4 @@ void SetExplicitlyAllowedPorts(const std::wstring& allowed_ports); } // namespace net -#endif // NET_BASE_NET_UTIL_H__ +#endif // NET_BASE_NET_UTIL_H_ |