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

Side by Side Diff: chrome/browser/component_updater/widevine_cdm_component_installer.cc

Issue 2617023004: media: Copy Widevine CDM adapter signature file (Closed)
Patch Set: media: Copy Widevine CDM adapter signature file Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory>
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // Matches CDM_MODULE_VERSION. 97 // Matches CDM_MODULE_VERSION.
98 const char kCdmModuleVersionsName[] = "x-cdm-module-versions"; 98 const char kCdmModuleVersionsName[] = "x-cdm-module-versions";
99 // Matches supported ContentDecryptionModule_* version(s). 99 // Matches supported ContentDecryptionModule_* version(s).
100 const char kCdmInterfaceVersionsName[] = "x-cdm-interface-versions"; 100 const char kCdmInterfaceVersionsName[] = "x-cdm-interface-versions";
101 // Matches supported Host_* version(s). 101 // Matches supported Host_* version(s).
102 const char kCdmHostVersionsName[] = "x-cdm-host-versions"; 102 const char kCdmHostVersionsName[] = "x-cdm-host-versions";
103 // The codecs list is a list of simple codec names (e.g. "vp8,vorbis"). 103 // The codecs list is a list of simple codec names (e.g. "vp8,vorbis").
104 // The list is passed to other parts of Chrome. 104 // The list is passed to other parts of Chrome.
105 const char kCdmCodecsListName[] = "x-cdm-codecs"; 105 const char kCdmCodecsListName[] = "x-cdm-codecs";
106 106
107 // TODO(xhwang): Move this to a common place if needed.
108 const base::FilePath::CharType kSignatureFileExtension[] =
109 FILE_PATH_LITERAL(".sig");
110
107 // Widevine CDM is packaged as a multi-CRX. Widevine CDM binaries are located in 111 // Widevine CDM is packaged as a multi-CRX. Widevine CDM binaries are located in
108 // _platform_specific/<platform_arch> folder in the package. This function 112 // _platform_specific/<platform_arch> folder in the package. This function
109 // returns the platform-specific subdirectory that is part of that multi-CRX. 113 // returns the platform-specific subdirectory that is part of that multi-CRX.
110 base::FilePath GetPlatformDirectory(const base::FilePath& base_path) { 114 base::FilePath GetPlatformDirectory(const base::FilePath& base_path) {
111 std::string platform_arch = kWidevineCdmPlatform; 115 std::string platform_arch = kWidevineCdmPlatform;
112 platform_arch += '_'; 116 platform_arch += '_';
113 platform_arch += kWidevineCdmArch; 117 platform_arch += kWidevineCdmArch;
114 return base_path.AppendASCII("_platform_specific").AppendASCII(platform_arch); 118 return base_path.AppendASCII("_platform_specific").AppendASCII(platform_arch);
115 } 119 }
116 120
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 << " adapter_install_path=" << adapter_install_path.AsUTF8Unsafe() 377 << " adapter_install_path=" << adapter_install_path.AsUTF8Unsafe()
374 << " adapter_version_path=" << adapter_version_path.AsUTF8Unsafe(); 378 << " adapter_version_path=" << adapter_version_path.AsUTF8Unsafe();
375 379
376 base::FilePath adapter_source_path; 380 base::FilePath adapter_source_path;
377 PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path); 381 PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path);
378 382
379 const std::string chrome_version = version_info::GetVersionNumber(); 383 const std::string chrome_version = version_info::GetVersionNumber();
380 DCHECK(!chrome_version.empty()); 384 DCHECK(!chrome_version.empty());
381 385
382 // If we are not using bundled CDM and we don't have a valid adapter, create 386 // If we are not using bundled CDM and we don't have a valid adapter, create
383 // the version file and copy the CDM adapter from |adapter_source_path| to 387 // the version file, copy the CDM adapter signature file, and copy the CDM
384 // |adapter_install_path|. 388 // adapter.
385 if (adapter_install_path != adapter_source_path && 389 if (adapter_install_path != adapter_source_path &&
386 !HasValidAdapter(adapter_version_path, adapter_install_path, 390 !HasValidAdapter(adapter_version_path, adapter_install_path,
387 chrome_version)) { 391 chrome_version)) {
388 int bytes_written = base::WriteFile( 392 int bytes_written = base::WriteFile(
389 adapter_version_path, chrome_version.data(), chrome_version.size()); 393 adapter_version_path, chrome_version.data(), chrome_version.size());
390 if (bytes_written < 0 || 394 if (bytes_written < 0 ||
391 static_cast<size_t>(bytes_written) != chrome_version.size()) { 395 static_cast<size_t>(bytes_written) != chrome_version.size()) {
392 PLOG(WARNING) << "Failed to write Widevine CDM adapter version file."; 396 PLOG(WARNING) << "Failed to write Widevine CDM adapter version file.";
393 // Ignore version file writing failure and try to copy the CDM adapter. 397 // Ignore version file writing failure and try to copy the CDM adapter.
394 } 398 }
395 399
400 // Copy Widevine CDM signature file if it exists.
jrummell 2017/01/06 02:04:00 Since failing to find and/or copy this is not fata
xhwang 2017/01/06 04:37:06 Good point. Done.
401 base::FilePath adapter_sig_source_path =
402 adapter_source_path.AddExtension(kSignatureFileExtension);
403 if (base::PathExists(adapter_sig_source_path)) {
404 base::FilePath adapter_sig_install_path =
405 adapter_install_path.AddExtension(kSignatureFileExtension);
406 if (!base::CopyFile(adapter_sig_source_path, adapter_sig_install_path))
407 PLOG(WARNING) << "Failed to copy Widevine CDM adapter signature file.";
408 } else {
409 PLOG(WARNING) << "Widevine CDM adapter signature file does not exist.";
jrummell 2017/01/06 02:04:00 Since there is a log if the file doesn't exist or
xhwang 2017/01/06 04:37:07 We did have cases where the CDM is missing and the
410 }
411
396 if (!base::CopyFile(adapter_source_path, adapter_install_path)) { 412 if (!base::CopyFile(adapter_source_path, adapter_install_path)) {
397 PLOG(WARNING) << "Failed to copy Widevine CDM adapter."; 413 PLOG(WARNING) << "Failed to copy Widevine CDM adapter.";
398 return; 414 return;
399 } 415 }
400 } 416 }
401 417
402 BrowserThread::PostTask( 418 BrowserThread::PostTask(
403 content::BrowserThread::UI, FROM_HERE, 419 content::BrowserThread::UI, FROM_HERE,
404 base::Bind(&RegisterWidevineCdmWithChrome, cdm_version, cdm_install_dir, 420 base::Bind(&RegisterWidevineCdmWithChrome, cdm_version, cdm_install_dir,
405 base::Passed(&manifest))); 421 base::Passed(&manifest)));
(...skipping 10 matching lines...) Expand all
416 std::unique_ptr<ComponentInstallerTraits> traits( 432 std::unique_ptr<ComponentInstallerTraits> traits(
417 new WidevineCdmComponentInstallerTraits); 433 new WidevineCdmComponentInstallerTraits);
418 // |cus| will take ownership of |installer| during installer->Register(cus). 434 // |cus| will take ownership of |installer| during installer->Register(cus).
419 DefaultComponentInstaller* installer = 435 DefaultComponentInstaller* installer =
420 new DefaultComponentInstaller(std::move(traits)); 436 new DefaultComponentInstaller(std::move(traits));
421 installer->Register(cus, base::Closure()); 437 installer->Register(cus, base::Closure());
422 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) 438 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
423 } 439 }
424 440
425 } // namespace component_updater 441 } // namespace component_updater
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698