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> |
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/macros.h" |
19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
20 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
22 #include "base/strings/string_split.h" | 22 #include "base/strings/string_split.h" |
23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
24 #include "base/values.h" | 24 #include "base/values.h" |
25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
26 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
27 #include "chrome/common/chrome_version_info.h" | |
28 #include "chrome/common/widevine_cdm_constants.h" | 27 #include "chrome/common/widevine_cdm_constants.h" |
29 #include "components/component_updater/component_updater_service.h" | 28 #include "components/component_updater/component_updater_service.h" |
30 #include "components/component_updater/default_component_installer.h" | 29 #include "components/component_updater/default_component_installer.h" |
| 30 #include "components/version_info/version_info.h" |
31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
32 #include "content/public/browser/plugin_service.h" | 32 #include "content/public/browser/plugin_service.h" |
33 #include "content/public/common/pepper_plugin_info.h" | 33 #include "content/public/common/pepper_plugin_info.h" |
34 #include "media/cdm/ppapi/supported_cdm_versions.h" | 34 #include "media/cdm/ppapi/supported_cdm_versions.h" |
35 #include "third_party/widevine/cdm/widevine_cdm_common.h" | 35 #include "third_party/widevine/cdm/widevine_cdm_common.h" |
36 | 36 |
37 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. NOLINT | 37 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. NOLINT |
38 | 38 |
39 using content::BrowserThread; | 39 using content::BrowserThread; |
40 using content::PluginService; | 40 using content::PluginService; |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 void WidevineCdmComponentInstallerTraits::UpdateCdmAdapter( | 323 void WidevineCdmComponentInstallerTraits::UpdateCdmAdapter( |
324 const base::Version& cdm_version, | 324 const base::Version& cdm_version, |
325 const base::FilePath& cdm_install_dir, | 325 const base::FilePath& cdm_install_dir, |
326 scoped_ptr<base::DictionaryValue> manifest) { | 326 scoped_ptr<base::DictionaryValue> manifest) { |
327 const base::FilePath adapter_version_path = | 327 const base::FilePath adapter_version_path = |
328 GetPlatformDirectory(cdm_install_dir).AppendASCII(kCdmAdapterVersionName); | 328 GetPlatformDirectory(cdm_install_dir).AppendASCII(kCdmAdapterVersionName); |
329 const base::FilePath adapter_install_path = | 329 const base::FilePath adapter_install_path = |
330 GetPlatformDirectory(cdm_install_dir) | 330 GetPlatformDirectory(cdm_install_dir) |
331 .AppendASCII(kWidevineCdmAdapterFileName); | 331 .AppendASCII(kWidevineCdmAdapterFileName); |
332 | 332 |
333 const std::string chrome_version = chrome::VersionInfo().Version(); | 333 const std::string chrome_version = version_info::GetVersionNumber(); |
334 DCHECK(!chrome_version.empty()); | 334 DCHECK(!chrome_version.empty()); |
335 std::string adapter_version; | 335 std::string adapter_version; |
336 if (!base::ReadFileToString(adapter_version_path, &adapter_version) || | 336 if (!base::ReadFileToString(adapter_version_path, &adapter_version) || |
337 adapter_version != chrome_version || | 337 adapter_version != chrome_version || |
338 !base::PathExists(adapter_install_path)) { | 338 !base::PathExists(adapter_install_path)) { |
339 int bytes_written = base::WriteFile( | 339 int bytes_written = base::WriteFile( |
340 adapter_version_path, chrome_version.data(), chrome_version.size()); | 340 adapter_version_path, chrome_version.data(), chrome_version.size()); |
341 if (bytes_written < 0 || | 341 if (bytes_written < 0 || |
342 static_cast<size_t>(bytes_written) != chrome_version.size()) { | 342 static_cast<size_t>(bytes_written) != chrome_version.size()) { |
343 DLOG(WARNING) << "Failed to write Widevine CDM adapter version file."; | 343 DLOG(WARNING) << "Failed to write Widevine CDM adapter version file."; |
(...skipping 27 matching lines...) Expand all Loading... |
371 scoped_ptr<ComponentInstallerTraits> traits( | 371 scoped_ptr<ComponentInstallerTraits> traits( |
372 new WidevineCdmComponentInstallerTraits); | 372 new WidevineCdmComponentInstallerTraits); |
373 // |cus| will take ownership of |installer| during installer->Register(cus). | 373 // |cus| will take ownership of |installer| during installer->Register(cus). |
374 DefaultComponentInstaller* installer = | 374 DefaultComponentInstaller* installer = |
375 new DefaultComponentInstaller(traits.Pass()); | 375 new DefaultComponentInstaller(traits.Pass()); |
376 installer->Register(cus, base::Closure()); | 376 installer->Register(cus, base::Closure()); |
377 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 377 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
378 } | 378 } |
379 | 379 |
380 } // namespace component_updater | 380 } // namespace component_updater |
OLD | NEW |