Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: net/base/mime_util.h

Issue 1123343007: iOS experiments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added media_blink dependency on media_mime_util Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/media.gyp ('k') | net/base/mime_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This file defines MIME utility functions. All of them assume the MIME type 8 // This file defines MIME utility functions. All of them assume the MIME type
9 // to be of the format specified by rfc2045. According to it, MIME types are 9 // to be of the format specified by rfc2045. According to it, MIME types are
10 // case strongly insensitive except parameter values, which may or may not be 10 // case strongly insensitive except parameter values, which may or may not be
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 NET_EXPORT bool GetMimeTypeFromFile(const base::FilePath& file_path, 43 NET_EXPORT bool GetMimeTypeFromFile(const base::FilePath& file_path,
44 std::string* mime_type); 44 std::string* mime_type);
45 45
46 // Get the preferred extension (if any) associated with the given mime type. 46 // Get the preferred extension (if any) associated with the given mime type.
47 // Returns true if a corresponding file extension exists. The extension is 47 // Returns true if a corresponding file extension exists. The extension is
48 // returned without a prefixed dot, ex "html". 48 // returned without a prefixed dot, ex "html".
49 NET_EXPORT bool GetPreferredExtensionForMimeType( 49 NET_EXPORT bool GetPreferredExtensionForMimeType(
50 const std::string& mime_type, 50 const std::string& mime_type,
51 base::FilePath::StringType* extension); 51 base::FilePath::StringType* extension);
52 52
53 // Check to see if a particular MIME type is in our list.
54 NET_EXPORT bool IsSupportedMediaMimeType(const std::string& mime_type);
55
56 // Returns true if this the mime_type_pattern matches a given mime-type. 53 // Returns true if this the mime_type_pattern matches a given mime-type.
57 // Checks for absolute matching and wildcards. MIME types are case insensitive. 54 // Checks for absolute matching and wildcards. MIME types are case insensitive.
58 NET_EXPORT bool MatchesMimeType(const std::string& mime_type_pattern, 55 NET_EXPORT bool MatchesMimeType(const std::string& mime_type_pattern,
59 const std::string& mime_type); 56 const std::string& mime_type);
60 57
61 // 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
62 // with no parameter, i.e. string that matches the following ABNF (see the 59 // with no parameter, i.e. string that matches the following ABNF (see the
63 // definition of content ABNF in RFC2045 and media-type ABNF httpbis p2 60 // definition of content ABNF in RFC2045 and media-type ABNF httpbis p2
64 // semantics). 61 // semantics).
65 // 62 //
66 // token "/" token 63 // token "/" token
67 // 64 //
68 // If |top_level_type| is non-NULL, sets it to parsed top-level type string. 65 // If |top_level_type| is non-NULL, sets it to parsed top-level type string.
69 // If |subtype| is non-NULL, sets it to parsed subtype string. 66 // If |subtype| is non-NULL, sets it to parsed subtype string.
70 NET_EXPORT bool ParseMimeTypeWithoutParameter(const std::string& type_string, 67 NET_EXPORT bool ParseMimeTypeWithoutParameter(const std::string& type_string,
71 std::string* top_level_type, 68 std::string* top_level_type,
72 std::string* subtype); 69 std::string* subtype);
73 70
74 // Returns true if the |type_string| is a top-level type of any media type 71 // Returns true if the |type_string| is a top-level type of any media type
75 // registered with IANA media types registry at 72 // registered with IANA media types registry at
76 // http://www.iana.org/assignments/media-types/media-types.xhtml or an 73 // http://www.iana.org/assignments/media-types/media-types.xhtml or an
77 // experimental type (type with x- prefix). 74 // experimental type (type with x- prefix).
78 // 75 //
79 // This method doesn't check that the input conforms to token ABNF, so if input 76 // This method doesn't check that the input conforms to token ABNF, so if input
80 // is experimental type strings, you need to check check that before using 77 // is experimental type strings, you need to check check that before using
81 // this method. 78 // this method.
82 NET_EXPORT bool IsValidTopLevelMimeType(const std::string& type_string); 79 NET_EXPORT bool IsValidTopLevelMimeType(const std::string& type_string);
83 80
84 // Returns true if and only if all codecs are supported, false otherwise.
85 NET_EXPORT bool AreSupportedMediaCodecs(const std::vector<std::string>& codecs);
86
87 // Parses a codec string, populating |codecs_out| with the prefix of each codec
88 // in the string |codecs_in|. For example, passed "aaa.b.c,dd.eee", if
89 // |strip| == true |codecs_out| will contain {"aaa", "dd"}, if |strip| == false
90 // |codecs_out| will contain {"aaa.b.c", "dd.eee"}.
91 // See http://www.ietf.org/rfc/rfc4281.txt.
92 NET_EXPORT void ParseCodecString(const std::string& codecs,
93 std::vector<std::string>* codecs_out,
94 bool strip);
95
96 // Check to see if a particular MIME type is in our list which only supports a
97 // certain subset of codecs.
98 NET_EXPORT bool IsStrictMediaMimeType(const std::string& mime_type);
99
100 // Indicates that the MIME type and (possible codec string) are supported by the
101 // underlying platform.
102 enum SupportsType {
103 // The underlying platform is known not to support the given MIME type and
104 // codec combination.
105 IsNotSupported,
106
107 // The underlying platform is known to support the given MIME type and codec
108 // combination.
109 IsSupported,
110
111 // The underlying platform is unsure whether the given MIME type and codec
112 // combination can be rendered or not before actually trying to play it.
113 MayBeSupported
114 };
115
116 // Checks the |mime_type| and |codecs| against the MIME types known to support
117 // only a particular subset of codecs.
118 // * Returns IsSupported if the |mime_type| is supported and all the codecs
119 // within the |codecs| are supported for the |mime_type|.
120 // * Returns MayBeSupported if the |mime_type| is supported and is known to
121 // support only a subset of codecs, but |codecs| was empty. Also returned if
122 // all the codecs in |codecs| are supported, but additional codec parameters
123 // were supplied (such as profile) for which the support cannot be decided.
124 // * Returns IsNotSupported if either the |mime_type| is not supported or the
125 // |mime_type| is supported but at least one of the codecs within |codecs| is
126 // not supported for the |mime_type|.
127 NET_EXPORT SupportsType IsSupportedStrictMediaMimeType(
128 const std::string& mime_type,
129 const std::vector<std::string>& codecs);
130
131 // Get the extensions associated with the given mime type. There could be 81 // Get the extensions associated with the given mime type. There could be
132 // multiple extensions for a given mime type, like "html,htm" for "text/html", 82 // multiple extensions for a given mime type, like "html,htm" for "text/html",
133 // or "txt,text,html,..." for "text/*". 83 // or "txt,text,html,..." for "text/*".
134 // Note that we do not erase the existing elements in the the provided vector. 84 // Note that we do not erase the existing elements in the the provided vector.
135 // Instead, we append the result to it. 85 // Instead, we append the result to it.
136 NET_EXPORT void GetExtensionsForMimeType( 86 NET_EXPORT void GetExtensionsForMimeType(
137 const std::string& mime_type, 87 const std::string& mime_type,
138 std::vector<base::FilePath::StringType>* extensions); 88 std::vector<base::FilePath::StringType>* extensions);
139 89
140 // Test only method that removes proprietary media types and codecs from the
141 // list of supported MIME types and codecs. These types and codecs must be
142 // removed to ensure consistent layout test results across all Chromium
143 // variations.
144 NET_EXPORT void RemoveProprietaryMediaTypesAndCodecsForTests();
145
146 // A list of supported certificate-related mime types. 90 // A list of supported certificate-related mime types.
147 // 91 //
148 // A Java counterpart will be generated for this enum. 92 // A Java counterpart will be generated for this enum.
149 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net 93 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net
150 enum CertificateMimeType { 94 enum CertificateMimeType {
151 CERTIFICATE_MIME_TYPE_UNKNOWN, 95 CERTIFICATE_MIME_TYPE_UNKNOWN,
152 CERTIFICATE_MIME_TYPE_X509_USER_CERT, 96 CERTIFICATE_MIME_TYPE_X509_USER_CERT,
153 CERTIFICATE_MIME_TYPE_X509_CA_CERT, 97 CERTIFICATE_MIME_TYPE_X509_CA_CERT,
154 CERTIFICATE_MIME_TYPE_PKCS12_ARCHIVE, 98 CERTIFICATE_MIME_TYPE_PKCS12_ARCHIVE,
155 }; 99 };
156 100
157 // Prepares one value as part of a multi-part upload request. 101 // Prepares one value as part of a multi-part upload request.
158 NET_EXPORT void AddMultipartValueForUpload(const std::string& value_name, 102 NET_EXPORT void AddMultipartValueForUpload(const std::string& value_name,
159 const std::string& value, 103 const std::string& value,
160 const std::string& mime_boundary, 104 const std::string& mime_boundary,
161 const std::string& content_type, 105 const std::string& content_type,
162 std::string* post_data); 106 std::string* post_data);
163 107
164 // Adds the final delimiter to a multi-part upload request. 108 // Adds the final delimiter to a multi-part upload request.
165 NET_EXPORT void AddMultipartFinalDelimiterForUpload( 109 NET_EXPORT void AddMultipartFinalDelimiterForUpload(
166 const std::string& mime_boundary, 110 const std::string& mime_boundary,
167 std::string* post_data); 111 std::string* post_data);
168 112
169 } // namespace net 113 } // namespace net
170 114
171 #endif // NET_BASE_MIME_UTIL_H__ 115 #endif // NET_BASE_MIME_UTIL_H__
OLDNEW
« no previous file with comments | « media/media.gyp ('k') | net/base/mime_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698