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

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)) {
392 if (!base::CopyFile(adapter_source_path, adapter_install_path)) {
393 PLOG(WARNING) << "Failed to copy Widevine CDM adapter.";
394 return;
395 }
396
397 // Generate the version file.
388 int bytes_written = base::WriteFile( 398 int bytes_written = base::WriteFile(
389 adapter_version_path, chrome_version.data(), chrome_version.size()); 399 adapter_version_path, chrome_version.data(), chrome_version.size());
390 if (bytes_written < 0 || 400 if (bytes_written < 0 ||
391 static_cast<size_t>(bytes_written) != chrome_version.size()) { 401 static_cast<size_t>(bytes_written) != chrome_version.size()) {
392 PLOG(WARNING) << "Failed to write Widevine CDM adapter version file."; 402 PLOG(WARNING) << "Failed to write Widevine CDM adapter version file.";
393 // Ignore version file writing failure and try to copy the CDM adapter. 403 // Ignore version file writing failure.
394 } 404 }
395 405
396 if (!base::CopyFile(adapter_source_path, adapter_install_path)) { 406 // Copy Widevine CDM adapter signature file.
397 PLOG(WARNING) << "Failed to copy Widevine CDM adapter."; 407 if (!base::CopyFile(
398 return; 408 adapter_source_path.AddExtension(kSignatureFileExtension),
409 adapter_install_path.AddExtension(kSignatureFileExtension))) {
410 PLOG(WARNING) << "Failed to copy Widevine CDM adapter signature file.";
411 // The sig file may be missing or the copy failed. Ignore the failure.
399 } 412 }
400 } 413 }
401 414
402 BrowserThread::PostTask( 415 BrowserThread::PostTask(
403 content::BrowserThread::UI, FROM_HERE, 416 content::BrowserThread::UI, FROM_HERE,
404 base::Bind(&RegisterWidevineCdmWithChrome, cdm_version, cdm_install_dir, 417 base::Bind(&RegisterWidevineCdmWithChrome, cdm_version, cdm_install_dir,
405 base::Passed(&manifest))); 418 base::Passed(&manifest)));
406 } 419 }
407 420
408 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) 421 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
409 422
410 void RegisterWidevineCdmComponent(ComponentUpdateService* cus) { 423 void RegisterWidevineCdmComponent(ComponentUpdateService* cus) {
411 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) 424 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
412 base::FilePath adapter_source_path; 425 base::FilePath adapter_source_path;
413 PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path); 426 PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path);
414 if (!base::PathExists(adapter_source_path)) 427 if (!base::PathExists(adapter_source_path))
415 return; 428 return;
416 std::unique_ptr<ComponentInstallerTraits> traits( 429 std::unique_ptr<ComponentInstallerTraits> traits(
417 new WidevineCdmComponentInstallerTraits); 430 new WidevineCdmComponentInstallerTraits);
418 // |cus| will take ownership of |installer| during installer->Register(cus). 431 // |cus| will take ownership of |installer| during installer->Register(cus).
419 DefaultComponentInstaller* installer = 432 DefaultComponentInstaller* installer =
420 new DefaultComponentInstaller(std::move(traits)); 433 new DefaultComponentInstaller(std::move(traits));
421 installer->Register(cus, base::Closure()); 434 installer->Register(cus, base::Closure());
422 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) 435 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
423 } 436 }
424 437
425 } // namespace component_updater 438 } // 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