OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_BASE_MIME_UTIL_H__ | 5 #ifndef NET_BASE_MIME_UTIL_H__ |
6 #define NET_BASE_MIME_UTIL_H__ | 6 #define NET_BASE_MIME_UTIL_H__ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 // Convenience function. | 49 // Convenience function. |
50 NET_EXPORT bool IsSupportedMimeType(const std::string& mime_type); | 50 NET_EXPORT bool IsSupportedMimeType(const std::string& mime_type); |
51 | 51 |
52 // Returns true if this the mime_type_pattern matches a given mime-type. | 52 // Returns true if this the mime_type_pattern matches a given mime-type. |
53 // Checks for absolute matching and wildcards. mime-types should be in | 53 // Checks for absolute matching and wildcards. mime-types should be in |
54 // lower case. | 54 // lower case. |
55 NET_EXPORT bool MatchesMimeType(const std::string& mime_type_pattern, | 55 NET_EXPORT bool MatchesMimeType(const std::string& mime_type_pattern, |
56 const std::string& mime_type); | 56 const std::string& mime_type); |
57 | 57 |
58 // Returns true if the |type_string| is a correctly-formed mime type specifier. | 58 // Returns true if the |type_string| is a correctly-formed mime type specifier |
59 // Allows strings of the form x/y[;params], where "x" is a legal mime type name. | 59 // with no parameter, i.e. string that matches the following ABNF (see the |
60 // Also allows wildcard types -- "x/*", "*/*", and "*". | 60 // definition of content ABNF in RFC2045 and media-type ABNF httpbis p2 |
61 NET_EXPORT bool IsMimeType(const std::string& type_string); | 61 // semantics). |
| 62 // |
| 63 // token "/" token |
| 64 // |
| 65 // If |top_level_type| is non-NULL, sets it to parsed top-level type string. |
| 66 // If |subtype| is non-NULL, sets it to parsed subtype string. |
| 67 NET_EXPORT bool ParseMimeTypeWithoutParameter(const std::string& type_string, |
| 68 std::string* top_level_type, |
| 69 std::string* subtype); |
| 70 |
| 71 // Returns true if the |type_string| is a top-level type of any media type |
| 72 // registered with IANA media types registry at |
| 73 // http://www.iana.org/assignments/media-types/media-types.xhtml or an |
| 74 // experimental type (type with x- prefix). |
| 75 // |
| 76 // This method doesn't check that the input conforms to token ABNF, so if input |
| 77 // is experimental type strings, you need to check check that before using |
| 78 // this method. |
| 79 NET_EXPORT bool IsValidTopLevelMimeType(const std::string& type_string); |
62 | 80 |
63 // Returns true if and only if all codecs are supported, false otherwise. | 81 // Returns true if and only if all codecs are supported, false otherwise. |
64 NET_EXPORT bool AreSupportedMediaCodecs(const std::vector<std::string>& codecs); | 82 NET_EXPORT bool AreSupportedMediaCodecs(const std::vector<std::string>& codecs); |
65 | 83 |
66 // Parses a codec string, populating |codecs_out| with the prefix of each codec | 84 // Parses a codec string, populating |codecs_out| with the prefix of each codec |
67 // in the string |codecs_in|. For example, passed "aaa.b.c,dd.eee", if | 85 // in the string |codecs_in|. For example, passed "aaa.b.c,dd.eee", if |
68 // |strip| == true |codecs_out| will contain {"aaa", "dd"}, if |strip| == false | 86 // |strip| == true |codecs_out| will contain {"aaa", "dd"}, if |strip| == false |
69 // |codecs_out| will contain {"aaa.b.c", "dd.eee"}. | 87 // |codecs_out| will contain {"aaa.b.c", "dd.eee"}. |
70 // See http://www.ietf.org/rfc/rfc4281.txt. | 88 // See http://www.ietf.org/rfc/rfc4281.txt. |
71 NET_EXPORT void ParseCodecString(const std::string& codecs, | 89 NET_EXPORT void ParseCodecString(const std::string& codecs, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 std::string* post_data); | 142 std::string* post_data); |
125 | 143 |
126 // Adds the final delimiter to a multi-part upload request. | 144 // Adds the final delimiter to a multi-part upload request. |
127 NET_EXPORT void AddMultipartFinalDelimiterForUpload( | 145 NET_EXPORT void AddMultipartFinalDelimiterForUpload( |
128 const std::string& mime_boundary, | 146 const std::string& mime_boundary, |
129 std::string* post_data); | 147 std::string* post_data); |
130 | 148 |
131 } // namespace net | 149 } // namespace net |
132 | 150 |
133 #endif // NET_BASE_MIME_UTIL_H__ | 151 #endif // NET_BASE_MIME_UTIL_H__ |
OLD | NEW |