OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include "webkit/glue/simple_webmimeregistry_impl.h" | 5 #include "webkit/glue/simple_webmimeregistry_impl.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "net/base/mime_util.h" | 9 #include "net/base/mime_util.h" |
10 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" | 10 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 return WebMimeRegistry::IsNotSupported; | 47 return WebMimeRegistry::IsNotSupported; |
48 return WebMimeRegistry::IsSupported; | 48 return WebMimeRegistry::IsSupported; |
49 } | 49 } |
50 | 50 |
51 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType( | 51 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType( |
52 const WebString& mime_type, const WebString& codecs) { | 52 const WebString& mime_type, const WebString& codecs) { |
53 // Not supporting the container is a flat-out no. | 53 // Not supporting the container is a flat-out no. |
54 if (!net::IsSupportedMediaMimeType(ToASCIIOrEmpty(mime_type).c_str())) | 54 if (!net::IsSupportedMediaMimeType(ToASCIIOrEmpty(mime_type).c_str())) |
55 return IsNotSupported; | 55 return IsNotSupported; |
56 | 56 |
| 57 // Check list of strict codecs to see if it is supported. |
| 58 if (net::IsStrictMediaMimeType(ToASCIIOrEmpty(mime_type).c_str())) { |
| 59 // We support the container, but no codecs were specified. |
| 60 if (codecs.isNull()) |
| 61 return MayBeSupported; |
| 62 |
| 63 // Check if the codecs are a perfect match. |
| 64 std::vector<std::string> strict_codecs; |
| 65 net::ParseCodecString(ToASCIIOrEmpty(codecs).c_str(), |
| 66 &strict_codecs, |
| 67 false); |
| 68 if (!net::IsSupportedStrictMediaMimeType(ToASCIIOrEmpty(mime_type).c_str(), |
| 69 strict_codecs)) |
| 70 return IsNotSupported; |
| 71 |
| 72 // Good to go! |
| 73 return IsSupported; |
| 74 } |
| 75 |
57 // If we don't recognize the codec, it's possible we support it. | 76 // If we don't recognize the codec, it's possible we support it. |
58 std::vector<std::string> parsed_codecs; | 77 std::vector<std::string> parsed_codecs; |
59 net::ParseCodecString(ToASCIIOrEmpty(codecs).c_str(), &parsed_codecs); | 78 net::ParseCodecString(ToASCIIOrEmpty(codecs).c_str(), &parsed_codecs, true); |
60 if (!net::AreSupportedMediaCodecs(parsed_codecs)) | 79 if (!net::AreSupportedMediaCodecs(parsed_codecs)) |
61 return MayBeSupported; | 80 return MayBeSupported; |
62 | 81 |
63 // Otherwise we have a perfect match. | 82 // Otherwise we have a perfect match. |
64 return IsSupported; | 83 return IsSupported; |
65 } | 84 } |
66 | 85 |
67 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsNonImageMIMETyp
e( | 86 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsNonImageMIMETyp
e( |
68 const WebString& mime_type) { | 87 const WebString& mime_type) { |
69 if (!net::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type).c_str())) | 88 if (!net::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type).c_str())) |
(...skipping 19 matching lines...) Expand all Loading... |
89 | 108 |
90 WebString SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType( | 109 WebString SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType( |
91 const WebString& mime_type) { | 110 const WebString& mime_type) { |
92 FilePath::StringType file_extension; | 111 FilePath::StringType file_extension; |
93 net::GetPreferredExtensionForMimeType(ToASCIIOrEmpty(mime_type), | 112 net::GetPreferredExtensionForMimeType(ToASCIIOrEmpty(mime_type), |
94 &file_extension); | 113 &file_extension); |
95 return FilePathStringToWebString(file_extension); | 114 return FilePathStringToWebString(file_extension); |
96 } | 115 } |
97 | 116 |
98 } // namespace webkit_glue | 117 } // namespace webkit_glue |
OLD | NEW |