OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/media/crypto/key_systems.h" | 5 #include "content/renderer/media/crypto/key_systems.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "content/public/common/content_client.h" | 12 #include "content/public/common/content_client.h" |
13 #include "content/public/renderer/content_renderer_client.h" | 13 #include "content/public/renderer/content_renderer_client.h" |
14 #include "content/public/renderer/key_system_info.h" | 14 #include "content/public/renderer/key_system_info.h" |
15 #include "content/renderer/media/crypto/key_systems_info.h" | 15 #include "content/renderer/media/crypto/key_systems_info.h" |
16 #include "net/base/mime_util.h" | 16 #include "net/base/mime_util.h" |
17 #include "third_party/WebKit/public/platform/WebCString.h" | 17 #include "third_party/WebKit/public/platform/WebCString.h" |
18 #include "third_party/WebKit/public/platform/WebString.h" | 18 #include "third_party/WebKit/public/platform/WebString.h" |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
22 // Convert a WebString to ASCII, falling back on an empty string in the case | 22 // Convert a WebString to ASCII, falling back on an empty string in the case |
23 // of a non-ASCII string. | 23 // of a non-ASCII string. |
24 static std::string ToASCIIOrEmpty(const WebKit::WebString& string) { | 24 static std::string ToASCIIOrEmpty(const blink::WebString& string) { |
25 return IsStringASCII(string) ? UTF16ToASCII(string) : std::string(); | 25 return IsStringASCII(string) ? UTF16ToASCII(string) : std::string(); |
26 } | 26 } |
27 | 27 |
28 const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; | 28 const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; |
29 | 29 |
30 const char kAudioWebM[] = "audio/webm"; | 30 const char kAudioWebM[] = "audio/webm"; |
31 const char kVideoWebM[] = "video/webm"; | 31 const char kVideoWebM[] = "video/webm"; |
32 const char kVorbis[] = "vorbis"; | 32 const char kVorbis[] = "vorbis"; |
33 const char kVorbisVP8[] = "vorbis,vp8,vp8.0"; | 33 const char kVorbisVP8[] = "vorbis,vp8,vp8.0"; |
34 | 34 |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; | 310 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; |
311 return std::vector<uint8>(); | 311 return std::vector<uint8>(); |
312 } | 312 } |
313 | 313 |
314 return key_system_iter->second.uuid; | 314 return key_system_iter->second.uuid; |
315 } | 315 } |
316 #endif | 316 #endif |
317 | 317 |
318 //------------------------------------------------------------------------------ | 318 //------------------------------------------------------------------------------ |
319 | 319 |
320 bool IsConcreteSupportedKeySystem(const WebKit::WebString& key_system) { | 320 bool IsConcreteSupportedKeySystem(const blink::WebString& key_system) { |
321 return KeySystems::GetInstance().IsConcreteSupportedKeySystem( | 321 return KeySystems::GetInstance().IsConcreteSupportedKeySystem( |
322 ToASCIIOrEmpty(key_system)); | 322 ToASCIIOrEmpty(key_system)); |
323 } | 323 } |
324 | 324 |
325 bool IsSupportedKeySystemWithMediaMimeType( | 325 bool IsSupportedKeySystemWithMediaMimeType( |
326 const std::string& mime_type, | 326 const std::string& mime_type, |
327 const std::vector<std::string>& codecs, | 327 const std::vector<std::string>& codecs, |
328 const std::string& key_system) { | 328 const std::string& key_system) { |
329 return KeySystems::GetInstance().IsSupportedKeySystemWithMediaMimeType( | 329 return KeySystems::GetInstance().IsSupportedKeySystemWithMediaMimeType( |
330 mime_type, codecs, key_system); | 330 mime_type, codecs, key_system); |
331 } | 331 } |
332 | 332 |
333 std::string KeySystemNameForUMA(const WebKit::WebString& key_system) { | 333 std::string KeySystemNameForUMA(const blink::WebString& key_system) { |
334 return KeySystemNameForUMAInternal(key_system); | 334 return KeySystemNameForUMAInternal(key_system); |
335 } | 335 } |
336 | 336 |
337 bool CanUseAesDecryptor(const std::string& concrete_key_system) { | 337 bool CanUseAesDecryptor(const std::string& concrete_key_system) { |
338 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); | 338 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); |
339 } | 339 } |
340 | 340 |
341 #if defined(ENABLE_PEPPER_CDMS) | 341 #if defined(ENABLE_PEPPER_CDMS) |
342 std::string GetPepperType(const std::string& concrete_key_system) { | 342 std::string GetPepperType(const std::string& concrete_key_system) { |
343 return KeySystems::GetInstance().GetPepperType(concrete_key_system); | 343 return KeySystems::GetInstance().GetPepperType(concrete_key_system); |
344 } | 344 } |
345 #elif defined(OS_ANDROID) | 345 #elif defined(OS_ANDROID) |
346 std::vector<uint8> GetUUID(const std::string& concrete_key_system) { | 346 std::vector<uint8> GetUUID(const std::string& concrete_key_system) { |
347 return KeySystems::GetInstance().GetUUID(concrete_key_system); | 347 return KeySystems::GetInstance().GetUUID(concrete_key_system); |
348 } | 348 } |
349 #endif | 349 #endif |
350 | 350 |
351 } // namespace content | 351 } // namespace content |
OLD | NEW |