diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-29 20:34:16 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-29 20:34:16 +0000 |
commit | 4a93d168ac89970e222a548f512cd70a54b12901 (patch) | |
tree | 36e82b6c1382e8a376afa88975ec27f31c502c0e /net/base/mime_util.cc | |
parent | 28f9033b54cd783536fd7cc84d6f0ef536dc5105 (diff) | |
download | chromium_src-4a93d168ac89970e222a548f512cd70a54b12901.zip chromium_src-4a93d168ac89970e222a548f512cd70a54b12901.tar.gz chromium_src-4a93d168ac89970e222a548f512cd70a54b12901.tar.bz2 |
Handle mimetype queries for media files
Added code path from WebKit to net::mimt_util to query
supported mime-types for media files.
BUG=12777
Review URL: http://codereview.chromium.org/114060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17225 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/mime_util.cc')
-rw-r--r-- | net/base/mime_util.cc | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc index 9713332..f34645f 100644 --- a/net/base/mime_util.cc +++ b/net/base/mime_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -26,6 +26,7 @@ class MimeUtil : public PlatformMimeUtil { std::string* mime_type) const; bool IsSupportedImageMimeType(const char* mime_type) const; + bool IsSupportedMediaMimeType(const char* mime_type) const; bool IsSupportedNonImageMimeType(const char* mime_type) const; bool IsSupportedJavascriptMimeType(const char* mime_type) const; @@ -47,6 +48,7 @@ private: typedef base::hash_set<std::string> MimeMappings; MimeMappings image_map_; + MimeMappings media_map_; MimeMappings non_image_map_; MimeMappings javascript_map_; MimeMappings view_source_map_; @@ -166,6 +168,28 @@ static const char* const supported_image_types[] = { "image/x-xbitmap" // xbm }; +// TODO(hclam): Integrate this list with |secondary_mappings| above. +static const char* const supported_media_types[] = { + // Ogg. + "audio/ogg", + "video/ogg", + + // MPEG-4. + "application/mp4", + "audio/mp4", + "audio/x-m4a", + "video/mp4", + "video/x-m4v", + + // MP3. + // TODO(hclam): may add "audio/mpeg" and "audio/x-mp3". + "audio/mp3", + + // AAC. + "audio/aac", + "audio/x-aac" +}; + // Note: does not include javascript types list (see supported_javascript_types) static const char* const supported_non_image_types[] = { "text/html", @@ -217,11 +241,17 @@ void MimeUtil::InitializeMimeTypeMaps() { for (size_t i = 0; i < arraysize(supported_image_types); ++i) image_map_.insert(supported_image_types[i]); - // Initialize the supported non-image types + // Initialize the supported non-image types. for (size_t i = 0; i < arraysize(supported_non_image_types); ++i) non_image_map_.insert(supported_non_image_types[i]); for (size_t i = 0; i < arraysize(supported_javascript_types); ++i) non_image_map_.insert(supported_javascript_types[i]); + for (size_t i = 0; i < arraysize(supported_media_types); ++i) + non_image_map_.insert(supported_media_types[i]); + + // Initialize the supported media types. + for (size_t i = 0; i < arraysize(supported_media_types); ++i) + media_map_.insert(supported_media_types[i]); for (size_t i = 0; i < arraysize(supported_javascript_types); ++i) javascript_map_.insert(supported_javascript_types[i]); @@ -234,6 +264,10 @@ bool MimeUtil::IsSupportedImageMimeType(const char* mime_type) const { return image_map_.find(mime_type) != image_map_.end(); } +bool MimeUtil::IsSupportedMediaMimeType(const char* mime_type) const { + return media_map_.find(mime_type) != media_map_.end(); +} + bool MimeUtil::IsSupportedNonImageMimeType(const char* mime_type) const { return non_image_map_.find(mime_type) != non_image_map_.end(); } @@ -316,6 +350,10 @@ bool IsSupportedImageMimeType(const char* mime_type) { return GetMimeUtil()->IsSupportedImageMimeType(mime_type); } +bool IsSupportedMediaMimeType(const char* mime_type) { + return GetMimeUtil()->IsSupportedMediaMimeType(mime_type); +} + bool IsSupportedNonImageMimeType(const char* mime_type) { return GetMimeUtil()->IsSupportedNonImageMimeType(mime_type); } |