Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: webkit/glue/simple_webmimeregistry_impl.cc

Issue 10020053: Initial implementation of Encrypted Media Extensions in Chrome. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: removed key_systems namespace Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webkit/glue/simple_webmimeregistry_impl.h ('k') | webkit/media/key_systems.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the 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 "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "net/base/mime_util.h" 10 #include "net/base/mime_util.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
12 #include "webkit/glue/webkit_glue.h" 12 #include "webkit/glue/webkit_glue.h"
13 #include "webkit/media/key_systems.h"
13 14
14 using WebKit::WebString; 15 using WebKit::WebString;
15 using WebKit::WebMimeRegistry; 16 using WebKit::WebMimeRegistry;
16 17
17 namespace { 18 namespace {
18 19
19 // Convert a WebString to ASCII, falling back on an empty string in the case 20 // Convert a WebString to ASCII, falling back on an empty string in the case
20 // of a non-ASCII string. 21 // of a non-ASCII string.
21 std::string ToASCIIOrEmpty(const WebString& string) { 22 std::string ToASCIIOrEmpty(const WebString& string) {
22 return IsStringASCII(string) ? UTF16ToASCII(string) : std::string(); 23 return IsStringASCII(string) ? UTF16ToASCII(string) : std::string();
(...skipping 15 matching lines...) Expand all
38 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; 39 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
39 } 40 }
40 41
41 WebMimeRegistry::SupportsType 42 WebMimeRegistry::SupportsType
42 SimpleWebMimeRegistryImpl::supportsJavaScriptMIMEType( 43 SimpleWebMimeRegistryImpl::supportsJavaScriptMIMEType(
43 const WebString& mime_type) { 44 const WebString& mime_type) {
44 return net::IsSupportedJavascriptMimeType(ToASCIIOrEmpty(mime_type)) ? 45 return net::IsSupportedJavascriptMimeType(ToASCIIOrEmpty(mime_type)) ?
45 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; 46 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
46 } 47 }
47 48
49 // When debugging layout tests failures in the test shell,
50 // see TestShellWebMimeRegistryImpl.
51 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType(
52 const WebString& mime_type, const WebString& codecs) {
53 return supportsMediaMIMEType(mime_type, codecs, WebString());
54 }
55
48 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType( 56 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType(
49 const WebString& mime_type, 57 const WebString& mime_type,
50 const WebString& codecs) { 58 const WebString& codecs,
59 const WebString& key_system) {
60 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type);
51 // Not supporting the container is a flat-out no. 61 // Not supporting the container is a flat-out no.
52 if (!net::IsSupportedMediaMimeType(ToASCIIOrEmpty(mime_type))) 62 if (!net::IsSupportedMediaMimeType(mime_type_ascii))
53 return IsNotSupported; 63 return IsNotSupported;
54 64
65 if (!key_system.isEmpty()) {
66 // Check whether the key system is supported with the mime_type and codecs.
67
68 // Not supporting the key system is a flat-out no.
69 if (!webkit_media::IsSupportedKeySystem(key_system))
70 return IsNotSupported;
71
72 std::vector<std::string> strict_codecs;
73 net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, false);
74
75 if (!webkit_media::IsSupportedKeySystemWithMediaMimeType(
76 mime_type_ascii, strict_codecs, ToASCIIOrEmpty(key_system)))
77 return IsNotSupported;
78
79 // Continue processing the mime_type and codecs.
80 }
81
55 // Check list of strict codecs to see if it is supported. 82 // Check list of strict codecs to see if it is supported.
56 if (net::IsStrictMediaMimeType(ToASCIIOrEmpty(mime_type))) { 83 if (net::IsStrictMediaMimeType(mime_type_ascii)) {
57 // We support the container, but no codecs were specified. 84 // We support the container, but no codecs were specified.
58 if (codecs.isNull()) 85 if (codecs.isNull())
59 return MayBeSupported; 86 return MayBeSupported;
60 87
61 // Check if the codecs are a perfect match. 88 // Check if the codecs are a perfect match.
62 std::vector<std::string> strict_codecs; 89 std::vector<std::string> strict_codecs;
63 net::ParseCodecString(ToASCIIOrEmpty(codecs).c_str(), &strict_codecs, 90 net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, false);
64 false); 91 if (!net::IsSupportedStrictMediaMimeType(mime_type_ascii, strict_codecs))
65 if (!net::IsSupportedStrictMediaMimeType(ToASCIIOrEmpty(mime_type),
66 strict_codecs))
67 return IsNotSupported; 92 return IsNotSupported;
68 93
69 // Good to go! 94 // Good to go!
70 return IsSupported; 95 return IsSupported;
71 } 96 }
72 97
73 // If we don't recognize the codec, it's possible we support it. 98 // If we don't recognize the codec, it's possible we support it.
74 std::vector<std::string> parsed_codecs; 99 std::vector<std::string> parsed_codecs;
75 net::ParseCodecString(ToASCIIOrEmpty(codecs).c_str(), &parsed_codecs, true); 100 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true);
76 if (!net::AreSupportedMediaCodecs(parsed_codecs)) 101 if (!net::AreSupportedMediaCodecs(parsed_codecs))
77 return MayBeSupported; 102 return MayBeSupported;
78 103
79 // Otherwise we have a perfect match. 104 // Otherwise we have a perfect match.
80 return IsSupported; 105 return IsSupported;
81 } 106 }
82 107
83 WebMimeRegistry::SupportsType 108 WebMimeRegistry::SupportsType
84 SimpleWebMimeRegistryImpl::supportsNonImageMIMEType( 109 SimpleWebMimeRegistryImpl::supportsNonImageMIMEType(
85 const WebString& mime_type) { 110 const WebString& mime_type) {
(...skipping 27 matching lines...) Expand all
113 138
114 WebString SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType( 139 WebString SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType(
115 const WebString& mime_type) { 140 const WebString& mime_type) {
116 FilePath::StringType file_extension; 141 FilePath::StringType file_extension;
117 net::GetPreferredExtensionForMimeType(ToASCIIOrEmpty(mime_type), 142 net::GetPreferredExtensionForMimeType(ToASCIIOrEmpty(mime_type),
118 &file_extension); 143 &file_extension);
119 return FilePathStringToWebString(file_extension); 144 return FilePathStringToWebString(file_extension);
120 } 145 }
121 146
122 } // namespace webkit_glue 147 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/simple_webmimeregistry_impl.h ('k') | webkit/media/key_systems.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698