1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Functions used internally by filename_util, and filename_util_icu.
7 #ifndef NET_BASE_FILENAME_UTIL_INTERNAL_H_
8 #define NET_BASE_FILENAME_UTIL_INTERNAL_H_
12 #include "base/callback.h"
13 #include "base/files/file_path.h"
14 #include "base/strings/string16.h"
20 typedef base::Callback
<
21 void(base::FilePath::StringType
* file_name
, char replace_char
)>
22 ReplaceIllegalCharactersCallback
;
24 void SanitizeGeneratedFileName(base::FilePath::StringType
* filename
,
25 bool replace_trailing
);
27 bool IsShellIntegratedExtension(const base::FilePath::StringType
& extension
);
29 bool IsReservedName(const base::FilePath::StringType
& filename
);
31 void EnsureSafeExtension(const std::string
& mime_type
,
32 bool ignore_extension
,
33 base::FilePath
* file_name
);
35 bool FilePathToString16(const base::FilePath
& path
, base::string16
* converted
);
37 // Similar to GetSuggestedFilename(), but takes callback to replace illegal
39 base::string16
GetSuggestedFilenameImpl(
41 const std::string
& content_disposition
,
42 const std::string
& referrer_charset
,
43 const std::string
& suggested_name
,
44 const std::string
& mime_type
,
45 const std::string
& default_name
,
46 ReplaceIllegalCharactersCallback replace_illegal_characters_callback
);
48 // Similar to GenerateFileName(), but takes callback to replace illegal
50 base::FilePath
GenerateFileNameImpl(
52 const std::string
& content_disposition
,
53 const std::string
& referrer_charset
,
54 const std::string
& suggested_name
,
55 const std::string
& mime_type
,
56 const std::string
& default_name
,
57 ReplaceIllegalCharactersCallback replace_illegal_characters_callback
);
61 #endif // NET_BASE_FILENAME_UTIL_INTERNAL_H_