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

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: 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
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/supported_key_systems.h"
13 14
14 using WebKit::WebString; 15 using WebKit::WebString;
15 using WebKit::WebMimeRegistry; 16 using WebKit::WebMimeRegistry;
17 using webkit_media::SupportedKeySystems;
16 18
17 namespace { 19 namespace {
18 20
19 // Convert a WebString to ASCII, falling back on an empty string in the case 21 // Convert a WebString to ASCII, falling back on an empty string in the case
20 // of a non-ASCII string. 22 // of a non-ASCII string.
21 std::string ToASCIIOrEmpty(const WebString& string) { 23 std::string ToASCIIOrEmpty(const WebString& string) {
22 return IsStringASCII(string) ? UTF16ToASCII(string) : std::string(); 24 return IsStringASCII(string) ? UTF16ToASCII(string) : std::string();
23 } 25 }
24 26
25 } // namespace 27 } // namespace
(...skipping 12 matching lines...) Expand all
38 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; 40 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
39 } 41 }
40 42
41 WebMimeRegistry::SupportsType 43 WebMimeRegistry::SupportsType
42 SimpleWebMimeRegistryImpl::supportsJavaScriptMIMEType( 44 SimpleWebMimeRegistryImpl::supportsJavaScriptMIMEType(
43 const WebString& mime_type) { 45 const WebString& mime_type) {
44 return net::IsSupportedJavascriptMimeType(ToASCIIOrEmpty(mime_type)) ? 46 return net::IsSupportedJavascriptMimeType(ToASCIIOrEmpty(mime_type)) ?
45 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; 47 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
46 } 48 }
47 49
50 // When debugging layout tests failures in the test shell,
51 // see TestShellWebMimeRegistryImpl.
52 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType(
53 const WebString& mime_type, const WebString& codecs) {
54 return supportsMediaMIMEType(mime_type, codecs, WebString());
55 }
56
48 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType( 57 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType(
49 const WebString& mime_type, 58 const WebString& mime_type,
50 const WebString& codecs) { 59 const WebString& codecs,
60 const WebString& keySystem) {
scherkus (not reviewing) 2012/04/12 20:18:41 key_system
ddorwin 2012/04/12 23:41:23 Done.
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(ToASCIIOrEmpty(mime_type)))
53 return IsNotSupported; 63 return IsNotSupported;
54 64
65 if (!keySystem.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 (!SupportedKeySystems::isKeySystemSupported(keySystem))
70 return IsNotSupported;
71
72 std::vector<std::string> strict_codecs;
73 net::ParseCodecString(ToASCIIOrEmpty(codecs).c_str(),
scherkus (not reviewing) 2012/04/12 20:18:41 does this need to be c_str()? the calling function
ddorwin 2012/04/12 23:41:23 Done.
74 &strict_codecs,
75 false);
76
77 if (!SupportedKeySystems::IsSupportedKeySystemWithMediaMimeType(
78 ToASCIIOrEmpty(mime_type).c_str(),
scherkus (not reviewing) 2012/04/12 20:18:41 ditto here
ddorwin 2012/04/12 23:41:23 Done.
79 strict_codecs,
80 ToASCIIOrEmpty(keySystem).c_str()))
81 return IsNotSupported;
82
83 // Continue processing the mime_type and codecs.
84 }
85
55 // Check list of strict codecs to see if it is supported. 86 // Check list of strict codecs to see if it is supported.
56 if (net::IsStrictMediaMimeType(ToASCIIOrEmpty(mime_type))) { 87 if (net::IsStrictMediaMimeType(ToASCIIOrEmpty(mime_type))) {
57 // We support the container, but no codecs were specified. 88 // We support the container, but no codecs were specified.
58 if (codecs.isNull()) 89 if (codecs.isNull())
59 return MayBeSupported; 90 return MayBeSupported;
60 91
61 // Check if the codecs are a perfect match. 92 // Check if the codecs are a perfect match.
62 std::vector<std::string> strict_codecs; 93 std::vector<std::string> strict_codecs;
63 net::ParseCodecString(ToASCIIOrEmpty(codecs).c_str(), &strict_codecs, 94 net::ParseCodecString(ToASCIIOrEmpty(codecs).c_str(), &strict_codecs,
64 false); 95 false);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 144
114 WebString SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType( 145 WebString SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType(
115 const WebString& mime_type) { 146 const WebString& mime_type) {
116 FilePath::StringType file_extension; 147 FilePath::StringType file_extension;
117 net::GetPreferredExtensionForMimeType(ToASCIIOrEmpty(mime_type), 148 net::GetPreferredExtensionForMimeType(ToASCIIOrEmpty(mime_type),
118 &file_extension); 149 &file_extension);
119 return FilePathStringToWebString(file_extension); 150 return FilePathStringToWebString(file_extension);
120 } 151 }
121 152
122 } // namespace webkit_glue 153 } // namespace webkit_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698