Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1454)

Unified Diff: chrome/browser/component_updater/widevine_cdm_component_installer.cc

Issue 2000513002: media: Bundle Widevine CDM on Win/Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/chrome_dll_bundle.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/component_updater/widevine_cdm_component_installer.cc
diff --git a/chrome/browser/component_updater/widevine_cdm_component_installer.cc b/chrome/browser/component_updater/widevine_cdm_component_installer.cc
index 4279e0b95beab98918ad408a53e01a91accea26a..05269336365b4baeed67dd1f087e2eac7eff6046 100644
--- a/chrome/browser/component_updater/widevine_cdm_component_installer.cc
+++ b/chrome/browser/component_updater/widevine_cdm_component_installer.cc
@@ -333,6 +333,15 @@ std::string WidevineCdmComponentInstallerTraits::GetAp() const {
return std::string();
}
+static bool HasValidAdapter(const base::FilePath& adapter_version_path,
+ const base::FilePath& adapter_install_path,
+ const std::string& chrome_version) {
+ std::string adapter_version;
+ return base::ReadFileToString(adapter_version_path, &adapter_version) &&
+ adapter_version == chrome_version &&
+ base::PathExists(adapter_install_path);
+}
+
void WidevineCdmComponentInstallerTraits::UpdateCdmAdapter(
const base::Version& cdm_version,
const base::FilePath& cdm_install_dir,
@@ -347,12 +356,18 @@ void WidevineCdmComponentInstallerTraits::UpdateCdmAdapter(
<< " adapter_install_path=" << adapter_install_path.AsUTF8Unsafe()
<< " adapter_version_path=" << adapter_version_path.AsUTF8Unsafe();
+ base::FilePath adapter_source_path;
+ PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path);
+
const std::string chrome_version = version_info::GetVersionNumber();
DCHECK(!chrome_version.empty());
- std::string adapter_version;
- if (!base::ReadFileToString(adapter_version_path, &adapter_version) ||
- adapter_version != chrome_version ||
- !base::PathExists(adapter_install_path)) {
+
+ // If we are not using bundled CDM and we don't have a valid adapter, create
+ // the version file and copy the CDM adapter from |adapter_source_path| to
+ // |adapter_install_path|.
+ if (adapter_install_path != adapter_source_path &&
+ !HasValidAdapter(adapter_version_path, adapter_install_path,
+ chrome_version)) {
int bytes_written = base::WriteFile(
adapter_version_path, chrome_version.data(), chrome_version.size());
if (bytes_written < 0 ||
@@ -361,8 +376,6 @@ void WidevineCdmComponentInstallerTraits::UpdateCdmAdapter(
// Ignore version file writing failure and try to copy the CDM adapter.
}
- base::FilePath adapter_source_path;
- PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path);
if (!base::CopyFile(adapter_source_path, adapter_install_path)) {
PLOG(WARNING) << "Failed to copy Widevine CDM adapter.";
return;
« no previous file with comments | « no previous file | chrome/chrome_dll_bundle.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698