diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-08 20:35:10 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-08 20:35:10 +0000 |
commit | 9d9221f0615f685b209ee5240a8e8e0cb8118454 (patch) | |
tree | 0c1f29f0c2f1db84144f03b8153d88af3d7a1005 /net/base/filename_util.h | |
parent | 3d57bfd273ccb467e50110c137b79d5bcf1a5e14 (diff) | |
download | chromium_src-9d9221f0615f685b209ee5240a8e8e0cb8118454.zip chromium_src-9d9221f0615f685b209ee5240a8e8e0cb8118454.tar.gz chromium_src-9d9221f0615f685b209ee5240a8e8e0cb8118454.tar.bz2 |
Revert 262487 "Add net/base/filename_util.h."
> Add net/base/filename_util.h.
>
> Moved some filename-related functions from net_util.h to the new
> filename_util.h .
>
> BUG=276739
> R=piman@chromium.org, rsleevi@chromium.org
> TBR=kalman@chromium.org, piman@chromium.org, sky@chromium.org
>
> Review URL: https://codereview.chromium.org/220253002
TBR=sergeyu@chromium.org
Review URL: https://codereview.chromium.org/228763004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262498 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/filename_util.h')
-rw-r--r-- | net/base/filename_util.h | 116 |
1 files changed, 0 insertions, 116 deletions
diff --git a/net/base/filename_util.h b/net/base/filename_util.h deleted file mode 100644 index 6b151ba..0000000 --- a/net/base/filename_util.h +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2014 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_FILENAME_UTIL_H_ -#define NET_BASE_FILENAME_UTIL_H_ - -#include <string> - -#include "base/strings/string16.h" -#include "net/base/net_export.h" - -class GURL; - -namespace base { -class FilePath; -} - -namespace net { - -// Given the full path to a file name, creates a file: URL. The returned URL -// may not be valid if the input is malformed. -NET_EXPORT GURL FilePathToFileURL(const base::FilePath& path); - -// Converts a file: URL back to a filename that can be passed to the OS. The -// file URL must be well-formed (GURL::is_valid() must return true); we don't -// handle degenerate cases here. Returns true on success, false if it isn't a -// valid file URL. On failure, *file_path will be empty. -NET_EXPORT bool FileURLToFilePath(const GURL& url, base::FilePath* file_path); - -// Generates a filename using the first successful method from the following (in -// order): -// -// 1) The raw Content-Disposition header in |content_disposition| as read from -// the network. |referrer_charset| is used to decode non-ASCII strings. -// 2) |suggested_name| if specified. |suggested_name| is assumed to be in -// UTF-8. -// 3) The filename extracted from the |url|. |referrer_charset| will be used to -// interpret the URL if there are non-ascii characters. -// 4) |default_name|. If non-empty, |default_name| is assumed to be a filename -// and shouldn't contain a path. |default_name| is not subject to validation -// or sanitization, and therefore shouldn't be a user supplied string. -// 5) The hostname portion from the |url| -// -// Then, leading and trailing '.'s will be removed. On Windows, trailing spaces -// are also removed. The string "download" is the final fallback if no filename -// is found or the filename is empty. -// -// Any illegal characters in the filename will be replaced by '-'. If the -// filename doesn't contain an extension, and a |mime_type| is specified, the -// preferred extension for the |mime_type| will be appended to the filename. -// The resulting filename is then checked against a list of reserved names on -// Windows. If the name is reserved, an underscore will be prepended to the -// filename. -// -// Note: |mime_type| should only be specified if this function is called from a -// thread that allows IO. -NET_EXPORT base::string16 GetSuggestedFilename( - const GURL& url, - const std::string& content_disposition, - const std::string& referrer_charset, - const std::string& suggested_name, - const std::string& mime_type, - const std::string& default_name); - -// Similar to GetSuggestedFilename(), but returns a FilePath. -NET_EXPORT base::FilePath GenerateFileName( - const GURL& url, - const std::string& content_disposition, - const std::string& referrer_charset, - const std::string& suggested_name, - const std::string& mime_type, - const std::string& default_name); - -// Valid components: -// * are not empty -// * are not Windows reserved names (CON, NUL.zip, etc.) -// * do not have trailing separators -// * do not equal kCurrentDirectory -// * do not reference the parent directory -// * do not contain illegal characters -// * do not end with Windows shell-integrated extensions (even on posix) -// * do not begin with '.' (which would hide them in most file managers) -// * do not end with ' ' or '.' -NET_EXPORT bool IsSafePortablePathComponent(const base::FilePath& component); - -// Basenames of valid relative paths are IsSafePortableBasename(), and internal -// path components of valid relative paths are valid path components as -// described above IsSafePortableBasename(). Valid relative paths are not -// absolute paths. -NET_EXPORT bool IsSafePortableRelativePath(const base::FilePath& path); - -// Ensures that the filename and extension is safe to use in the filesystem. -// -// Assumes that |file_path| already contains a valid path or file name. On -// Windows if the extension causes the file to have an unsafe interaction with -// the shell (see net_util::IsShellIntegratedExtension()), then it will be -// replaced by the string 'download'. If |file_path| doesn't contain an -// extension or |ignore_extension| is true then the preferred extension, if one -// exists, for |mime_type| will be used as the extension. -// -// On Windows, the filename will be checked against a set of reserved names, and -// if so, an underscore will be prepended to the name. -// -// |file_name| can either be just the file name or it can be a full path to a -// file. -// -// Note: |mime_type| should only be non-empty if this function is called from a -// thread that allows IO. -NET_EXPORT void GenerateSafeFileName(const std::string& mime_type, - bool ignore_extension, - base::FilePath* file_path); - -} // namespace net - -#endif // NET_BASE_FILENAME_UTIL_H_ |