diff options
Diffstat (limited to 'net/base/mime_util.cc')
-rw-r--r-- | net/base/mime_util.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc index 62788dc..2880fa19 100644 --- a/net/base/mime_util.cc +++ b/net/base/mime_util.cc @@ -17,6 +17,27 @@ using std::string; +namespace { + +struct MediaType { + const char name[12]; + const char matcher[13]; +}; + +static const MediaType kIanaMediaTypes[] = { + { "application", "application/" }, + { "audio", "audio/" }, + { "example", "example/" }, + { "image", "image/" }, + { "message", "message/" }, + { "model", "model/" }, + { "multipart", "multipart/" }, + { "text", "text/" }, + { "video", "video/" }, +}; + +} // namespace + namespace net { // Singleton utility class for mime types. @@ -871,4 +892,13 @@ void GetMediaCodecsBlacklistedForTests(std::vector<std::string>* codecs) { #endif } +const std::string GetIANAMediaType(const std::string& mime_type) { + for (size_t i = 0; i < arraysize(kIanaMediaTypes); ++i) { + if (StartsWithASCII(mime_type, kIanaMediaTypes[i].matcher, true)) { + return kIanaMediaTypes[i].name; + } + } + return ""; +} + } // namespace net |