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/public/renderer/key_system_info.h" | 5 #include "content/public/renderer/key_system_info.h" |
6 | 6 |
| 7 #include "base/logging.h" |
| 8 |
7 namespace content { | 9 namespace content { |
8 | 10 |
| 11 namespace { |
| 12 |
| 13 // Return |name|'s parent key system. |
| 14 std::string GetDirectParentName(std::string name) { |
| 15 int last_period = name.find_last_of('.'); |
| 16 DCHECK_GT(last_period, 0); |
| 17 return name.substr(0, last_period); |
| 18 } |
| 19 |
| 20 } // namespace |
| 21 |
| 22 // static |
| 23 KeySystemInfo KeySystemInfo::Build(const char* key_system, |
| 24 bool has_parent, |
| 25 const char* suffix, |
| 26 #if defined(ENABLE_PEPPER_CDMS) |
| 27 const char* pepper_type, |
| 28 #endif // defined(ENABLE_PEPPER_CDMS) |
| 29 SupportedCodecs supported_codecs) { |
| 30 KeySystemInfo info(key_system); |
| 31 |
| 32 if (has_parent) |
| 33 info.parent_key_system = GetDirectParentName(key_system); |
| 34 if (suffix) |
| 35 info.key_system.append(suffix); |
| 36 |
| 37 // TODO(xhwang): A container or an initDataType may be supported even though |
| 38 // there are no codecs supported in that container. Fix this when we support |
| 39 // initDataType. |
| 40 info.supported_codecs = supported_codecs; |
| 41 |
| 42 #if defined(ENABLE_PEPPER_CDMS) |
| 43 info.pepper_type = pepper_type; |
| 44 #endif // defined(ENABLE_PEPPER_CDMS) |
| 45 return info; |
| 46 } |
| 47 |
9 KeySystemInfo::KeySystemInfo(const std::string& key_system) | 48 KeySystemInfo::KeySystemInfo(const std::string& key_system) |
10 : key_system(key_system), | 49 : key_system(key_system), |
11 use_aes_decryptor(false) { | 50 use_aes_decryptor(false) { |
12 } | 51 } |
13 | 52 |
14 KeySystemInfo::~KeySystemInfo() { | 53 KeySystemInfo::~KeySystemInfo() { |
15 } | 54 } |
16 | 55 |
17 } // namespace content | 56 } // namespace content |
OLD | NEW |