OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/component_updater/widevine_cdm_component_installer.h" | 5 #include "chrome/browser/component_updater/widevine_cdm_component_installer.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 const std::string version_name, | 149 const std::string version_name, |
150 VersionCheckFunc version_check_func) { | 150 VersionCheckFunc version_check_func) { |
151 std::string versions_string; | 151 std::string versions_string; |
152 if (!manifest.GetString(version_name, &versions_string)) { | 152 if (!manifest.GetString(version_name, &versions_string)) { |
153 DLOG(WARNING) << "Widevine CDM component manifest missing " << version_name; | 153 DLOG(WARNING) << "Widevine CDM component manifest missing " << version_name; |
154 return false; | 154 return false; |
155 } | 155 } |
156 DLOG_IF(WARNING, versions_string.empty()) | 156 DLOG_IF(WARNING, versions_string.empty()) |
157 << "Widevine CDM component manifest has empty " << version_name; | 157 << "Widevine CDM component manifest has empty " << version_name; |
158 | 158 |
159 std::vector<std::string> versions; | 159 for (const base::StringPiece& ver_str : base::SplitStringPiece( |
160 base::SplitString(versions_string, kCdmValueDelimiter, &versions); | 160 versions_string, std::string(1, kCdmValueDelimiter), |
161 | 161 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { |
162 for (size_t i = 0; i < versions.size(); ++i) { | |
163 int version = 0; | 162 int version = 0; |
164 if (base::StringToInt(versions[i], &version)) | 163 if (base::StringToInt(ver_str, &version)) |
165 if (version_check_func(version)) | 164 if (version_check_func(version)) |
166 return true; | 165 return true; |
167 } | 166 } |
168 | 167 |
169 DLOG(WARNING) << "Widevine CDM component manifest has no supported " | 168 DLOG(WARNING) << "Widevine CDM component manifest has no supported " |
170 << version_name << " in '" << versions_string << "'"; | 169 << version_name << " in '" << versions_string << "'"; |
171 return false; | 170 return false; |
172 } | 171 } |
173 | 172 |
174 // Returns whether the CDM's API versions, as specified in the manifest, are | 173 // Returns whether the CDM's API versions, as specified in the manifest, are |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 scoped_ptr<ComponentInstallerTraits> traits( | 371 scoped_ptr<ComponentInstallerTraits> traits( |
373 new WidevineCdmComponentInstallerTraits); | 372 new WidevineCdmComponentInstallerTraits); |
374 // |cus| will take ownership of |installer| during installer->Register(cus). | 373 // |cus| will take ownership of |installer| during installer->Register(cus). |
375 DefaultComponentInstaller* installer = | 374 DefaultComponentInstaller* installer = |
376 new DefaultComponentInstaller(traits.Pass()); | 375 new DefaultComponentInstaller(traits.Pass()); |
377 installer->Register(cus, base::Closure()); | 376 installer->Register(cus, base::Closure()); |
378 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 377 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
379 } | 378 } |
380 | 379 |
381 } // namespace component_updater | 380 } // namespace component_updater |
OLD | NEW |