Commit 3f789b50 authored by Robert Sesek's avatar Robert Sesek Committed by Commit Bot

Convert the ENABLE_SCREEN_CAPTURE define to a BUILDFLAG.

Using global defines pollutes the build. The preferred method for
feature defines are to use buildflags, which are scoped to the targets
and files that require them.

Change-Id: Id9d749cbbb4f9a1a6847171df1cbc1c903bacdbf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1803804Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703920}
parent 04e4737f
......@@ -9,6 +9,7 @@ import("//build/config/linux/pangocairo/pangocairo.gni")
import("//build/config/ui.gni")
import("//chromeos/assistant/assistant.gni")
import("//components/ui_devtools/devtools.gni")
import("//content/common/features.gni")
import("//gpu/vulkan/features.gni")
import("//media/media_options.gni")
import("//net/features.gni")
......@@ -2073,8 +2074,7 @@ jumbo_source_set("browser") {
# Desktop/Window/WebContents screen capture implementations, conditionally
# built depending on the available implementations for each platform.
if (is_linux || is_mac || is_win) {
defines += [ "ENABLE_SCREEN_CAPTURE=1" ]
if (enable_screen_capture && !is_android) {
sources += [
"media/capture/desktop_capture_device.cc",
"media/capture/desktop_capture_device.h",
......@@ -2438,10 +2438,7 @@ jumbo_source_set("browser") {
if (enable_vulkan) {
deps += [ "//gpu/vulkan/init" ]
}
defines += [
"APPCACHE_USE_SIMPLE_CACHE",
"ENABLE_SCREEN_CAPTURE=1",
]
defines += [ "APPCACHE_USE_SIMPLE_CACHE" ]
libs += [ "jnigraphics" ]
} else {
# Not Android.
......
......@@ -9,10 +9,12 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/metrics/histogram_macros.h"
#include "build/build_config.h"
#include "content/common/buildflags.h"
#include "content/public/browser/browser_thread.h"
#include "media/media_buildflags.h"
#if defined(ENABLE_SCREEN_CAPTURE) && !defined(OS_ANDROID)
#if BUILDFLAG(ENABLE_SCREEN_CAPTURE) && !defined(OS_ANDROID)
#include "content/browser/media/capture/desktop_capture_device.h"
#endif
......
......@@ -15,6 +15,7 @@
#include "build/build_config.h"
#include "content/browser/renderer_host/media/in_process_launched_video_capture_device.h"
#include "content/browser/renderer_host/media/video_capture_controller.h"
#include "content/common/buildflags.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/desktop_media_id.h"
......@@ -29,7 +30,7 @@
#include "media/capture/video/video_frame_receiver_on_task_runner.h"
#include "third_party/blink/public/common/mediastream/media_stream_request.h"
#if defined(ENABLE_SCREEN_CAPTURE)
#if BUILDFLAG(ENABLE_SCREEN_CAPTURE)
#include "content/browser/media/capture/desktop_capture_device_uma_types.h"
#if defined(OS_ANDROID)
#include "content/browser/media/capture/screen_capture_device_android.h"
......@@ -40,7 +41,7 @@
#endif
#include "content/browser/media/capture/desktop_capture_device.h"
#endif // defined(OS_ANDROID)
#endif // defined(ENABLE_SCREEN_CAPTURE)
#endif // BUILDFLAG(ENABLE_SCREEN_CAPTURE)
#if defined(OS_CHROMEOS)
#include "content/browser/gpu/chromeos/video_capture_dependencies.h"
......@@ -140,7 +141,7 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
break;
}
#if defined(ENABLE_SCREEN_CAPTURE)
#if BUILDFLAG(ENABLE_SCREEN_CAPTURE)
#if !defined(OS_ANDROID)
case blink::mojom::MediaStreamType::GUM_TAB_VIDEO_CAPTURE:
start_capture_closure = base::BindOnce(
......@@ -221,7 +222,7 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
std::move(after_start_capture_callback));
break;
}
#endif // defined(ENABLE_SCREEN_CAPTURE)
#endif // BUILDFLAG(ENABLE_SCREEN_CAPTURE)
default: {
NOTIMPLEMENTED();
......@@ -329,7 +330,7 @@ void InProcessVideoCaptureDeviceLauncher::DoStartDeviceCaptureOnDeviceThread(
std::move(result_callback).Run(std::move(video_capture_device));
}
#if defined(ENABLE_SCREEN_CAPTURE)
#if BUILDFLAG(ENABLE_SCREEN_CAPTURE)
#if !defined(OS_ANDROID)
void InProcessVideoCaptureDeviceLauncher::DoStartTabCaptureOnDeviceThread(
......@@ -407,7 +408,7 @@ void InProcessVideoCaptureDeviceLauncher::DoStartDesktopCaptureOnDeviceThread(
std::move(result_callback).Run(std::move(video_capture_device));
}
#endif // defined(ENABLE_SCREEN_CAPTURE)
#endif // BUILDFLAG(ENABLE_SCREEN_CAPTURE)
void InProcessVideoCaptureDeviceLauncher::
DoStartFakeDisplayCaptureOnDeviceThread(
......
......@@ -24,6 +24,7 @@
#include "content/browser/renderer_host/media/video_capture_controller_event_handler.h"
#include "content/browser/screenlock_monitor/screenlock_monitor.h"
#include "content/browser/screenlock_monitor/screenlock_monitor_source.h"
#include "content/common/buildflags.h"
#include "content/public/browser/desktop_media_id.h"
#include "content/public/test/browser_task_environment.h"
#include "media/capture/video/fake_video_capture_device_factory.h"
......@@ -907,7 +908,7 @@ TEST_F(VideoCaptureManagerTest, DeviceCaptureDeviceNotClosedOnScreenlock) {
vcm_->UnregisterListener(listener_.get());
}
#if defined(ENABLE_SCREEN_CAPTURE) && !defined(OS_ANDROID)
#if BUILDFLAG(ENABLE_SCREEN_CAPTURE) && !defined(OS_ANDROID)
// Try to open, start a desktop capture device, and confirm it's closed on
// ScreenLocked event on desktop platforms.
TEST_F(VideoCaptureManagerTest, DesktopCaptureDeviceClosedOnScreenlock) {
......@@ -941,7 +942,7 @@ TEST_F(VideoCaptureManagerTest, DesktopCaptureDeviceClosedOnScreenlock) {
base::RunLoop().RunUntilIdle();
vcm_->UnregisterListener(listener_.get());
}
#endif // ENABLE_SCREEN_CAPTURE && !OS_ANDROID
#endif // ENABLE_SCREEN_CAPTURE && !defined(OS_ANDROID)
// TODO(mcasas): Add a test to check consolidation of the supported formats
// provided by the device when http://crbug.com/323913 is closed.
......
......@@ -24,6 +24,7 @@ buildflag_header("buildflags") {
flags = [
"USE_EXTERNAL_POPUP_MENU=$use_external_popup_menu",
"ALLOW_CRITICAL_MEMORY_PRESSURE_HANDLING_IN_FOREGROUND=$allow_critical_memory_pressure_handling_in_foreground",
"ENABLE_SCREEN_CAPTURE=$enable_screen_capture",
]
}
......
......@@ -12,3 +12,5 @@ declare_args() {
# false, critical memory pressure is treated like moderate pressure in foreground).
allow_critical_memory_pressure_handling_in_foreground = is_chromecast
}
enable_screen_capture = is_linux || is_mac || is_win || is_android
......@@ -10,6 +10,7 @@ import("//build/config/features.gni")
import("//build/config/jumbo.gni")
import("//build/config/ui.gni")
import("//build/nocompile.gni")
import("//content/common/features.gni")
import("//media/media_options.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//net/features.gni")
......@@ -2047,6 +2048,7 @@ test("content_unittests") {
"//content/browser/service_worker:service_worker_proto",
"//content/browser/speech/proto",
"//content/child:for_content_tests",
"//content/common:buildflags",
"//content/gpu",
"//content/public/browser",
"//content/public/child",
......@@ -2202,9 +2204,9 @@ test("content_unittests") {
}
# Screen capture unit tests.
if (is_linux || is_mac || is_win) {
defines += [ "ENABLE_SCREEN_CAPTURE=1" ]
if (enable_screen_capture && !is_android) {
deps += [
"//content/common:buildflags",
"//media/capture:test_support",
"//third_party/libyuv",
"//third_party/webrtc/modules/desktop_capture",
......
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