| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <memory> |
| 10 #include <string> | 11 #include <string> |
| 11 #include <utility> | 12 #include <utility> |
| 12 #include <vector> | 13 #include <vector> |
| 13 | 14 |
| 14 #include "base/base_paths.h" | 15 #include "base/base_paths.h" |
| 15 #include "base/bind.h" | 16 #include "base/bind.h" |
| 16 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
| 17 #include "base/files/file_util.h" | 18 #include "base/files/file_util.h" |
| 18 #include "base/logging.h" | 19 #include "base/logging.h" |
| 19 #include "base/macros.h" | 20 #include "base/macros.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 bool VerifyInstallation( | 255 bool VerifyInstallation( |
| 255 const base::DictionaryValue& manifest, | 256 const base::DictionaryValue& manifest, |
| 256 const base::FilePath& install_dir) const override; | 257 const base::FilePath& install_dir) const override; |
| 257 void ComponentReady(const base::Version& version, | 258 void ComponentReady(const base::Version& version, |
| 258 const base::FilePath& path, | 259 const base::FilePath& path, |
| 259 std::unique_ptr<base::DictionaryValue> manifest) override; | 260 std::unique_ptr<base::DictionaryValue> manifest) override; |
| 260 base::FilePath GetRelativeInstallDir() const override; | 261 base::FilePath GetRelativeInstallDir() const override; |
| 261 void GetHash(std::vector<uint8_t>* hash) const override; | 262 void GetHash(std::vector<uint8_t>* hash) const override; |
| 262 std::string GetName() const override; | 263 std::string GetName() const override; |
| 263 update_client::InstallerAttributes GetInstallerAttributes() const override; | 264 update_client::InstallerAttributes GetInstallerAttributes() const override; |
| 265 std::vector<std::string> GetMimeTypes() const override; |
| 264 | 266 |
| 265 // Checks and updates CDM adapter if necessary to make sure the latest CDM | 267 // Checks and updates CDM adapter if necessary to make sure the latest CDM |
| 266 // adapter is always used. | 268 // adapter is always used. |
| 267 // Note: The component is ready when CDM is present, but the CDM won't be | 269 // Note: The component is ready when CDM is present, but the CDM won't be |
| 268 // registered until the adapter is copied by this function (see | 270 // registered until the adapter is copied by this function (see |
| 269 // VerifyInstallation). | 271 // VerifyInstallation). |
| 270 void UpdateCdmAdapter(const base::Version& cdm_version, | 272 void UpdateCdmAdapter(const base::Version& cdm_version, |
| 271 const base::FilePath& cdm_install_dir, | 273 const base::FilePath& cdm_install_dir, |
| 272 std::unique_ptr<base::DictionaryValue> manifest); | 274 std::unique_ptr<base::DictionaryValue> manifest); |
| 273 | 275 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 335 |
| 334 std::string WidevineCdmComponentInstallerTraits::GetName() const { | 336 std::string WidevineCdmComponentInstallerTraits::GetName() const { |
| 335 return kWidevineCdmDisplayName; | 337 return kWidevineCdmDisplayName; |
| 336 } | 338 } |
| 337 | 339 |
| 338 update_client::InstallerAttributes | 340 update_client::InstallerAttributes |
| 339 WidevineCdmComponentInstallerTraits::GetInstallerAttributes() const { | 341 WidevineCdmComponentInstallerTraits::GetInstallerAttributes() const { |
| 340 return update_client::InstallerAttributes(); | 342 return update_client::InstallerAttributes(); |
| 341 } | 343 } |
| 342 | 344 |
| 345 std::vector<std::string> WidevineCdmComponentInstallerTraits::GetMimeTypes() |
| 346 const { |
| 347 return std::vector<std::string>(); |
| 348 } |
| 349 |
| 343 static bool HasValidAdapter(const base::FilePath& adapter_version_path, | 350 static bool HasValidAdapter(const base::FilePath& adapter_version_path, |
| 344 const base::FilePath& adapter_install_path, | 351 const base::FilePath& adapter_install_path, |
| 345 const std::string& chrome_version) { | 352 const std::string& chrome_version) { |
| 346 std::string adapter_version; | 353 std::string adapter_version; |
| 347 return base::ReadFileToString(adapter_version_path, &adapter_version) && | 354 return base::ReadFileToString(adapter_version_path, &adapter_version) && |
| 348 adapter_version == chrome_version && | 355 adapter_version == chrome_version && |
| 349 base::PathExists(adapter_install_path); | 356 base::PathExists(adapter_install_path); |
| 350 } | 357 } |
| 351 | 358 |
| 352 void WidevineCdmComponentInstallerTraits::UpdateCdmAdapter( | 359 void WidevineCdmComponentInstallerTraits::UpdateCdmAdapter( |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 std::unique_ptr<ComponentInstallerTraits> traits( | 413 std::unique_ptr<ComponentInstallerTraits> traits( |
| 407 new WidevineCdmComponentInstallerTraits); | 414 new WidevineCdmComponentInstallerTraits); |
| 408 // |cus| will take ownership of |installer| during installer->Register(cus). | 415 // |cus| will take ownership of |installer| during installer->Register(cus). |
| 409 DefaultComponentInstaller* installer = | 416 DefaultComponentInstaller* installer = |
| 410 new DefaultComponentInstaller(std::move(traits)); | 417 new DefaultComponentInstaller(std::move(traits)); |
| 411 installer->Register(cus, base::Closure()); | 418 installer->Register(cus, base::Closure()); |
| 412 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 419 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
| 413 } | 420 } |
| 414 | 421 |
| 415 } // namespace component_updater | 422 } // namespace component_updater |
| OLD | NEW |