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