Chromium Code Reviews| 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 |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 | 15 |
| 16 // Get the mime type (if any) that is associated with the given file extension. | 16 // Get the mime type (if any) that is associated with the given file extension. |
| 17 // Returns true if a corresponding mime type exists. | 17 // Returns true if a corresponding mime type exists. |
| 18 NET_EXPORT bool GetMimeTypeFromExtension(const FilePath::StringType& ext, | 18 NET_EXPORT bool GetMimeTypeFromExtension(const base::FilePath::StringType& ext, |
|
Mattias Nissler (ping if slow)
2013/02/06 17:53:33
unrelated changes?
Jói
2013/02/07 14:52:32
Correct, as in pref_member.h. Removed.
| |
| 19 std::string* mime_type); | 19 std::string* mime_type); |
| 20 | 20 |
| 21 // Get the mime type (if any) that is associated with the given file extension. | 21 // Get the mime type (if any) that is associated with the given file extension. |
| 22 // Returns true if a corresponding mime type exists. In this method, | 22 // Returns true if a corresponding mime type exists. In this method, |
| 23 // the search for a mime type is constrained to a limited set of | 23 // the search for a mime type is constrained to a limited set of |
| 24 // types known to the net library, the OS/registry is not consulted. | 24 // types known to the net library, the OS/registry is not consulted. |
| 25 NET_EXPORT bool GetWellKnownMimeTypeFromExtension( | 25 NET_EXPORT bool GetWellKnownMimeTypeFromExtension( |
| 26 const FilePath::StringType& ext, | 26 const base::FilePath::StringType& ext, |
| 27 std::string* mime_type); | 27 std::string* mime_type); |
| 28 | 28 |
| 29 // Get the mime type (if any) that is associated with the given file. Returns | 29 // Get the mime type (if any) that is associated with the given file. Returns |
| 30 // true if a corresponding mime type exists. | 30 // true if a corresponding mime type exists. |
| 31 NET_EXPORT bool GetMimeTypeFromFile(const FilePath& file_path, | 31 NET_EXPORT bool GetMimeTypeFromFile(const FilePath& file_path, |
| 32 std::string* mime_type); | 32 std::string* mime_type); |
| 33 | 33 |
| 34 // Get the preferred extension (if any) associated with the given mime type. | 34 // Get the preferred extension (if any) associated with the given mime type. |
| 35 // Returns true if a corresponding file extension exists. The extension is | 35 // Returns true if a corresponding file extension exists. The extension is |
| 36 // returned without a prefixed dot, ex "html". | 36 // returned without a prefixed dot, ex "html". |
| 37 NET_EXPORT bool GetPreferredExtensionForMimeType( | 37 NET_EXPORT bool GetPreferredExtensionForMimeType( |
| 38 const std::string& mime_type, | 38 const std::string& mime_type, |
| 39 FilePath::StringType* extension); | 39 base::FilePath::StringType* extension); |
| 40 | 40 |
| 41 // Check to see if a particular MIME type is in our list. | 41 // Check to see if a particular MIME type is in our list. |
| 42 NET_EXPORT bool IsSupportedImageMimeType(const std::string& mime_type); | 42 NET_EXPORT bool IsSupportedImageMimeType(const std::string& mime_type); |
| 43 NET_EXPORT bool IsSupportedMediaMimeType(const std::string& mime_type); | 43 NET_EXPORT bool IsSupportedMediaMimeType(const std::string& mime_type); |
| 44 NET_EXPORT bool IsSupportedNonImageMimeType(const std::string& mime_type); | 44 NET_EXPORT bool IsSupportedNonImageMimeType(const std::string& mime_type); |
| 45 NET_EXPORT bool IsUnsupportedTextMimeType(const std::string& mime_type); | 45 NET_EXPORT bool IsUnsupportedTextMimeType(const std::string& mime_type); |
| 46 NET_EXPORT bool IsSupportedJavascriptMimeType(const std::string& mime_type); | 46 NET_EXPORT bool IsSupportedJavascriptMimeType(const std::string& mime_type); |
| 47 NET_EXPORT bool IsSupportedCertificateMimeType(const std::string& mime_type); | 47 NET_EXPORT bool IsSupportedCertificateMimeType(const std::string& mime_type); |
| 48 | 48 |
| 49 // Convenience function. | 49 // Convenience function. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 const std::string& mime_type, | 85 const std::string& mime_type, |
| 86 const std::vector<std::string>& codecs); | 86 const std::vector<std::string>& codecs); |
| 87 | 87 |
| 88 // Get the extensions associated with the given mime type. This should be passed | 88 // Get the extensions associated with the given mime type. This should be passed |
| 89 // in lower case. There could be multiple extensions for a given mime type, like | 89 // in lower case. There could be multiple extensions for a given mime type, like |
| 90 // "html,htm" for "text/html", or "txt,text,html,..." for "text/*". | 90 // "html,htm" for "text/html", or "txt,text,html,..." for "text/*". |
| 91 // Note that we do not erase the existing elements in the the provided vector. | 91 // Note that we do not erase the existing elements in the the provided vector. |
| 92 // Instead, we append the result to it. | 92 // Instead, we append the result to it. |
| 93 NET_EXPORT void GetExtensionsForMimeType( | 93 NET_EXPORT void GetExtensionsForMimeType( |
| 94 const std::string& mime_type, | 94 const std::string& mime_type, |
| 95 std::vector<FilePath::StringType>* extensions); | 95 std::vector<base::FilePath::StringType>* extensions); |
| 96 | 96 |
| 97 // Test only methods that return lists of proprietary media types and codecs | 97 // Test only methods that return lists of proprietary media types and codecs |
| 98 // that are not supported by all variations of Chromium. | 98 // that are not supported by all variations of Chromium. |
| 99 // These types and codecs must be blacklisted to ensure consistent layout test | 99 // These types and codecs must be blacklisted to ensure consistent layout test |
| 100 // results across all Chromium variations. | 100 // results across all Chromium variations. |
| 101 NET_EXPORT void GetMediaTypesBlacklistedForTests( | 101 NET_EXPORT void GetMediaTypesBlacklistedForTests( |
| 102 std::vector<std::string>* types); | 102 std::vector<std::string>* types); |
| 103 NET_EXPORT void GetMediaCodecsBlacklistedForTests( | 103 NET_EXPORT void GetMediaCodecsBlacklistedForTests( |
| 104 std::vector<std::string>* codecs); | 104 std::vector<std::string>* codecs); |
| 105 | 105 |
| 106 // Returns the IANA media type contained in |mime_type|, or an empty | 106 // Returns the IANA media type contained in |mime_type|, or an empty |
| 107 // string if |mime_type| does not specifify a known media type. | 107 // string if |mime_type| does not specifify a known media type. |
| 108 // Supported media types are defined at: | 108 // Supported media types are defined at: |
| 109 // http://www.iana.org/assignments/media-types/index.html | 109 // http://www.iana.org/assignments/media-types/index.html |
| 110 NET_EXPORT const std::string GetIANAMediaType(const std::string& mime_type); | 110 NET_EXPORT const std::string GetIANAMediaType(const std::string& mime_type); |
| 111 | 111 |
| 112 // A list of supported certificate-related mime types. | 112 // A list of supported certificate-related mime types. |
| 113 enum CertificateMimeType { | 113 enum CertificateMimeType { |
| 114 #define CERTIFICATE_MIME_TYPE(name, value) CERTIFICATE_MIME_TYPE_ ## name = valu e, | 114 #define CERTIFICATE_MIME_TYPE(name, value) CERTIFICATE_MIME_TYPE_ ## name = valu e, |
| 115 #include "net/base/mime_util_certificate_type_list.h" | 115 #include "net/base/mime_util_certificate_type_list.h" |
| 116 #undef CERTIFICATE_MIME_TYPE | 116 #undef CERTIFICATE_MIME_TYPE |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 NET_EXPORT CertificateMimeType GetCertificateMimeTypeForMimeType( | 119 NET_EXPORT CertificateMimeType GetCertificateMimeTypeForMimeType( |
| 120 const std::string& mime_type); | 120 const std::string& mime_type); |
| 121 | 121 |
| 122 } // namespace net | 122 } // namespace net |
| 123 | 123 |
| 124 #endif // NET_BASE_MIME_UTIL_H__ | 124 #endif // NET_BASE_MIME_UTIL_H__ |
| OLD | NEW |