| 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 <string.h> | 8 #include <string.h> |
| 8 | |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/base_paths.h" | 12 #include "base/base_paths.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/macros.h" |
| 18 #include "base/path_service.h" | 19 #include "base/path_service.h" |
| 19 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
| 20 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/strings/string_split.h" | 22 #include "base/strings/string_split.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 23 #include "base/values.h" | 24 #include "base/values.h" |
| 24 #include "build/build_config.h" | 25 #include "build/build_config.h" |
| 25 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
| 26 #include "chrome/common/chrome_version_info.h" | 27 #include "chrome/common/chrome_version_info.h" |
| 27 #include "chrome/common/widevine_cdm_constants.h" | 28 #include "chrome/common/widevine_cdm_constants.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 38 using content::BrowserThread; | 39 using content::BrowserThread; |
| 39 using content::PluginService; | 40 using content::PluginService; |
| 40 | 41 |
| 41 namespace component_updater { | 42 namespace component_updater { |
| 42 | 43 |
| 43 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 44 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
| 44 | 45 |
| 45 namespace { | 46 namespace { |
| 46 | 47 |
| 47 // CRX hash. The extension id is: oimompecagnajdejgnnjijobebaeigek. | 48 // CRX hash. The extension id is: oimompecagnajdejgnnjijobebaeigek. |
| 48 const uint8 kSha2Hash[] = {0xe8, 0xce, 0xcf, 0x42, 0x06, 0xd0, 0x93, 0x49, | 49 const uint8_t kSha2Hash[] = {0xe8, 0xce, 0xcf, 0x42, 0x06, 0xd0, 0x93, 0x49, |
| 49 0x6d, 0xd9, 0x89, 0xe1, 0x41, 0x04, 0x86, 0x4a, | 50 0x6d, 0xd9, 0x89, 0xe1, 0x41, 0x04, 0x86, 0x4a, |
| 50 0x8f, 0xbd, 0x86, 0x12, 0xb9, 0x58, 0x9b, 0xfb, | 51 0x8f, 0xbd, 0x86, 0x12, 0xb9, 0x58, 0x9b, 0xfb, |
| 51 0x4f, 0xbb, 0x1b, 0xa9, 0xd3, 0x85, 0x37, 0xef}; | 52 0x4f, 0xbb, 0x1b, 0xa9, 0xd3, 0x85, 0x37, 0xef}; |
| 52 | 53 |
| 53 // File name of the Widevine CDM component manifest on different platforms. | 54 // File name of the Widevine CDM component manifest on different platforms. |
| 54 const char kWidevineCdmManifestName[] = "WidevineCdm"; | 55 const char kWidevineCdmManifestName[] = "WidevineCdm"; |
| 55 | 56 |
| 56 // File name of the Widevine CDM adapter version file. The CDM adapter shares | 57 // File name of the Widevine CDM adapter version file. The CDM adapter shares |
| 57 // the same version number with Chromium version. | 58 // the same version number with Chromium version. |
| 58 const char kCdmAdapterVersionName[] = "CdmAdapterVersion"; | 59 const char kCdmAdapterVersionName[] = "CdmAdapterVersion"; |
| 59 | 60 |
| 60 // Name of the Widevine CDM OS in the component manifest. | 61 // Name of the Widevine CDM OS in the component manifest. |
| 61 const char kWidevineCdmPlatform[] = | 62 const char kWidevineCdmPlatform[] = |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 virtual bool CanAutoUpdate() const OVERRIDE; | 241 virtual bool CanAutoUpdate() const OVERRIDE; |
| 241 virtual bool OnCustomInstall(const base::DictionaryValue& manifest, | 242 virtual bool OnCustomInstall(const base::DictionaryValue& manifest, |
| 242 const base::FilePath& install_dir) OVERRIDE; | 243 const base::FilePath& install_dir) OVERRIDE; |
| 243 virtual bool VerifyInstallation( | 244 virtual bool VerifyInstallation( |
| 244 const base::FilePath& install_dir) const OVERRIDE; | 245 const base::FilePath& install_dir) const OVERRIDE; |
| 245 virtual void ComponentReady( | 246 virtual void ComponentReady( |
| 246 const base::Version& version, | 247 const base::Version& version, |
| 247 const base::FilePath& path, | 248 const base::FilePath& path, |
| 248 scoped_ptr<base::DictionaryValue> manifest) OVERRIDE; | 249 scoped_ptr<base::DictionaryValue> manifest) OVERRIDE; |
| 249 virtual base::FilePath GetBaseDirectory() const OVERRIDE; | 250 virtual base::FilePath GetBaseDirectory() const OVERRIDE; |
| 250 virtual void GetHash(std::vector<uint8>* hash) const OVERRIDE; | 251 virtual void GetHash(std::vector<uint8_t>* hash) const OVERRIDE; |
| 251 virtual std::string GetName() const OVERRIDE; | 252 virtual std::string GetName() const OVERRIDE; |
| 252 | 253 |
| 253 // Checks and updates CDM adapter if necessary to make sure the latest CDM | 254 // Checks and updates CDM adapter if necessary to make sure the latest CDM |
| 254 // adapter is always used. | 255 // adapter is always used. |
| 255 // Note: The component is ready when CDM is present, but the CDM won't be | 256 // Note: The component is ready when CDM is present, but the CDM won't be |
| 256 // registered until the adapter is copied by this function (see | 257 // registered until the adapter is copied by this function (see |
| 257 // VerifyInstallation). | 258 // VerifyInstallation). |
| 258 void UpdateCdmAdapter(const base::Version& cdm_version, | 259 void UpdateCdmAdapter(const base::Version& cdm_version, |
| 259 const base::FilePath& cdm_install_dir, | 260 const base::FilePath& cdm_install_dir, |
| 260 scoped_ptr<base::DictionaryValue> manifest); | 261 scoped_ptr<base::DictionaryValue> manifest); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 303 |
| 303 // The base directory on Windows looks like: | 304 // The base directory on Windows looks like: |
| 304 // <profile>\AppData\Local\Google\Chrome\User Data\WidevineCdm\. | 305 // <profile>\AppData\Local\Google\Chrome\User Data\WidevineCdm\. |
| 305 base::FilePath WidevineCdmComponentInstallerTraits::GetBaseDirectory() const { | 306 base::FilePath WidevineCdmComponentInstallerTraits::GetBaseDirectory() const { |
| 306 base::FilePath result; | 307 base::FilePath result; |
| 307 PathService::Get(chrome::DIR_COMPONENT_WIDEVINE_CDM, &result); | 308 PathService::Get(chrome::DIR_COMPONENT_WIDEVINE_CDM, &result); |
| 308 return result; | 309 return result; |
| 309 } | 310 } |
| 310 | 311 |
| 311 void WidevineCdmComponentInstallerTraits::GetHash( | 312 void WidevineCdmComponentInstallerTraits::GetHash( |
| 312 std::vector<uint8>* hash) const { | 313 std::vector<uint8_t>* hash) const { |
| 313 hash->assign(kSha2Hash, kSha2Hash + arraysize(kSha2Hash)); | 314 hash->assign(kSha2Hash, kSha2Hash + arraysize(kSha2Hash)); |
| 314 } | 315 } |
| 315 | 316 |
| 316 std::string WidevineCdmComponentInstallerTraits::GetName() const { | 317 std::string WidevineCdmComponentInstallerTraits::GetName() const { |
| 317 return kWidevineCdmManifestName; | 318 return kWidevineCdmManifestName; |
| 318 } | 319 } |
| 319 | 320 |
| 320 void WidevineCdmComponentInstallerTraits::UpdateCdmAdapter( | 321 void WidevineCdmComponentInstallerTraits::UpdateCdmAdapter( |
| 321 const base::Version& cdm_version, | 322 const base::Version& cdm_version, |
| 322 const base::FilePath& cdm_install_dir, | 323 const base::FilePath& cdm_install_dir, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 // |cus| will take ownership of |installer| during installer->Register(cus). | 371 // |cus| will take ownership of |installer| during installer->Register(cus). |
| 371 DefaultComponentInstaller* installer = | 372 DefaultComponentInstaller* installer = |
| 372 new DefaultComponentInstaller(traits.Pass()); | 373 new DefaultComponentInstaller(traits.Pass()); |
| 373 installer->Register(cus); | 374 installer->Register(cus); |
| 374 #else | 375 #else |
| 375 return; | 376 return; |
| 376 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 377 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
| 377 } | 378 } |
| 378 | 379 |
| 379 } // namespace component_updater | 380 } // namespace component_updater |
| OLD | NEW |