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
Esse commit está contido em:
+40
-2
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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&);
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário