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 | |
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
-rw-r--r-- | net/base/mime_util.cc | 42 | ||||
-rw-r--r-- | net/base/mime_util.h | 3 | ||||
-rw-r--r-- | webkit/api/public/WebMimeRegistry.h | 1 | ||||
-rw-r--r-- | webkit/api/src/WebMediaPlayerClientImpl.cpp | 10 | ||||
-rw-r--r-- | webkit/glue/simple_webmimeregistry_impl.cc | 5 | ||||
-rw-r--r-- | webkit/glue/simple_webmimeregistry_impl.h | 1 |
6 files changed, 55 insertions, 7 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); } diff --git a/net/base/mime_util.h b/net/base/mime_util.h index 3bd6f85..6ae4a55 100644 --- a/net/base/mime_util.h +++ b/net/base/mime_util.h @@ -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. @@ -28,6 +28,7 @@ bool GetPreferredExtensionForMimeType(const std::string& mime_type, // Check to see if a particular MIME type is in our list. bool IsSupportedImageMimeType(const char* mime_type); +bool IsSupportedMediaMimeType(const char* mime_type); bool IsSupportedNonImageMimeType(const char* mime_type); bool IsSupportedJavascriptMimeType(const char* mime_type); diff --git a/webkit/api/public/WebMimeRegistry.h b/webkit/api/public/WebMimeRegistry.h index 40e5c98..100331f 100644 --- a/webkit/api/public/WebMimeRegistry.h +++ b/webkit/api/public/WebMimeRegistry.h @@ -40,6 +40,7 @@ namespace WebKit { public: virtual bool supportsImageMIMEType(const WebString& mimeType) = 0; virtual bool supportsJavaScriptMIMEType(const WebString& mimeType) = 0; + virtual bool supportsMediaMIMEType(const WebString& mimeType) = 0; virtual bool supportsNonImageMIMEType(const WebString& mimeType) = 0; virtual WebString mimeTypeForExtension(const WebString& fileExtension) = 0; diff --git a/webkit/api/src/WebMediaPlayerClientImpl.cpp b/webkit/api/src/WebMediaPlayerClientImpl.cpp index 9312516..d4d565a 100644 --- a/webkit/api/src/WebMediaPlayerClientImpl.cpp +++ b/webkit/api/src/WebMediaPlayerClientImpl.cpp @@ -13,6 +13,7 @@ #include "WebKit.h" #include "WebKitClient.h" #include "WebMediaPlayer.h" +#include "WebMimeRegistry.h" #include "WebRect.h" #include "WebSize.h" #include "WebString.h" @@ -326,16 +327,17 @@ MediaPlayerPrivateInterface* WebMediaPlayerClientImpl::create(MediaPlayer* playe void WebMediaPlayerClientImpl::getSupportedTypes(HashSet<String>& supportedTypes) { - // FIXME: decide what to do here, we should fill in the HashSet about - // codecs that we support. + // FIXME: integrate this list with WebMediaPlayerClientImpl::supportsType. notImplemented(); } MediaPlayer::SupportsType WebMediaPlayerClientImpl::supportsType(const String& type, const String& codecs) { - // FIXME: implement this properly. - return MediaPlayer::IsSupported; + // FIXME: respect codecs, now we only check for mime-type. + if (webKitClient()->mimeRegistry()->supportsMediaMIMEType(type)) + return MediaPlayer::IsSupported; + return MediaPlayer::IsNotSupported; } WebMediaPlayerClientImpl::WebMediaPlayerClientImpl() diff --git a/webkit/glue/simple_webmimeregistry_impl.cc b/webkit/glue/simple_webmimeregistry_impl.cc index d678c1b..95c39a1 100644 --- a/webkit/glue/simple_webmimeregistry_impl.cc +++ b/webkit/glue/simple_webmimeregistry_impl.cc @@ -25,6 +25,11 @@ bool SimpleWebMimeRegistryImpl::supportsJavaScriptMIMEType( return net::IsSupportedJavascriptMimeType(UTF16ToASCII(mime_type).c_str()); } +bool SimpleWebMimeRegistryImpl::supportsMediaMIMEType( + const WebString& mime_type) { + return net::IsSupportedMediaMimeType(UTF16ToASCII(mime_type).c_str()); +} + bool SimpleWebMimeRegistryImpl::supportsNonImageMIMEType( const WebString& mime_type) { return net::IsSupportedNonImageMimeType(UTF16ToASCII(mime_type).c_str()); diff --git a/webkit/glue/simple_webmimeregistry_impl.h b/webkit/glue/simple_webmimeregistry_impl.h index 7d5140b..c783ebd 100644 --- a/webkit/glue/simple_webmimeregistry_impl.h +++ b/webkit/glue/simple_webmimeregistry_impl.h @@ -14,6 +14,7 @@ class SimpleWebMimeRegistryImpl : public WebKit::WebMimeRegistry { // WebMimeRegistry methods: virtual bool supportsImageMIMEType(const WebKit::WebString&); virtual bool supportsJavaScriptMIMEType(const WebKit::WebString&); + virtual bool supportsMediaMIMEType(const WebKit::WebString&); virtual bool supportsNonImageMIMEType(const WebKit::WebString&); virtual WebKit::WebString mimeTypeForExtension(const WebKit::WebString&); virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&); |