Skip to content

Commit

Permalink
Move ENABLE_PEPPER_CDMS to a buildflag header.
Browse files Browse the repository at this point in the history
Removes the global build flag and #define and converts to a buildflag header in
ppapi/features.

A new target "//third_party/widevine/cdm:headers" was added since
widevine_cdm_version.h was unreferenced in the build. Given that this file now
requires //ppapi/features we really need "gn check" to work on it. I made the
existing users of ":version_h" reference this new target which encompasses the
public headers of the widevine CDM.

TBR=jschuh (render_messages.h)

Review-Url: https://codereview.chromium.org/2411433002
Cr-Commit-Position: refs/heads/master@{#424477}
  • Loading branch information
brettw authored and Commit bot committed Oct 11, 2016
1 parent 382a7a5 commit e23a62a
Show file tree
Hide file tree
Showing 59 changed files with 233 additions and 142 deletions.
2 changes: 0 additions & 2 deletions android_webview/renderer/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ include_rules = [
"+third_party/WebKit/public/platform",
"+third_party/WebKit/public/web",

"+third_party/widevine/cdm/widevine_cdm_common.h",

"+ui/gfx",
"+ui/gl/gpu_memory_buffer.h",

Expand Down
4 changes: 0 additions & 4 deletions build/config/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ config("feature_flags") {
if (enable_notifications) {
defines += [ "ENABLE_NOTIFICATIONS" ]
}
if (enable_pepper_cdms) {
# TODO(brettw) should probably be "=1"
defines += [ "ENABLE_PEPPER_CDMS" ]
}
if (enable_plugins) {
defines += [ "ENABLE_PLUGINS=1" ]
}
Expand Down
4 changes: 0 additions & 4 deletions build/config/features.gni
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ use_browser_spellchecker = is_android || is_mac
# Use Minikin hyphenation engine.
use_minikin_hyphenation = is_android

# Enables the use of CDMs in pepper plugins.
enable_pepper_cdms =
enable_plugins && (is_linux || is_mac || is_win) && !is_chromecast

# The seccomp-bpf sandbox is only supported on five architectures
# currently.
# Do not disable seccomp_bpf anywhere without talking to
Expand Down
1 change: 1 addition & 0 deletions chrome/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ include_rules = [
"+content/public/test",
"+mojo/common",
"+mojo/public",
"+ppapi/features",

# Don't allow inclusion of these other libs we shouldn't be calling directly.
"-webkit",
Expand Down
4 changes: 3 additions & 1 deletion chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import("//build/split_static_library.gni")
import("//chrome/common/features.gni")
import("//components/os_crypt/features.gni")
import("//media/media_options.gni")
import("//ppapi/features/features.gni")
import("//third_party/protobuf/proto_library.gni")

# //build/config/android/rules.gni imports //tools/grit/grit_rule.gni, which
Expand Down Expand Up @@ -1444,7 +1445,7 @@ split_static_library("browser") {
"//third_party/re2",
"//third_party/smhasher:cityhash",
"//third_party/webrtc/modules/desktop_capture",
"//third_party/widevine/cdm:version_h",
"//third_party/widevine/cdm:headers",
"//third_party/zlib",
"//third_party/zlib:compression_utils",
"//third_party/zlib:minizip",
Expand Down Expand Up @@ -1920,6 +1921,7 @@ split_static_library("browser") {
]
deps += [
"//components/pdf/browser",
"//ppapi/features",
"//ppapi/proxy:ipc",
"//third_party/adobe/flash:flapper_version_h",
]
Expand Down
15 changes: 8 additions & 7 deletions chrome/browser/content_settings/content_settings_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/url_request/url_request_mock_http_job.h"
#include "ppapi/features/features.h"
#include "ppapi/shared_impl/ppapi_switches.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
Expand All @@ -53,7 +54,7 @@
#include "base/mac/scoped_nsautorelease_pool.h"
#endif

#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
#include "chrome/browser/media/pepper_cdm_test_helper.h"
#endif

Expand Down Expand Up @@ -356,7 +357,7 @@ class PepperContentSettingsSpecialCasesTest : public ContentSettingsTest {
#endif
}

#if defined(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE)
#if BUILDFLAG(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE)
// Since the CDM is bundled and registered through the component updater,
// we must re-enable the component updater.
void SetUpDefaultCommandLine(base::CommandLine* command_line) override {
Expand All @@ -365,7 +366,7 @@ class PepperContentSettingsSpecialCasesTest : public ContentSettingsTest {
test_launcher_utils::RemoveCommandLineSwitch(
default_command_line, switches::kDisableComponentUpdate, command_line);
}
#endif // defined(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE)

void SetUpInProcessBrowserTestFixture() override {
ContentSettingsTest::SetUpInProcessBrowserTestFixture();
Expand Down Expand Up @@ -497,7 +498,7 @@ IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest,
RunLoadPepperPluginTest(content::kFlashPluginSwfMimeType, false);
}

#if defined(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) && \
#if BUILDFLAG(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) && \
!defined(OS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest,
WidevineCdm) {
Expand All @@ -508,7 +509,7 @@ IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest,
EXPECT_TRUE(IsPepperCdmRegistered(kWidevineCdmPluginMimeType));
RunLoadPepperPluginTest(kWidevineCdmPluginMimeType, true);
}
#endif // defined(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) &&
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) &&
// !defined(OS_CHROMEOS)

#if !defined(DISABLE_NACL)
Expand All @@ -527,7 +528,7 @@ IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest,
RunJavaScriptBlockedTest("load_flash_no_js.html", false);
}

#if defined(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE)
#if BUILDFLAG(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE)
IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest,
WidevineCdm) {
// Check that Widevine CDM is available and registered.
Expand All @@ -537,7 +538,7 @@ IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest,
EXPECT_TRUE(IsPepperCdmRegistered(kWidevineCdmPluginMimeType));
RunJavaScriptBlockedTest("load_widevine_no_js.html", true);
}
#endif // defined(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE)

#if !defined(DISABLE_NACL)
IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest,
Expand Down
11 changes: 6 additions & 5 deletions chrome/browser/load_library_perf_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "ppapi/features/features.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/perf/perf_test.h"

#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.

#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
#include "chrome/browser/media/pepper_cdm_test_constants.h"
#include "media/cdm/cdm_paths.h"
#endif
Expand Down Expand Up @@ -60,7 +61,7 @@ void MeasureSizeAndTimeToLoadNativeLibrary(
true);
}

#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)

void MeasureSizeAndTimeToLoadCdm(const std::string& cdm_base_dir,
const std::string& cdm_name) {
Expand All @@ -69,11 +70,11 @@ void MeasureSizeAndTimeToLoadCdm(const std::string& cdm_base_dir,
base::FilePath::FromUTF8Unsafe(cdm_name));
}

#endif // defined(ENABLE_PEPPER_CDMS)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)

} // namespace

#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
#if defined(WIDEVINE_CDM_AVAILABLE)
TEST(LoadCDMPerfTest, Widevine) {
MeasureSizeAndTimeToLoadCdm(
Expand All @@ -97,4 +98,4 @@ TEST(LoadCDMPerfTest, ExternalClearKeyAdapter) {
MeasureSizeAndTimeToLoadCdm(kClearKeyCdmBaseDirectory,
kClearKeyCdmAdapterFileName);
}
#endif // defined(ENABLE_PEPPER_CDMS)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
24 changes: 13 additions & 11 deletions chrome/browser/media/encrypted_media_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
#include "chrome/test/base/test_launcher_utils.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h"
#include "ppapi/features/features.h"
#include "testing/gtest/include/gtest/gtest-spi.h"

#if defined(OS_ANDROID)
#include "base/android/build_info.h"
#endif

#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
#include "chrome/browser/media/pepper_cdm_test_constants.h"
#include "chrome/browser/media/pepper_cdm_test_helper.h"
#include "media/base/media_switches.h"
Expand Down Expand Up @@ -239,14 +241,14 @@ class EncryptedMediaTestBase : public MediaBrowserTest {
switches::kDisableGestureRequirementForMediaPlayback);
}

#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
void SetUpDefaultCommandLine(base::CommandLine* command_line) override {
base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM);
InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line);
test_launcher_utils::RemoveCommandLineSwitch(
default_command_line, switches::kDisableComponentUpdate, command_line);
}
#endif // defined(ENABLE_PEPPER_CDMS)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)

void SetUpCommandLineForKeySystem(const std::string& key_system,
base::CommandLine* command_line) {
Expand All @@ -256,19 +258,19 @@ class EncryptedMediaTestBase : public MediaBrowserTest {
// TODO(shadi): Add port forwarding to the test web server configuration.
command_line->AppendSwitch(switches::kDisableWebSecurity);

#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
if (IsExternalClearKey(key_system)) {
RegisterPepperCdm(command_line, kClearKeyCdmBaseDirectory,
kClearKeyCdmAdapterFileName, kClearKeyCdmDisplayName,
kClearKeyCdmPepperMimeType);
command_line->AppendSwitchASCII(switches::kEnableFeatures,
media::kExternalClearKeyForTesting.name);
}
#endif // defined(ENABLE_PEPPER_CDMS)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
}
};

#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
// Tests encrypted media playback using ExternalClearKey key system in
// decrypt-and-decode mode.
class ECKEncryptedMediaTest : public EncryptedMediaTestBase {
Expand Down Expand Up @@ -311,7 +313,7 @@ class WVEncryptedMediaTest : public EncryptedMediaTestBase {
};

#endif // defined(WIDEVINE_CDM_AVAILABLE)
#endif // defined(ENABLE_PEPPER_CDMS)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)

// Tests encrypted media playback with a combination of parameters:
// - char*: Key system name.
Expand Down Expand Up @@ -419,7 +421,7 @@ INSTANTIATE_TEST_CASE_P(MSE_ClearKey,
Combine(Values(kClearKeyKeySystem), Values(MSE)));

// External Clear Key is currently only used on platforms that use Pepper CDMs.
#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey,
EncryptedMediaTest,
Combine(Values(kExternalClearKeyKeySystem),
Expand All @@ -438,7 +440,7 @@ INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly,
EncryptedMediaTest,
Combine(Values(kExternalClearKeyDecryptOnlyKeySystem),
Values(MSE)));
#endif // defined(ENABLE_PEPPER_CDMS)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)

#if defined(WIDEVINE_CDM_AVAILABLE)
#if !defined(OS_CHROMEOS)
Expand Down Expand Up @@ -605,7 +607,7 @@ IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) {
}
#endif // defined(WIDEVINE_CDM_AVAILABLE)

#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, InitializeCDMFail) {
TestNonPlaybackCases(kExternalClearKeyInitializeFailKeySystem,
kEmeNotSupportedError);
Expand Down Expand Up @@ -651,4 +653,4 @@ IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) {
kEmeSessionNotFound);
}

#endif // defined(ENABLE_PEPPER_CDMS)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
30 changes: 16 additions & 14 deletions chrome/browser/media/encrypted_media_supported_types_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
#include "media/base/test_data_util.h"
#include "media/media_features.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "ppapi/features/features.h"
#include "url/gurl.h"

#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
#include "chrome/browser/media/pepper_cdm_test_constants.h"
#include "chrome/browser/media/pepper_cdm_test_helper.h"
#endif
Expand Down Expand Up @@ -78,15 +79,15 @@ const char kUnexpectedResult[] = "unexpected result";
#endif

// Expectations for External Clear Key.
#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
#define EXPECT_ECK EXPECT_SUCCESS
#define EXPECT_ECK_PROPRIETARY EXPECT_PROPRIETARY
#define EXPECT_ECK_NO_MATCH EXPECT_NO_MATCH
#else
#define EXPECT_ECK EXPECT_UNKNOWN_KEYSYSTEM
#define EXPECT_ECK_PROPRIETARY EXPECT_UNKNOWN_KEYSYSTEM
#define EXPECT_ECK_NO_MATCH EXPECT_UNKNOWN_KEYSYSTEM
#endif // defined(ENABLE_PEPPER_CDMS)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)

// Expectations for Widevine.
#if defined(WIDEVINE_CDM_AVAILABLE)
Expand Down Expand Up @@ -167,14 +168,14 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest {
}
const CodecVector& invalid_codecs() const { return invalid_codecs_; }

#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
void SetUpDefaultCommandLine(base::CommandLine* command_line) override {
base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM);
InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line);
test_launcher_utils::RemoveCommandLineSwitch(
default_command_line, switches::kDisableComponentUpdate, command_line);
}
#endif // defined(ENABLE_PEPPER_CDMS)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)

void SetUpOnMainThread() override {
InProcessBrowserTest::SetUpOnMainThread();
Expand Down Expand Up @@ -279,7 +280,7 @@ class EncryptedMediaSupportedTypesClearKeyTest
// For ExternalClearKey tests, ensure that the ClearKey adapter is loaded.
class EncryptedMediaSupportedTypesExternalClearKeyTest
: public EncryptedMediaSupportedTypesTest {
#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
protected:
void SetUpCommandLine(base::CommandLine* command_line) override {
EncryptedMediaSupportedTypesTest::SetUpCommandLine(command_line);
Expand All @@ -289,7 +290,7 @@ class EncryptedMediaSupportedTypesExternalClearKeyTest
command_line->AppendSwitchASCII(switches::kEnableFeatures,
media::kExternalClearKeyForTesting.name);
}
#endif // defined(ENABLE_PEPPER_CDMS)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
};

// By default, the External Clear Key (ECK) key system is not supported even if
Expand All @@ -301,19 +302,19 @@ class EncryptedMediaSupportedTypesExternalClearKeyNotEnabledTest
protected:
void SetUpCommandLine(base::CommandLine* command_line) override {
EncryptedMediaSupportedTypesTest::SetUpCommandLine(command_line);
#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
RegisterPepperCdm(command_line, kClearKeyCdmBaseDirectory,
kClearKeyCdmAdapterFileName, kClearKeyCdmDisplayName,
kClearKeyCdmPepperMimeType);
#endif // defined(ENABLE_PEPPER_CDMS)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
}
};

class EncryptedMediaSupportedTypesWidevineTest
: public EncryptedMediaSupportedTypesTest {
};

#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
// Registers ClearKey CDM with the wrong path (filename).
class EncryptedMediaSupportedTypesClearKeyCDMRegisteredWithWrongPathTest
: public EncryptedMediaSupportedTypesTest {
Expand Down Expand Up @@ -342,7 +343,7 @@ class EncryptedMediaSupportedTypesWidevineCDMRegisteredWithWrongPathTest
}
};

#endif // defined(ENABLE_PEPPER_CDMS)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)

IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesClearKeyTest, Basic) {
EXPECT_SUCCESS(AreCodecsSupportedByKeySystem(
Expand Down Expand Up @@ -474,7 +475,7 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesClearKeyTest, Audio_MP4) {
// External Clear Key
//

// When defined(ENABLE_PEPPER_CDMS), this also tests the Pepper CDM check.
// When BUILDFLAG(ENABLE_PEPPER_CDMS), this also tests the Pepper CDM check.
IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesExternalClearKeyTest,
Basic) {
EXPECT_ECK(AreCodecsSupportedByKeySystem(
Expand Down Expand Up @@ -699,7 +700,7 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineTest, Audio_MP4) {
kAudioMP4MimeType, video_webm_codecs(), kWidevine));
}

#if defined(ENABLE_PEPPER_CDMS)
#if BUILDFLAG(ENABLE_PEPPER_CDMS)
// Since this test fixture does not register the CDMs on the command line, the
// check for the CDMs in chrome_key_systems.cc should fail, and they should not
// be registered with KeySystems.
Expand Down Expand Up @@ -746,5 +747,6 @@ IN_PROC_BROWSER_TEST_F(
kVideoWebMMimeType, no_codecs(), kClearKey));
}
#endif // !defined(WIDEVINE_CDM_AVAILABLE)
#endif // defined(ENABLE_PEPPER_CDMS)
#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)

} // namespace chrome
Loading

0 comments on commit e23a62a

Please sign in to comment.