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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/chrome_dll_bundle.gypi » ('j') | 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 <string> 10 #include <string>
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 } 326 }
327 327
328 std::string WidevineCdmComponentInstallerTraits::GetName() const { 328 std::string WidevineCdmComponentInstallerTraits::GetName() const {
329 return kWidevineCdmDisplayName; 329 return kWidevineCdmDisplayName;
330 } 330 }
331 331
332 std::string WidevineCdmComponentInstallerTraits::GetAp() const { 332 std::string WidevineCdmComponentInstallerTraits::GetAp() const {
333 return std::string(); 333 return std::string();
334 } 334 }
335 335
336 static bool HasValidAdapter(const base::FilePath& adapter_version_path,
337 const base::FilePath& adapter_install_path,
338 const std::string& chrome_version) {
339 std::string adapter_version;
340 return base::ReadFileToString(adapter_version_path, &adapter_version) &&
341 adapter_version == chrome_version &&
342 base::PathExists(adapter_install_path);
343 }
344
336 void WidevineCdmComponentInstallerTraits::UpdateCdmAdapter( 345 void WidevineCdmComponentInstallerTraits::UpdateCdmAdapter(
337 const base::Version& cdm_version, 346 const base::Version& cdm_version,
338 const base::FilePath& cdm_install_dir, 347 const base::FilePath& cdm_install_dir,
339 std::unique_ptr<base::DictionaryValue> manifest) { 348 std::unique_ptr<base::DictionaryValue> manifest) {
340 const base::FilePath adapter_version_path = 349 const base::FilePath adapter_version_path =
341 GetPlatformDirectory(cdm_install_dir).AppendASCII(kCdmAdapterVersionName); 350 GetPlatformDirectory(cdm_install_dir).AppendASCII(kCdmAdapterVersionName);
342 const base::FilePath adapter_install_path = 351 const base::FilePath adapter_install_path =
343 GetPlatformDirectory(cdm_install_dir) 352 GetPlatformDirectory(cdm_install_dir)
344 .AppendASCII(kWidevineCdmAdapterFileName); 353 .AppendASCII(kWidevineCdmAdapterFileName);
345 354
346 VLOG(1) << "UpdateCdmAdapter: version" << cdm_version.GetString() 355 VLOG(1) << "UpdateCdmAdapter: version" << cdm_version.GetString()
347 << " adapter_install_path=" << adapter_install_path.AsUTF8Unsafe() 356 << " adapter_install_path=" << adapter_install_path.AsUTF8Unsafe()
348 << " adapter_version_path=" << adapter_version_path.AsUTF8Unsafe(); 357 << " adapter_version_path=" << adapter_version_path.AsUTF8Unsafe();
349 358
359 base::FilePath adapter_source_path;
360 PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path);
361
350 const std::string chrome_version = version_info::GetVersionNumber(); 362 const std::string chrome_version = version_info::GetVersionNumber();
351 DCHECK(!chrome_version.empty()); 363 DCHECK(!chrome_version.empty());
352 std::string adapter_version; 364
353 if (!base::ReadFileToString(adapter_version_path, &adapter_version) || 365 // If we are not using bundled CDM and we don't have a valid adapter, create
354 adapter_version != chrome_version || 366 // the version file and copy the CDM adapter from |adapter_source_path| to
355 !base::PathExists(adapter_install_path)) { 367 // |adapter_install_path|.
368 if (adapter_install_path != adapter_source_path &&
369 !HasValidAdapter(adapter_version_path, adapter_install_path,
370 chrome_version)) {
356 int bytes_written = base::WriteFile( 371 int bytes_written = base::WriteFile(
357 adapter_version_path, chrome_version.data(), chrome_version.size()); 372 adapter_version_path, chrome_version.data(), chrome_version.size());
358 if (bytes_written < 0 || 373 if (bytes_written < 0 ||
359 static_cast<size_t>(bytes_written) != chrome_version.size()) { 374 static_cast<size_t>(bytes_written) != chrome_version.size()) {
360 PLOG(WARNING) << "Failed to write Widevine CDM adapter version file."; 375 PLOG(WARNING) << "Failed to write Widevine CDM adapter version file.";
361 // Ignore version file writing failure and try to copy the CDM adapter. 376 // Ignore version file writing failure and try to copy the CDM adapter.
362 } 377 }
363 378
364 base::FilePath adapter_source_path;
365 PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path);
366 if (!base::CopyFile(adapter_source_path, adapter_install_path)) { 379 if (!base::CopyFile(adapter_source_path, adapter_install_path)) {
367 PLOG(WARNING) << "Failed to copy Widevine CDM adapter."; 380 PLOG(WARNING) << "Failed to copy Widevine CDM adapter.";
368 return; 381 return;
369 } 382 }
370 } 383 }
371 384
372 BrowserThread::PostTask( 385 BrowserThread::PostTask(
373 content::BrowserThread::UI, FROM_HERE, 386 content::BrowserThread::UI, FROM_HERE,
374 base::Bind(&RegisterWidevineCdmWithChrome, cdm_version, cdm_install_dir, 387 base::Bind(&RegisterWidevineCdmWithChrome, cdm_version, cdm_install_dir,
375 base::Passed(&manifest))); 388 base::Passed(&manifest)));
(...skipping 10 matching lines...) Expand all
386 std::unique_ptr<ComponentInstallerTraits> traits( 399 std::unique_ptr<ComponentInstallerTraits> traits(
387 new WidevineCdmComponentInstallerTraits); 400 new WidevineCdmComponentInstallerTraits);
388 // |cus| will take ownership of |installer| during installer->Register(cus). 401 // |cus| will take ownership of |installer| during installer->Register(cus).
389 DefaultComponentInstaller* installer = 402 DefaultComponentInstaller* installer =
390 new DefaultComponentInstaller(std::move(traits)); 403 new DefaultComponentInstaller(std::move(traits));
391 installer->Register(cus, base::Closure()); 404 installer->Register(cus, base::Closure());
392 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) 405 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
393 } 406 }
394 407
395 } // namespace component_updater 408 } // namespace component_updater
OLDNEW
« 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