Commit 609ff090 authored by Xiaohan Wang's avatar Xiaohan Wang Committed by Commit Bot

media: Add ENABLE_WIDEVINE_CDM_COMPONENT buildflag

This replaces the current WIDEVINE_CDM_IS_COMPONENT macro defined in
widevine_cdm_common.h. Buildflag is safer, also this avoids tricky cases
where widevine_cdm_common.h must be included before the define can be
evaluated.

Bug: 349182
Test: No functionality change
Change-Id: Ifc26d2fa87b00997e9335a977cb6417c4ec4432d
Reviewed-on: https://chromium-review.googlesource.com/1248132Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarJohn Rummell <jrummell@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594961}
parent ec670890
...@@ -3973,12 +3973,13 @@ jumbo_split_static_library("browser") { ...@@ -3973,12 +3973,13 @@ jumbo_split_static_library("browser") {
deps += [ "//media/mojo/interfaces" ] deps += [ "//media/mojo/interfaces" ]
if (enable_widevine) { if (enable_widevine) {
# TODO(crbug.com/349182): Also check WIDEVINE_CDM_IS_COMPONENT. if (enable_widevine_cdm_component) {
sources += [ sources += [
"component_updater/widevine_cdm_component_installer.cc", "component_updater/widevine_cdm_component_installer.cc",
"component_updater/widevine_cdm_component_installer.h", "component_updater/widevine_cdm_component_installer.h",
] ]
deps += [ "//third_party/widevine/cdm:headers" ] deps += [ "//third_party/widevine/cdm:headers" ]
}
if (is_win) { if (is_win) {
sources += [ sources += [
"media/widevine_hardware_caps_win.cc", "media/widevine_hardware_caps_win.cc",
......
...@@ -66,7 +66,6 @@ ...@@ -66,7 +66,6 @@
#include "chrome/browser/component_updater/sth_set_component_installer.h" #include "chrome/browser/component_updater/sth_set_component_installer.h"
#include "chrome/browser/component_updater/subresource_filter_component_installer.h" #include "chrome/browser/component_updater/subresource_filter_component_installer.h"
#include "chrome/browser/component_updater/supervised_user_whitelist_installer.h" #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h"
#include "chrome/browser/component_updater/widevine_cdm_component_installer.h"
#include "chrome/browser/defaults.h" #include "chrome/browser/defaults.h"
#include "chrome/browser/first_run/first_run.h" #include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/lifetime/application_lifetime.h"
...@@ -306,6 +305,10 @@ ...@@ -306,6 +305,10 @@
#include "chrome/browser/vr/service/vr_service_impl.h" #include "chrome/browser/vr/service/vr_service_impl.h"
#endif #endif
#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
#include "chrome/browser/component_updater/widevine_cdm_component_installer.h"
#endif // BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
#if defined(USE_AURA) #if defined(USE_AURA)
#include "services/service_manager/runner/common/client_util.h" #include "services/service_manager/runner/common/client_util.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
...@@ -549,9 +552,9 @@ void RegisterComponentsForUpdate(PrefService* profile_prefs) { ...@@ -549,9 +552,9 @@ void RegisterComponentsForUpdate(PrefService* profile_prefs) {
RegisterPepperFlashComponent(cus); RegisterPepperFlashComponent(cus);
#endif // !defined(OS_ANDROID) #endif // !defined(OS_ANDROID)
#if BUILDFLAG(ENABLE_WIDEVINE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) #if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
RegisterWidevineCdmComponent(cus); RegisterWidevineCdmComponent(cus);
#endif // BUILDFLAG(ENABLE_WIDEVINE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) #endif // BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
#if BUILDFLAG(ENABLE_NACL) && !defined(OS_ANDROID) #if BUILDFLAG(ENABLE_NACL) && !defined(OS_ANDROID)
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
......
...@@ -46,8 +46,8 @@ ...@@ -46,8 +46,8 @@
#include "third_party/widevine/cdm/buildflags.h" #include "third_party/widevine/cdm/buildflags.h"
#include "third_party/widevine/cdm/widevine_cdm_common.h" #include "third_party/widevine/cdm/widevine_cdm_common.h"
#if !BUILDFLAG(ENABLE_WIDEVINE) #if !BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
#error This file should only be compiled when Widevine is enabled #error This file should only be compiled when Widevine CDM component is enabled
#endif #endif
using content::BrowserThread; using content::BrowserThread;
...@@ -55,8 +55,6 @@ using content::CdmRegistry; ...@@ -55,8 +55,6 @@ using content::CdmRegistry;
namespace component_updater { namespace component_updater {
#if defined(WIDEVINE_CDM_IS_COMPONENT)
namespace { namespace {
// CRX hash. The extension id is: oimompecagnajdejgnnjijobebaeigek. // CRX hash. The extension id is: oimompecagnajdejgnnjijobebaeigek.
...@@ -515,14 +513,10 @@ void WidevineCdmComponentInstallerPolicy::UpdateCdmPath( ...@@ -515,14 +513,10 @@ void WidevineCdmComponentInstallerPolicy::UpdateCdmPath(
absolute_cdm_install_dir, base::Passed(&manifest))); absolute_cdm_install_dir, base::Passed(&manifest)));
} }
#endif // defined(WIDEVINE_CDM_IS_COMPONENT)
void RegisterWidevineCdmComponent(ComponentUpdateService* cus) { void RegisterWidevineCdmComponent(ComponentUpdateService* cus) {
#if defined(WIDEVINE_CDM_IS_COMPONENT)
auto installer = base::MakeRefCounted<ComponentInstaller>( auto installer = base::MakeRefCounted<ComponentInstaller>(
std::make_unique<WidevineCdmComponentInstallerPolicy>()); std::make_unique<WidevineCdmComponentInstallerPolicy>());
installer->Register(cus, base::OnceClosure()); installer->Register(cus, base::OnceClosure());
#endif // defined(WIDEVINE_CDM_IS_COMPONENT)
} }
} // namespace component_updater } // namespace component_updater
...@@ -96,16 +96,12 @@ ...@@ -96,16 +96,12 @@
#if BUILDFLAG(ENABLE_LIBRARY_CDMS) #if BUILDFLAG(ENABLE_LIBRARY_CDMS)
#include "media/cdm/cdm_paths.h" // nogncheck #include "media/cdm/cdm_paths.h" // nogncheck
// The order is sensitive here as WIDEVINE_CDM_IS_COMPONENT is defined in
// widevine_cdm_common.h.
// TODO(xhwang): Also make WIDEVINE_CDM_IS_COMPONENT a buildflag to avoid this.
#include "third_party/widevine/cdm/widevine_cdm_common.h" // nogncheck
// Registers Widevine CDM if Widevine is enabled, the Widevine CDM is // Registers Widevine CDM if Widevine is enabled, the Widevine CDM is
// bundled and not a component. When the Widevine CDM is a component, it is // bundled and not a component. When the Widevine CDM is a component, it is
// registered in widevine_cdm_component_installer.cc. // registered in widevine_cdm_component_installer.cc.
#if BUILDFLAG(ENABLE_WIDEVINE) && BUILDFLAG(SHOULD_BUNDLE_WIDEVINE_CDM) && \ #if BUILDFLAG(SHOULD_BUNDLE_WIDEVINE_CDM) && !BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
!defined(WIDEVINE_CDM_IS_COMPONENT)
#define REGISTER_BUNDLED_WIDEVINE_CDM #define REGISTER_BUNDLED_WIDEVINE_CDM
#include "third_party/widevine/cdm/widevine_cdm_common.h" // nogncheck
// TODO(crbug.com/663554): Needed for WIDEVINE_CDM_VERSION_STRING. Support // TODO(crbug.com/663554): Needed for WIDEVINE_CDM_VERSION_STRING. Support
// component updated CDM on all desktop platforms and remove this. // component updated CDM on all desktop platforms and remove this.
// This file is In SHARED_INTERMEDIATE_DIR. // This file is In SHARED_INTERMEDIATE_DIR.
......
...@@ -233,7 +233,7 @@ jumbo_static_library("renderer") { ...@@ -233,7 +233,7 @@ jumbo_static_library("renderer") {
} }
} }
if (enable_library_cdms && enable_widevine) { if (enable_widevine_cdm_component) {
deps += [ "//third_party/widevine/cdm:headers" ] deps += [ "//third_party/widevine/cdm:headers" ]
} }
......
...@@ -6,10 +6,9 @@ ...@@ -6,10 +6,9 @@
#include "base/time/default_tick_clock.h" #include "base/time/default_tick_clock.h"
#include "chrome/renderer/media/chrome_key_systems.h" #include "chrome/renderer/media/chrome_key_systems.h"
#include "media/media_buildflags.h"
#include "third_party/widevine/cdm/buildflags.h" #include "third_party/widevine/cdm/buildflags.h"
#if BUILDFLAG(ENABLE_LIBRARY_CDMS) && BUILDFLAG(ENABLE_WIDEVINE) #if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
#include "third_party/widevine/cdm/widevine_cdm_common.h" #include "third_party/widevine/cdm/widevine_cdm_common.h"
#endif #endif
...@@ -36,8 +35,7 @@ void ChromeKeySystemsProvider::AddSupportedKeySystems( ...@@ -36,8 +35,7 @@ void ChromeKeySystemsProvider::AddSupportedKeySystems(
// Check whether all potentially supported key systems are supported. If so, // Check whether all potentially supported key systems are supported. If so,
// no need to update again. // no need to update again.
#if BUILDFLAG(ENABLE_LIBRARY_CDMS) && BUILDFLAG(ENABLE_WIDEVINE) && \ #if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
defined(WIDEVINE_CDM_IS_COMPONENT)
for (const auto& properties : *key_systems) { for (const auto& properties : *key_systems) {
if (properties->GetKeySystemName() == kWidevineKeySystem) { if (properties->GetKeySystemName() == kWidevineKeySystem) {
is_update_needed_ = false; is_update_needed_ = false;
......
...@@ -127,7 +127,7 @@ TEST(ChromeKeySystemsProviderTest, IsKeySystemsUpdateNeeded) { ...@@ -127,7 +127,7 @@ TEST(ChromeKeySystemsProviderTest, IsKeySystemsUpdateNeeded) {
EXPECT_FALSE(key_systems_provider.IsKeySystemsUpdateNeeded()); EXPECT_FALSE(key_systems_provider.IsKeySystemsUpdateNeeded());
tick_clock.Advance(base::TimeDelta::FromMilliseconds(10)); tick_clock.Advance(base::TimeDelta::FromMilliseconds(10));
#if BUILDFLAG(ENABLE_WIDEVINE) && defined(WIDEVINE_CDM_IS_COMPONENT) #if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
// Require update once enough time has passed for builds that install Widevine // Require update once enough time has passed for builds that install Widevine
// as a component. // as a component.
EXPECT_TRUE(key_systems_provider.IsKeySystemsUpdateNeeded()); EXPECT_TRUE(key_systems_provider.IsKeySystemsUpdateNeeded());
...@@ -157,5 +157,5 @@ TEST(ChromeKeySystemsProviderTest, IsKeySystemsUpdateNeeded) { ...@@ -157,5 +157,5 @@ TEST(ChromeKeySystemsProviderTest, IsKeySystemsUpdateNeeded) {
// No update needed for builds that either don't offer Widevine or do so // No update needed for builds that either don't offer Widevine or do so
// as part of Chrome rather than component installer. // as part of Chrome rather than component installer.
EXPECT_FALSE(key_systems_provider.IsKeySystemsUpdateNeeded()); EXPECT_FALSE(key_systems_provider.IsKeySystemsUpdateNeeded());
#endif // BUILDFLAG(ENABLE_WIDEVINE) && defined(WIDEVINE_CDM_IS_COMPONENT) #endif // BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
} }
...@@ -15,6 +15,7 @@ buildflag_header("buildflags") { ...@@ -15,6 +15,7 @@ buildflag_header("buildflags") {
flags = [ flags = [
"ENABLE_WIDEVINE=$enable_widevine", "ENABLE_WIDEVINE=$enable_widevine",
"SHOULD_BUNDLE_WIDEVINE_CDM=$should_bundle_widevine_cdm", "SHOULD_BUNDLE_WIDEVINE_CDM=$should_bundle_widevine_cdm",
"ENABLE_WIDEVINE_CDM_COMPONENT=$enable_widevine_cdm_component",
] ]
} }
......
...@@ -11,14 +11,21 @@ declare_args() { ...@@ -11,14 +11,21 @@ declare_args() {
enable_widevine = is_chrome_branded || is_android enable_widevine = is_chrome_branded || is_android
} }
enable_widevine_cdm_host_verification = # The Widevine CDM can be updated as a component. This only applies to platforms
enable_widevine && enable_cdm_host_verification # where the CDM is a standalone library (enable_library_cdms == true). Currently
# it's only supported on Windows and Mac. The CDM can still be bundled when it's
# a component, see below.
enable_widevine_cdm_component =
enable_widevine && enable_library_cdms && (is_win || is_mac)
# Only bundle Widevine CDM in Google Chrome builds. # The Widevine CDM is bundled as part of Google Chrome builds.
# TODO: Provide prebuilt libraries for ARM64. # TODO(hmchen): Provide prebuilt libraries for ARM64.
should_bundle_widevine_cdm = enable_widevine && is_chrome_branded && should_bundle_widevine_cdm = enable_widevine && is_chrome_branded &&
enable_library_cdms && target_cpu != "arm64" enable_library_cdms && target_cpu != "arm64"
enable_widevine_cdm_host_verification =
enable_widevine && enable_cdm_host_verification
template("widevine_sign_file") { template("widevine_sign_file") {
# For official builds, generate a signature file for |file| which will # For official builds, generate a signature file for |file| which will
# be used by Widevine. If |signature_file| is not specified, the signature # be used by Widevine. If |signature_file| is not specified, the signature
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef WIDEVINE_CDM_WIDEVINE_CDM_COMMON_H_ #ifndef WIDEVINE_CDM_WIDEVINE_CDM_COMMON_H_
#define WIDEVINE_CDM_WIDEVINE_CDM_COMMON_H_ #define WIDEVINE_CDM_WIDEVINE_CDM_COMMON_H_
#include "media/media_buildflags.h"
// This file defines constants common to all Widevine CDM versions. // This file defines constants common to all Widevine CDM versions.
// "alpha" is a temporary name until a convention is defined. // "alpha" is a temporary name until a convention is defined.
...@@ -24,7 +22,6 @@ const char kWidevineKeySystemNameForUMA[] = "Widevine"; ...@@ -24,7 +22,6 @@ const char kWidevineKeySystemNameForUMA[] = "Widevine";
const char kWidevineCdmDisplayName[] = "Widevine Content Decryption Module"; const char kWidevineCdmDisplayName[] = "Widevine Content Decryption Module";
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
// Identifier used by the PluginPrivateFileSystem to identify the files stored // Identifier used by the PluginPrivateFileSystem to identify the files stored
// for the Widevine CDM. This is used to store persistent files. As the files // for the Widevine CDM. This is used to store persistent files. As the files
// were initially used by the CDM running as a pepper plugin, this ID is based // were initially used by the CDM running as a pepper plugin, this ID is based
...@@ -35,10 +32,4 @@ const char kWidevineCdmFileSystemId[] = "application_x-ppapi-widevine-cdm"; ...@@ -35,10 +32,4 @@ const char kWidevineCdmFileSystemId[] = "application_x-ppapi-widevine-cdm";
// Name of the CDM library. // Name of the CDM library.
const char kWidevineCdmLibraryName[] = "widevinecdm"; const char kWidevineCdmLibraryName[] = "widevinecdm";
#if defined(OS_MACOSX) || defined(OS_WIN)
// CDM is installed by the component installer instead of the Chrome installer.
#define WIDEVINE_CDM_IS_COMPONENT
#endif // defined(OS_MACOSX) || defined(OS_WIN)
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
#endif // WIDEVINE_CDM_WIDEVINE_CDM_COMMON_H_ #endif // WIDEVINE_CDM_WIDEVINE_CDM_COMMON_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment