remoting: Use BUILDFLAG for OS checking
Use BUILDFLAG(IS_XXX) instead of defined(OS_XXX).
Generated by `os_buildflag_migration.py` (https://crrev.com/c/3311983).
[email protected]
Bug: 1234043
Test: No functionality change
Change-Id: Ida556f7dd6c846203cae3bc062da08a4d2b5fafe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3373985
Reviewed-by: Nico Weber <[email protected]>
Owners-Override: Nico Weber <[email protected]>
Commit-Queue: Xiaohan Wang <[email protected]>
Cr-Commit-Position: refs/heads/main@{#958774}
diff --git a/remoting/base/auto_thread.cc b/remoting/base/auto_thread.cc
index 7ff953c..8b91584 100644
--- a/remoting/base/auto_thread.cc
+++ b/remoting/base/auto_thread.cc
@@ -19,11 +19,11 @@
#include "build/build_config.h"
#include "remoting/base/auto_thread_task_runner.h"
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
#include "base/files/file_descriptor_watcher_posix.h"
#endif
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "base/win/scoped_com_initializer.h"
#endif
@@ -31,7 +31,7 @@
namespace {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
std::unique_ptr<base::win::ScopedCOMInitializer> CreateComInitializer(
AutoThread::ComInitType type) {
std::unique_ptr<base::win::ScopedCOMInitializer> initializer;
@@ -83,7 +83,7 @@
return CreateWithType(name, joiner, base::MessagePumpType::DEFAULT);
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// static
scoped_refptr<AutoThreadTaskRunner> AutoThread::CreateWithLoopAndComInitTypes(
const char* name,
@@ -102,7 +102,7 @@
AutoThread::AutoThread(const char* name)
: startup_data_(nullptr),
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
com_init_type_(COM_INIT_NONE),
#endif
thread_(),
@@ -113,7 +113,7 @@
AutoThread::AutoThread(const char* name, AutoThreadTaskRunner* joiner)
: startup_data_(nullptr),
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
com_init_type_(COM_INIT_NONE),
#endif
thread_(),
@@ -137,7 +137,7 @@
scoped_refptr<AutoThreadTaskRunner> AutoThread::StartWithType(
base::MessagePumpType type) {
DCHECK(thread_.is_null());
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
DCHECK(com_init_type_ != COM_INIT_STA || type == base::MessagePumpType::UI);
#endif
@@ -166,7 +166,7 @@
return startup_data.task_runner;
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
void AutoThread::SetComInitType(ComInitType com_init_type) {
DCHECK_EQ(com_init_type_, COM_INIT_NONE);
com_init_type_ = com_init_type;
@@ -213,14 +213,14 @@
// startup_data_ can't be touched anymore since the starting thread is now
// unlocked.
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
// Allow threads running a MessageLoopForIO to use FileDescriptorWatcher.
std::unique_ptr<base::FileDescriptorWatcher> file_descriptor_watcher;
if (single_thread_task_executor.type() == base::MessagePumpType::IO) {
file_descriptor_watcher = std::make_unique<base::FileDescriptorWatcher>(
single_thread_task_executor.task_runner());
}
-#elif defined(OS_WIN)
+#elif BUILDFLAG(IS_WIN)
// Initialize COM on the thread, if requested.
std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer(
CreateComInitializer(com_init_type_));
diff --git a/remoting/base/auto_thread.h b/remoting/base/auto_thread.h
index a5d4097..225a09cf 100644
--- a/remoting/base/auto_thread.h
+++ b/remoting/base/auto_thread.h
@@ -44,7 +44,7 @@
const char* name,
scoped_refptr<AutoThreadTaskRunner> joiner);
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// Create an AutoThread initialized for COM. |com_init_type| specifies the
// type of COM apartment to initialize.
enum ComInitType { COM_INIT_NONE, COM_INIT_STA, COM_INIT_MTA };
@@ -76,7 +76,7 @@
// thread will exit when no references to the TaskRunner remain.
scoped_refptr<AutoThreadTaskRunner> StartWithType(base::MessagePumpType type);
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// Configures the thread to initialize the specified COM apartment type.
// SetComInitType() must be called before Start().
void SetComInitType(ComInitType com_init_type);
@@ -95,7 +95,7 @@
struct StartupData;
raw_ptr<StartupData> startup_data_;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// Specifies which kind of COM apartment to initialize, if any.
ComInitType com_init_type_;
#endif
diff --git a/remoting/base/auto_thread_unittest.cc b/remoting/base/auto_thread_unittest.cc
index 5572811..f021f16 100644
--- a/remoting/base/auto_thread_unittest.cc
+++ b/remoting/base/auto_thread_unittest.cc
@@ -15,7 +15,7 @@
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include <objbase.h>
#endif
@@ -33,7 +33,7 @@
task_runner->PostTask(FROM_HERE, base::BindOnce(&SetFlagTask, success));
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
void CheckComAptTypeTask(APTTYPE* apt_type_out, HRESULT* hresult) {
typedef HRESULT (WINAPI * CoGetApartmentTypeFunc)
(APTTYPE*, APTTYPEQUALIFIER*);
@@ -136,7 +136,7 @@
EXPECT_TRUE(success);
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
TEST_F(AutoThreadTest, ThreadWithComMta) {
scoped_refptr<base::TaskRunner> task_runner =
AutoThread::CreateWithLoopAndComInitTypes(kThreadName, main_task_runner_,
@@ -178,6 +178,6 @@
// COM activity in this test process, so allow both types here.
EXPECT_TRUE(apt_type == APTTYPE_MAINSTA || apt_type == APTTYPE_STA);
}
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
} // namespace remoting
diff --git a/remoting/base/chromoting_event.cc b/remoting/base/chromoting_event.cc
index 98caa0e..57b518c3 100644
--- a/remoting/base/chromoting_event.cc
+++ b/remoting/base/chromoting_event.cc
@@ -7,6 +7,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringize_macros.h"
#include "base/system/sys_info.h"
+#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "remoting/base/name_value_map.h"
@@ -189,17 +190,17 @@
SetString(kCpuKey, base::SysInfo::OperatingSystemArchitecture());
SetString(kOsVersionKey, base::SysInfo::OperatingSystemVersion());
SetString(kWebAppVersionKey, STRINGIZE(VERSION));
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
Os os = Os::CHROMOTING_LINUX;
#elif BUILDFLAG(IS_CHROMEOS_ASH)
Os os = Os::CHROMOTING_CHROMEOS;
-#elif defined(OS_IOS)
+#elif BUILDFLAG(IS_IOS)
Os os = Os::CHROMOTING_IOS;
-#elif defined(OS_MAC)
+#elif BUILDFLAG(IS_MAC)
Os os = Os::CHROMOTING_MAC;
-#elif defined(OS_WIN)
+#elif BUILDFLAG(IS_WIN)
Os os = Os::CHROMOTING_WINDOWS;
-#elif defined(OS_ANDROID)
+#elif BUILDFLAG(IS_ANDROID)
Os os = Os::CHROMOTING_ANDROID;
#else
Os os = Os::OTHER;
diff --git a/remoting/base/host_settings.cc b/remoting/base/host_settings.cc
index d351d93..10e5046 100644
--- a/remoting/base/host_settings.cc
+++ b/remoting/base/host_settings.cc
@@ -7,11 +7,11 @@
#include "base/no_destructor.h"
#include "build/build_config.h"
-#if defined(OS_APPLE) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
+#if BUILDFLAG(IS_APPLE) || (BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS))
#include "remoting/base/file_host_settings.h"
-#endif // defined(OS_LINUX)
+#endif // BUILDFLAG(IS_LINUX)
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "remoting/base/host_settings_win.h"
#endif // defined (OS_WIN)
@@ -44,10 +44,10 @@
// static
HostSettings* HostSettings::GetInstance() {
-#if defined(OS_APPLE) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
+#if BUILDFLAG(IS_APPLE) || (BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS))
static base::NoDestructor<FileHostSettings> instance(
FileHostSettings::GetSettingsFilePath());
-#elif defined(OS_WIN)
+#elif BUILDFLAG(IS_WIN)
static base::NoDestructor<HostSettingsWin> instance;
#else
// HostSettings is currently neither implemented nor used on other platforms.
diff --git a/remoting/base/logging.h b/remoting/base/logging.h
index 7eccc56d..126ff57 100644
--- a/remoting/base/logging.h
+++ b/remoting/base/logging.h
@@ -8,7 +8,7 @@
#include "base/logging.h"
#include "build/build_config.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include <guiddef.h>
#endif
@@ -22,7 +22,7 @@
#define HOST_LOG LOG(INFO)
#define HOST_DLOG DLOG(INFO)
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// {2db51ca1-4fd8-4b88-b5a2-fb8606b66b02}
constexpr GUID kRemotingHostLogProviderGuid = {
0x2db51ca1,
diff --git a/remoting/base/url_request_context_getter.cc b/remoting/base/url_request_context_getter.cc
index 3033d54..c14aafa 100644
--- a/remoting/base/url_request_context_getter.cc
+++ b/remoting/base/url_request_context_getter.cc
@@ -15,10 +15,10 @@
#include "net/url_request/url_request_context_builder.h"
#include "remoting/base/vlog_net_log.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "base/win/windows_version.h"
#include "net/log/net_log.h"
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
namespace remoting {
@@ -35,7 +35,7 @@
net::URLRequestContextBuilder builder;
builder.DisableHttpCache();
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
if (base::win::GetVersion() <= base::win::Version::WIN7) {
// The network stack of Windows 7 and older systems has a bug such that
// proxy resolution always fails and blocks each request for ~10-30
@@ -46,7 +46,7 @@
std::move(proxy_config_service_), net::NetLog::Get());
builder.set_proxy_resolution_service(std::move(proxy_resolution_service));
}
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
if (proxy_config_service_) {
builder.set_proxy_config_service(std::move(proxy_config_service_));
diff --git a/remoting/base/user_settings.cc b/remoting/base/user_settings.cc
index 2ad37e9..705106dc 100644
--- a/remoting/base/user_settings.cc
+++ b/remoting/base/user_settings.cc
@@ -8,7 +8,7 @@
#include "base/notreached.h"
#include "build/build_config.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "remoting/base/user_settings_win.h"
#endif
@@ -19,7 +19,7 @@
UserSettings::~UserSettings() = default;
UserSettings* UserSettings::GetInstance() {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
static base::NoDestructor<UserSettingsWin> instance;
return instance.get();
#else
diff --git a/remoting/client/chromoting_client_runtime_unittest.cc b/remoting/client/chromoting_client_runtime_unittest.cc
index 2b4eea9..2d2ba04 100644
--- a/remoting/client/chromoting_client_runtime_unittest.cc
+++ b/remoting/client/chromoting_client_runtime_unittest.cc
@@ -2,14 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/run_loop.h"
-#include "remoting/base/auto_thread_task_runner.h"
#include "remoting/client/chromoting_client_runtime.h"
+
+#include "base/run_loop.h"
+#include "build/build_config.h"
+#include "remoting/base/auto_thread_task_runner.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace remoting {
-#if defined(OS_IOS) || defined(OS_ANDROID)
+#if BUILDFLAG(IS_IOS) || BUILDFLAG(IS_ANDROID)
// A simple test that starts and stop the runtime. This tests the runtime
// operates properly and all threads and message loops are valid.
diff --git a/remoting/client/client_telemetry_logger.cc b/remoting/client/client_telemetry_logger.cc
index 5d292ac2..265679aa 100644
--- a/remoting/client/client_telemetry_logger.cc
+++ b/remoting/client/client_telemetry_logger.cc
@@ -11,9 +11,10 @@
#include "base/logging.h"
#include "base/rand_util.h"
#include "base/strings/stringprintf.h"
+#include "build/build_config.h"
#include "remoting/base/telemetry_log_writer.h"
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
#include <android/log.h>
#endif // OS_ANDROID
@@ -114,7 +115,7 @@
void ClientTelemetryLogger::PrintLogStatistics(
const protocol::PerformanceTracker& perf_tracker) {
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
__android_log_print(
ANDROID_LOG_INFO, "stats",
#else
diff --git a/remoting/client/display/sys_opengl.h b/remoting/client/display/sys_opengl.h
index 0351fc8..96b9175 100644
--- a/remoting/client/display/sys_opengl.h
+++ b/remoting/client/display/sys_opengl.h
@@ -7,18 +7,18 @@
#include "build/build_config.h"
-#if defined(OS_IOS)
+#if BUILDFLAG(IS_IOS)
#include <OpenGLES/ES3/gl.h>
-#elif defined(OS_LINUX) || defined(OS_CHROMEOS)
+#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>
-#elif defined(OS_MAC)
+#elif BUILDFLAG(IS_MAC)
#define GL_GLEXT_PROTOTYPES
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#else
#include <GLES3/gl3.h>
-#endif // defined(OS_IOS)
+#endif // BUILDFLAG(IS_IOS)
#endif // REMOTING_CLIENT_DISPLAY_SYS_OPENGL_H_
diff --git a/remoting/client/notification/notification_client.cc b/remoting/client/notification/notification_client.cc
index 37a69cd..0b8f40e 100644
--- a/remoting/client/notification/notification_client.cc
+++ b/remoting/client/notification/notification_client.cc
@@ -21,7 +21,7 @@
#include "remoting/client/notification/version_range.h"
#include "ui/base/l10n/l10n_util.h"
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
#include "base/android/locale_utils.h"
#endif
@@ -29,9 +29,9 @@
namespace {
-#if defined(OS_IOS)
+#if BUILDFLAG(IS_IOS)
constexpr char kCurrentPlatform[] = "IOS";
-#elif defined(OS_ANDROID)
+#elif BUILDFLAG(IS_ANDROID)
constexpr char kCurrentPlatform[] = "ANDROID";
#else
constexpr char kCurrentPlatform[] = "UNKNOWN";
@@ -208,7 +208,7 @@
kCurrentPlatform,
kCurrentVersion,
base::SysInfo::OperatingSystemVersion(),
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
// GetApplicationLocale() returns empty string on Android since we
// don't pack any .pak file into the apk, so we need to get the locale
// string directly.
diff --git a/remoting/codec/webrtc_video_encoder_gpu.cc b/remoting/codec/webrtc_video_encoder_gpu.cc
index 0dde5cc..e6cc24e 100644
--- a/remoting/codec/webrtc_video_encoder_gpu.cc
+++ b/remoting/codec/webrtc_video_encoder_gpu.cc
@@ -31,7 +31,7 @@
#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "base/win/scoped_com_initializer.h"
#endif
@@ -51,7 +51,7 @@
gpu::GpuPreferences CreateGpuPreferences() {
gpu::GpuPreferences gpu_preferences;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
gpu_preferences.enable_media_foundation_vea_on_windows7 = true;
#endif
return gpu_preferences;
@@ -130,7 +130,7 @@
void RunAnyPendingEncode();
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// This object is required by Chromium to ensure proper init/uninit of COM on
// this thread. The guidance is to match the lifetime of this object to the
// lifetime of the thread if possible.
@@ -340,7 +340,7 @@
void WebrtcVideoEncoderGpu::Core::BeginInitialization() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
if (!scoped_com_initializer_) {
scoped_com_initializer_ =
std::make_unique<base::win::ScopedCOMInitializer>();
@@ -397,7 +397,7 @@
// static
bool WebrtcVideoEncoderGpu::IsSupportedByH264(
const WebrtcVideoEncoderSelector::Profile& profile) {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// This object is required by Chromium to ensure proper init/uninit of COM on
// this thread. The guidance is to match the lifetime of this object to the
// lifetime of the thread if possible. Since we are still experimenting with
diff --git a/remoting/codec/webrtc_video_encoder_vpx.cc b/remoting/codec/webrtc_video_encoder_vpx.cc
index d77b9087..9fc19d3 100644
--- a/remoting/codec/webrtc_video_encoder_vpx.cc
+++ b/remoting/codec/webrtc_video_encoder_vpx.cc
@@ -85,11 +85,11 @@
const webrtc::DesktopSize& size) {
SetCommonCodecParameters(config, size);
-#if defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS)
+#if BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS)
// On Linux, using too many threads for VP8 encoding has been linked to high
// CPU usage on machines that are under stress. See http://crbug.com/1151148.
config->g_threads = std::min(config->g_threads, 2U);
-#endif // defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS)
+#endif // BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS)
// Value of 2 means using the real time profile. This is basically a
// redundant option since we explicitly select real time mode when doing
diff --git a/remoting/host/base/switches.cc b/remoting/host/base/switches.cc
index ce9f987f..81a194b 100644
--- a/remoting/host/base/switches.cc
+++ b/remoting/host/base/switches.cc
@@ -23,13 +23,13 @@
const char kProcessTypeFileChooser[] = "file_chooser";
const char kProcessTypeUrlForwarderConfigurator[] =
"url_forwarder_configurator";
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
const char kProcessTypeXSessionChooser[] = "xsession_chooser";
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
const char kEvaluateCapabilitySwitchName[] = "evaluate-type";
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
const char kEvaluateD3D[] = "d3d-support";
const char kEvaluate3dDisplayMode[] = "3d-display-mode";
const char kSetUpUrlForwarderSwitchName[] = "setup";
@@ -42,7 +42,7 @@
const char kMojoPipeToken[] = "mojo-pipe-token";
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
const char kCheckPermissionSwitchName[] = "check-permission";
const char kCheckAccessibilityPermissionSwitchName[] =
"check-accessibility-permission";
diff --git a/remoting/host/base/switches.h b/remoting/host/base/switches.h
index 4769406..c5a2956 100644
--- a/remoting/host/base/switches.h
+++ b/remoting/host/base/switches.h
@@ -35,14 +35,14 @@
extern const char kProcessTypeEvaluateCapability[];
extern const char kProcessTypeFileChooser[];
extern const char kProcessTypeUrlForwarderConfigurator[];
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
extern const char kProcessTypeXSessionChooser[];
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
extern const char kEvaluateCapabilitySwitchName[];
// Values for kEvaluateCapabilitySwitchName.
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// Executes EvaluateD3D() function.
extern const char kEvaluateD3D[];
// Executes Evaluate3dDisplayMode() function.
@@ -65,7 +65,7 @@
// processes.
extern const char kMojoPipeToken[];
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
// NativeMessagingHost switch to check for required OS permissions and request
// them if necessary.
extern const char kCheckPermissionSwitchName[];
diff --git a/remoting/host/base/username.cc b/remoting/host/base/username.cc
index 73766dde..62c2f58 100644
--- a/remoting/host/base/username.cc
+++ b/remoting/host/base/username.cc
@@ -9,16 +9,16 @@
#include "base/notreached.h"
#include "build/build_config.h"
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
#include <pwd.h>
#include <sys/types.h>
#include <unistd.h>
-#endif // defined(OS_POSIX)
+#endif // BUILDFLAG(IS_POSIX)
namespace remoting {
std::string GetUsername() {
-#if defined(OS_POSIX) && !defined(OS_ANDROID)
+#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID)
long buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
if (buf_size <= 0)
return std::string();
@@ -31,7 +31,7 @@
#else
NOTIMPLEMENTED();
return std::string();
-#endif // defined(OS_POSIX) && !defined(OS_ANDROID)
+#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID)
}
} // namespace remoting
diff --git a/remoting/host/basic_desktop_environment.cc b/remoting/host/basic_desktop_environment.cc
index f6ca2f2..aaa3e1c 100644
--- a/remoting/host/basic_desktop_environment.cc
+++ b/remoting/host/basic_desktop_environment.cc
@@ -25,7 +25,7 @@
#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
#include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "remoting/host/win/evaluate_d3d.h"
#endif
@@ -135,7 +135,7 @@
std::unique_ptr<DesktopAndCursorConditionalComposer>
BasicDesktopEnvironment::CreateComposingVideoCapturer() {
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
// Mac includes the mouse cursor in the captured image in curtain mode.
if (options_.enable_curtaining())
return nullptr;
@@ -176,7 +176,7 @@
watchdog.Arm();
desktop_capture_options().x_display()->IgnoreXServerGrabs();
watchdog.Disarm();
-#elif defined(OS_WIN)
+#elif BUILDFLAG(IS_WIN)
options_.desktop_capture_options()->set_allow_directx_capturer(
IsD3DAvailable());
#endif
diff --git a/remoting/host/branding.cc b/remoting/host/branding.cc
index df7eee6a..ade20f7 100644
--- a/remoting/host/branding.cc
+++ b/remoting/host/branding.cc
@@ -15,7 +15,7 @@
// The actual location of the files is ultimately determined by the service
// daemon and native messaging host - these defaults are only used in case the
// command-line switches are absent.
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#ifdef OFFICIAL_BUILD
const base::FilePath::CharType kConfigDir[] =
FILE_PATH_LITERAL("Google\\Chrome Remote Desktop");
@@ -23,7 +23,7 @@
const base::FilePath::CharType kConfigDir[] =
FILE_PATH_LITERAL("Chromoting");
#endif
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
const base::FilePath::CharType kConfigDir[] =
FILE_PATH_LITERAL("Chrome Remote Desktop");
#else
@@ -35,16 +35,16 @@
namespace remoting {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
const wchar_t kWindowsServiceName[] = L"chromoting";
#endif
base::FilePath GetConfigDir() {
base::FilePath app_data_dir;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
base::PathService::Get(base::DIR_COMMON_APP_DATA, &app_data_dir);
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
base::PathService::Get(base::DIR_APP_DATA, &app_data_dir);
#else
base::PathService::Get(base::DIR_HOME, &app_data_dir);
diff --git a/remoting/host/branding.h b/remoting/host/branding.h
index 575f3fb..1452803 100644
--- a/remoting/host/branding.h
+++ b/remoting/host/branding.h
@@ -10,7 +10,7 @@
namespace remoting {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// Windows chromoting service name.
extern const wchar_t kWindowsServiceName[];
#endif
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index 5bf16f8..c7021c5 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -31,7 +31,7 @@
#include "remoting/protocol/transport_context.h"
#include "remoting/protocol/webrtc_connection_to_client.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
@@ -124,7 +124,7 @@
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!ipc_server_);
-#if defined(OS_LINUX) || defined(OS_WIN)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN)
ipc_server_ = std::make_unique<MojoIpcServer<mojom::ChromotingHostServices>>(
GetChromotingHostServicesServerName(), this);
ipc_server_->StartServer();
@@ -244,7 +244,7 @@
<< "No connected remote desktop client was found.";
return;
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
DWORD peer_session_id;
if (!ProcessIdToSessionId(ipc_server_->current_peer_pid(),
&peer_session_id)) {
diff --git a/remoting/host/chromoting_host_context.cc b/remoting/host/chromoting_host_context.cc
index 5270294..b2a1684 100644
--- a/remoting/host/chromoting_host_context.cc
+++ b/remoting/host/chromoting_host_context.cc
@@ -117,18 +117,18 @@
std::unique_ptr<ChromotingHostContext> ChromotingHostContext::Create(
scoped_refptr<AutoThreadTaskRunner> ui_task_runner) {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// On Windows the AudioCapturer requires COM, so we run a single-threaded
// apartment, which requires a UI thread.
scoped_refptr<AutoThreadTaskRunner> audio_task_runner =
AutoThread::CreateWithLoopAndComInitTypes(
"ChromotingAudioThread", ui_task_runner, base::MessagePumpType::UI,
AutoThread::COM_INIT_STA);
-#else // !defined(OS_WIN)
+#else // !BUILDFLAG(IS_WIN)
scoped_refptr<AutoThreadTaskRunner> audio_task_runner =
AutoThread::CreateWithType("ChromotingAudioThread", ui_task_runner,
base::MessagePumpType::IO);
-#endif // !defined(OS_WIN)
+#endif // !BUILDFLAG(IS_WIN)
scoped_refptr<AutoThreadTaskRunner> file_task_runner =
AutoThread::CreateWithType("ChromotingFileThread", ui_task_runner,
base::MessagePumpType::IO);
@@ -143,16 +143,16 @@
// on a UI thread.
scoped_refptr<AutoThreadTaskRunner> input_task_runner =
AutoThread::CreateWithType("ChromotingInputThread", ui_task_runner,
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
base::MessagePumpType::UI);
#else
base::MessagePumpType::IO);
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
return base::WrapUnique(new ChromotingHostContext(
ui_task_runner, audio_task_runner, file_task_runner, input_task_runner,
network_task_runner,
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
// Mac requires a UI thread for the capturer.
AutoThread::CreateWithType("ChromotingCaptureThread", ui_task_runner,
base::MessagePumpType::UI),
diff --git a/remoting/host/chromoting_host_services_client.cc b/remoting/host/chromoting_host_services_client.cc
index 35a0f5d..33c5db9 100644
--- a/remoting/host/chromoting_host_services_client.cc
+++ b/remoting/host/chromoting_host_services_client.cc
@@ -14,7 +14,7 @@
#include "remoting/host/ipc_constants.h"
#include "remoting/host/mojom/chromoting_host_services.mojom.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include <windows.h>
#include "remoting/host/win/acl_util.h"
@@ -24,7 +24,7 @@
namespace {
-#if defined(OS_LINUX)
+#if BUILDFLAG(IS_LINUX)
constexpr char kChromeRemoteDesktopSessionEnvVar[] =
"CHROME_REMOTE_DESKTOP_SESSION";
#endif
@@ -47,7 +47,7 @@
// static
bool ChromotingHostServicesClient::Initialize() {
DCHECK(!g_initialized);
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// The ChromotingHostServices server runs under the LocalService account,
// which normally isn't allowed to query process info like session ID of a
// process running under a different account, so we add an ACL to allow it.
@@ -104,7 +104,7 @@
if (session_services_remote_.is_bound()) {
return true;
}
-#if defined(OS_LINUX)
+#if BUILDFLAG(IS_LINUX)
if (!environment_->HasVar(kChromeRemoteDesktopSessionEnvVar)) {
LOG(WARNING) << "Current desktop environment is not remotable.";
return false;
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc
index 50fb575c..3fbcce09 100644
--- a/remoting/host/client_session.cc
+++ b/remoting/host/client_session.cc
@@ -88,11 +88,11 @@
extension_manager_ =
std::make_unique<HostExtensionSessionManager>(extensions, this);
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// LocalInputMonitorWin filters out an echo of the injected input before it
// reaches |remote_input_filter_|.
remote_input_filter_.SetExpectLocalEcho(false);
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
}
ClientSession::~ClientSession() {
@@ -702,7 +702,7 @@
break;
case protocol::SessionConfig::Protocol::WEBRTC: {
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
mouse_clamping_filter_.set_input_size(size.WidthAsPixels(),
size.HeightAsPixels());
#else
@@ -711,7 +711,7 @@
// TODO(sergeyu): Fix InputInjector implementations to use DIPs as well.
mouse_clamping_filter_.set_input_size(size.WidthAsDips(),
size.HeightAsDips());
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
}
}
}
@@ -826,7 +826,7 @@
// display configuration supports capturing the entire desktop.
LOG(INFO) << " Webrtc desktop size " << default_webrtc_desktop_size_;
if (show_display_id_ == webrtc::kInvalidScreenId) {
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
// On MacOS, there are situations where webrtc cannot capture the entire
// desktop (e.g, when there are displays with different DPIs). We detect
// this situation by comparing the full desktop size (calculated above
@@ -844,7 +844,7 @@
#else
// Windows/Linux can capture full desktop if multiple displays.
can_capture_full_desktop_ = true;
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
}
// Generate and send VideoLayout message.
diff --git a/remoting/host/client_session_unittest.cc b/remoting/host/client_session_unittest.cc
index 8849222..0330e87 100644
--- a/remoting/host/client_session_unittest.cc
+++ b/remoting/host/client_session_unittest.cc
@@ -600,11 +600,11 @@
connection_->input_stub()->InjectMouseEvent(MakeMouseMoveEvent(100, 101));
-#if !defined(OS_WIN)
+#if !BUILDFLAG(IS_WIN)
// The OS echoes the injected event back.
client_session_->OnLocalPointerMoved(webrtc::DesktopVector(100, 101),
ui::ET_MOUSE_MOVED);
-#endif // !defined(OS_WIN)
+#endif // !BUILDFLAG(IS_WIN)
// This one should get throught as well.
connection_->input_stub()->InjectMouseEvent(MakeMouseMoveEvent(200, 201));
diff --git a/remoting/host/config_file_watcher.cc b/remoting/host/config_file_watcher.cc
index 20c94ea95..2dbe53c 100644
--- a/remoting/host/config_file_watcher.cc
+++ b/remoting/host/config_file_watcher.cc
@@ -27,11 +27,11 @@
const base::FilePath::CharType kDefaultHostConfigFile[] =
FILE_PATH_LITERAL("host.json");
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// Maximum number of times to try reading the configuration file before
// reporting an error.
const int kMaxRetries = 3;
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
class ConfigFileWatcherImpl
: public base::RefCountedThreadSafe<ConfigFileWatcherImpl> {
@@ -203,7 +203,7 @@
std::string config;
if (!base::ReadFileToString(config_path_, &config)) {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// EACCESS may indicate a locking or sharing violation. Retry a few times
// before reporting an error.
if (errno == EACCES && retries_ < kMaxRetries) {
@@ -213,7 +213,7 @@
config_updated_timer_->Reset();
return;
}
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
PLOG(ERROR) << "Failed to read '" << config_path_.value() << "'";
diff --git a/remoting/host/desktop_display_info.cc b/remoting/host/desktop_display_info.cc
index 2f624cd..6728557 100644
--- a/remoting/host/desktop_display_info.cc
+++ b/remoting/host/desktop_display_info.cc
@@ -99,14 +99,14 @@
unsigned int disp_index = disp_id;
if (full_desktop) {
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
// For Mac, we need to calculate the offset relative to the default
// display.
disp_index = 0;
#else
// For other platforms, the origin for full desktop is 0,0.
return webrtc::DesktopVector();
-#endif // !defined(OS_APPLE)
+#endif // !BUILDFLAG(IS_APPLE)
}
if (displays_.size() == 0) {
@@ -132,7 +132,7 @@
}
webrtc::DesktopVector topleft(dx, dy);
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
// Mac display offsets need to be relative to the main display's origin.
if (full_desktop) {
// For full desktop, this is the offset to the topleft display coord.
@@ -145,7 +145,7 @@
#else
// Return offset to this screen, relative to topleft.
return origin.subtract(topleft);
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
}
void DesktopDisplayInfo::AddDisplay(const DisplayGeometry& display) {
diff --git a/remoting/host/desktop_display_info_unittest.cc b/remoting/host/desktop_display_info_unittest.cc
index b01d893..f9acc37 100644
--- a/remoting/host/desktop_display_info_unittest.cc
+++ b/remoting/host/desktop_display_info_unittest.cc
@@ -82,13 +82,13 @@
AddDisplay(0, 0, 500, 400);
AddDisplay(-300, 0, 300, 200);
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
VerifyDisplayOffset(FROM_HERE, 0, 0, 0);
VerifyDisplayOffset(FROM_HERE, 1, -300, 0);
#else
VerifyDisplayOffset(FROM_HERE, 0, 300, 0);
VerifyDisplayOffset(FROM_HERE, 1, 0, 0);
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
}
// +---------o------------+
@@ -100,13 +100,13 @@
AddDisplay(-300, 0, 300, 200);
AddDisplay(0, 0, 500, 400);
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
VerifyDisplayOffset(FROM_HERE, 0, -300, 0);
VerifyDisplayOffset(FROM_HERE, 1, 0, 0);
#else
VerifyDisplayOffset(FROM_HERE, 0, 0, 0);
VerifyDisplayOffset(FROM_HERE, 1, 300, 0);
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
}
// +---------o------------+
@@ -119,7 +119,7 @@
AddDisplay(0, 0, 500, 400); // Default display.
AddDisplay(500, 50, 400, 350);
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
VerifyDisplayOffset(FROM_HERE, 0, -300, 0);
VerifyDisplayOffset(FROM_HERE, 1, 0, 0);
VerifyDisplayOffset(FROM_HERE, 2, 500, 50);
@@ -127,7 +127,7 @@
VerifyDisplayOffset(FROM_HERE, 0, 0, 0);
VerifyDisplayOffset(FROM_HERE, 1, 300, 0);
VerifyDisplayOffset(FROM_HERE, 2, 800, 50);
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
}
// x o-----------+ - 0
@@ -144,7 +144,7 @@
AddDisplay(300, 400, 600, 450);
AddDisplay(-300, 350, 300, 200);
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
VerifyDisplayOffset(FROM_HERE, 0, 0, 0);
VerifyDisplayOffset(FROM_HERE, 1, 300, 400);
VerifyDisplayOffset(FROM_HERE, 2, -300, 350);
@@ -152,7 +152,7 @@
VerifyDisplayOffset(FROM_HERE, 0, 300, 0);
VerifyDisplayOffset(FROM_HERE, 1, 600, 400);
VerifyDisplayOffset(FROM_HERE, 2, 0, 350);
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
}
// x +-------+ -- -50
@@ -181,7 +181,7 @@
AddDisplay(70, 100, 65, 20);
AddDisplay(0, 0, 80, 55); // Default display.
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
// Relative to display 6.
VerifyDisplayOffset(FROM_HERE, 0, 80, -10);
VerifyDisplayOffset(FROM_HERE, 1, 60, -50);
@@ -198,7 +198,7 @@
VerifyDisplayOffset(FROM_HERE, 4, 30, 30);
VerifyDisplayOffset(FROM_HERE, 5, 140, 150);
VerifyDisplayOffset(FROM_HERE, 6, 70, 50);
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
}
} // namespace remoting
diff --git a/remoting/host/desktop_process.cc b/remoting/host/desktop_process.cc
index 608f44e..d779a22 100644
--- a/remoting/host/desktop_process.cc
+++ b/remoting/host/desktop_process.cc
@@ -24,9 +24,9 @@
#include "remoting/host/desktop_environment.h"
#include "remoting/host/desktop_session_agent.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "base/win/windows_version.h"
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
namespace remoting {
@@ -76,7 +76,7 @@
void DesktopProcess::LockWorkstation() {
DCHECK(caller_task_runner_->BelongsToCurrentThread());
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
if (base::win::OSInfo::GetInstance()->version_type() ==
base::win::VersionType::SUITE_HOME) {
return;
@@ -87,7 +87,7 @@
}
#else
NOTREACHED();
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
}
bool DesktopProcess::OnMessageReceived(const IPC::Message& message) {
@@ -134,16 +134,16 @@
// Launch the audio capturing thread.
scoped_refptr<AutoThreadTaskRunner> audio_task_runner;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// On Windows the AudioCapturer requires COM, so we run a single-threaded
// apartment, which requires a UI thread.
audio_task_runner = AutoThread::CreateWithLoopAndComInitTypes(
"ChromotingAudioThread", caller_task_runner_, base::MessagePumpType::UI,
AutoThread::COM_INIT_STA);
-#else // !defined(OS_WIN)
+#else // !BUILDFLAG(IS_WIN)
audio_task_runner = AutoThread::CreateWithType(
"ChromotingAudioThread", caller_task_runner_, base::MessagePumpType::IO);
-#endif // !defined(OS_WIN)
+#endif // !BUILDFLAG(IS_WIN)
// Create a desktop agent.
desktop_agent_ =
diff --git a/remoting/host/desktop_process_main.cc b/remoting/host/desktop_process_main.cc
index 4c93ecd..138fce7 100644
--- a/remoting/host/desktop_process_main.cc
+++ b/remoting/host/desktop_process_main.cc
@@ -76,7 +76,7 @@
// Create a platform-dependent environment factory.
std::unique_ptr<DesktopEnvironmentFactory> desktop_environment_factory;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// base::Unretained() is safe here: |desktop_process| outlives run_loop.Run().
auto inject_sas_closure = base::BindRepeating(
&DesktopProcess::InjectSas, base::Unretained(&desktop_process));
@@ -87,11 +87,11 @@
std::make_unique<SessionDesktopEnvironmentFactory>(
ui_task_runner, video_capture_task_runner, input_task_runner,
ui_task_runner, inject_sas_closure, lock_workstation_closure);
-#else // !defined(OS_WIN)
+#else // !BUILDFLAG(IS_WIN)
desktop_environment_factory.reset(new Me2MeDesktopEnvironmentFactory(
ui_task_runner, video_capture_task_runner, input_task_runner,
ui_task_runner));
-#endif // !defined(OS_WIN)
+#endif // !BUILDFLAG(IS_WIN)
if (!desktop_process.Start(std::move(desktop_environment_factory)))
return kInitializationFailed;
@@ -105,8 +105,8 @@
} // namespace remoting
-#if !defined(OS_WIN)
+#if !BUILDFLAG(IS_WIN)
int main(int argc, char** argv) {
return remoting::HostMain(argc, argv);
}
-#endif // !defined(OS_WIN)
+#endif // !BUILDFLAG(IS_WIN)
diff --git a/remoting/host/desktop_session_agent.cc b/remoting/host/desktop_session_agent.cc
index 067fad0..85e7327 100644
--- a/remoting/host/desktop_session_agent.cc
+++ b/remoting/host/desktop_session_agent.cc
@@ -49,7 +49,7 @@
#include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h"
#include "third_party/webrtc/modules/desktop_capture/shared_memory.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include <windows.h>
#include "base/memory/writable_shared_memory_region.h"
@@ -67,7 +67,7 @@
static std::unique_ptr<SharedMemoryImpl>
Create(size_t size, int id, base::OnceClosure on_deleted_callback) {
webrtc::SharedMemory::Handle handle = webrtc::SharedMemory::kInvalidHandle;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// webrtc::ScreenCapturer uses webrtc::SharedMemory::handle() only on
// windows. This handle must be writable. A WritableSharedMemoryRegion is
// created, and then it is converted to read-only. On the windows platform,
@@ -119,7 +119,7 @@
base::OnceClosure on_deleted_callback)
: SharedMemory(mapping.memory(), mapping.size(), handle, id),
on_deleted_callback_(std::move(on_deleted_callback))
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
,
writable_handle_(handle)
#endif
@@ -131,7 +131,7 @@
base::OnceClosure on_deleted_callback_;
base::ReadOnlySharedMemoryRegion region_;
base::WritableSharedMemoryMapping mapping_;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// Owns the handle passed to the base class which is used by
// webrtc::ScreenCapturer.
base::win::ScopedHandle writable_handle_;
@@ -410,11 +410,11 @@
remote_input_filter_ =
std::make_unique<RemoteInputFilter>(input_tracker_.get());
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// LocalInputMonitorWin filters out an echo of the injected input before it
// reaches |remote_input_filter_|.
remote_input_filter_->SetExpectLocalEcho(false);
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
// Start the input injector.
std::unique_ptr<protocol::ClipboardStub> clipboard_stub(
diff --git a/remoting/host/desktop_session_proxy.cc b/remoting/host/desktop_session_proxy.cc
index 5bbfde6..43534a44 100644
--- a/remoting/host/desktop_session_proxy.cc
+++ b/remoting/host/desktop_session_proxy.cc
@@ -43,9 +43,9 @@
#include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h"
#include "third_party/webrtc/modules/desktop_capture/shared_memory.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "base/win/scoped_handle.h"
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
namespace remoting {
diff --git a/remoting/host/evaluate_capability.cc b/remoting/host/evaluate_capability.cc
index 3fd9edd..34a29e5 100644
--- a/remoting/host/evaluate_capability.cc
+++ b/remoting/host/evaluate_capability.cc
@@ -20,7 +20,7 @@
#include "remoting/host/base/switches.h"
#include "remoting/host/ipc_constants.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "remoting/host/win/evaluate_3d_display_mode.h"
#include "remoting/host/win/evaluate_d3d.h"
#endif
@@ -45,7 +45,7 @@
base::FilePath directory;
result = base::PathService::Get(base::DIR_EXE, &directory);
DCHECK(result);
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
if (path.BaseName().value() == FILE_PATH_LITERAL("remoting_unittests.exe")) {
return directory.Append(FILE_PATH_LITERAL("capability_test_stub.exe"));
}
@@ -55,7 +55,7 @@
}
#endif
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
if (path.BaseName().value() ==
FILE_PATH_LITERAL("chrome-remote-desktop-host")) {
return path;
@@ -65,14 +65,14 @@
}
return directory.Append(FILE_PATH_LITERAL("remoting_me2me_host"));
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
if (path.BaseName().value() == FILE_PATH_LITERAL("remoting_me2me_host")) {
return path;
}
return directory.Append(FILE_PATH_LITERAL(
"remoting_me2me_host.app/Contents/MacOS/remoting_me2me_host"));
-#elif defined(OS_WIN)
+#elif BUILDFLAG(IS_WIN)
if (path.BaseName().value() == FILE_PATH_LITERAL("remoting_console.exe")) {
return path;
}
@@ -92,7 +92,7 @@
} // namespace
int EvaluateCapabilityLocally(const std::string& type) {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
if (type == kEvaluateD3D) {
return EvaluateD3D();
}
@@ -120,7 +120,7 @@
// TODO(crbug.com/1144161): Do not perform blocking operations on the IO
// thread.
ScopedBypassIOThreadRestrictions bypass;
-#if DCHECK_IS_ON() && !defined(OS_WIN)
+#if DCHECK_IS_ON() && !BUILDFLAG(IS_WIN)
const bool result =
#endif
base::GetAppOutputWithExitCode(command, output, &exit_code);
@@ -128,7 +128,7 @@
// On Windows, base::GetAppOutputWithExitCode() usually returns false when
// receiving "unknown" exit code. See
// https://cs.chromium.org/chromium/src/base/process/launch_win.cc?rcl=39ec40095376e8d977decbdc5d7ca28ba7d39cf2&l=130
-#if DCHECK_IS_ON() && !defined(OS_WIN)
+#if DCHECK_IS_ON() && !BUILDFLAG(IS_WIN)
DCHECK(result) << "Failed to execute process "
<< command.GetCommandLineString() << ", exit code "
<< exit_code;
diff --git a/remoting/host/file_transfer/local_file_operations.cc b/remoting/host/file_transfer/local_file_operations.cc
index 8c1b613..51bb90e4 100644
--- a/remoting/host/file_transfer/local_file_operations.cc
+++ b/remoting/host/file_transfer/local_file_operations.cc
@@ -45,7 +45,7 @@
}
scoped_refptr<base::SequencedTaskRunner> CreateFileTaskRunner() {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// On Windows, we use user impersonation to write files as the currently
// logged-in user, while the process as a whole runs as SYSTEM. Since user
// impersonation is per-thread on Windows, we need a dedicated thread to
diff --git a/remoting/host/heartbeat_sender.cc b/remoting/host/heartbeat_sender.cc
index 55239969..5f3b67df 100644
--- a/remoting/host/heartbeat_sender.cc
+++ b/remoting/host/heartbeat_sender.cc
@@ -33,7 +33,7 @@
#include "remoting/signaling/signaling_address.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "base/strings/utf_string_conversions.h"
// Needed for GetComputerNameExW/ComputerNameDnsFullyQualified.
@@ -111,9 +111,9 @@
std::string GetHostname() {
// TODO(crbug.com/1052397): Revisit the macro expression once build flag
// switch of lacros-chrome is complete.
-#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
return net::GetHostName();
-#elif defined(OS_WIN)
+#elif BUILDFLAG(IS_WIN)
wchar_t buffer[MAX_PATH] = {0};
DWORD size = MAX_PATH;
if (!::GetComputerNameExW(ComputerNameDnsFullyQualified, buffer, &size)) {
diff --git a/remoting/host/heartbeat_sender_unittest.cc b/remoting/host/heartbeat_sender_unittest.cc
index 43b2546..a5c5ce9a 100644
--- a/remoting/host/heartbeat_sender_unittest.cc
+++ b/remoting/host/heartbeat_sender_unittest.cc
@@ -75,7 +75,7 @@
// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
// of lacros-chrome is complete.
-#if defined(OS_WIN) || defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
+#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
ASSERT_EQ(is_googler, request->has_hostname());
#else
ASSERT_FALSE(request->has_hostname());
diff --git a/remoting/host/host_attributes.cc b/remoting/host/host_attributes.cc
index 9bd6cff6..a54f32b1 100644
--- a/remoting/host/host_attributes.cc
+++ b/remoting/host/host_attributes.cc
@@ -16,7 +16,7 @@
#include "build/branding_buildflags.h"
#include "build/build_config.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "base/win/windows_version.h"
#include "media/base/win/mf_initializer.h"
#include "media/gpu/windows/media_foundation_video_encode_accelerator_win.h"
@@ -99,7 +99,7 @@
result.push_back(attribute.name);
}
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
{
GetD3DCapabilities(&result);
@@ -122,7 +122,7 @@
media::InitializeMediaFoundation()) {
result.push_back("HWEncoder");
}
-#elif defined(OS_LINUX) || defined(OS_CHROMEOS)
+#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
result.push_back("HWEncoder");
#endif
diff --git a/remoting/host/host_details.cc b/remoting/host/host_details.cc
index 9e9cdff..3290e44 100644
--- a/remoting/host/host_details.cc
+++ b/remoting/host/host_details.cc
@@ -8,7 +8,7 @@
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include "base/linux_util.h"
#endif
@@ -17,15 +17,15 @@
// Get the host Operating System Name, removing the need to check for OS
// definitions and keeps the keys used consistent.
std::string GetHostOperatingSystemName() {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
return "Windows";
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
return "Mac";
#elif BUILDFLAG(IS_CHROMEOS_ASH)
return "ChromeOS";
-#elif defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
+#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
return "Linux";
-#elif defined(OS_ANDROID)
+#elif BUILDFLAG(IS_ANDROID)
return "Android";
#else
#error "Unsupported host OS"
@@ -35,7 +35,7 @@
// Get the host Operating System Version, removing the need to check for OS
// definitions and keeps the format used consistent.
std::string GetHostOperatingSystemVersion() {
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
return base::GetLinuxDistro();
#else
return base::SysInfo::OperatingSystemVersion();
diff --git a/remoting/host/host_main.cc b/remoting/host/host_main.cc
index 6deec87..d8ca9ec 100644
--- a/remoting/host/host_main.cc
+++ b/remoting/host/host_main.cc
@@ -28,31 +28,31 @@
#include "remoting/host/setup/me2me_native_messaging_host.h"
#include "remoting/host/usage_stats_consent.h"
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
#include "base/mac/scoped_nsautorelease_pool.h"
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include <windows.h>
#include <commctrl.h>
#include <shellapi.h>
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
namespace remoting {
// Known entry points.
int HostProcessMain();
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
int DaemonProcessMain();
int DesktopProcessMain();
int FileChooserMain();
int RdpDesktopSessionMain();
int UrlForwarderConfiguratorMain();
-#endif // defined(OS_WIN)
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_WIN)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
int XSessionChooserMain();
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
namespace {
@@ -63,15 +63,15 @@
"\n"
"Options:\n"
-#if defined(OS_LINUX)
+#if BUILDFLAG(IS_LINUX)
" --audio-pipe-name=<pipe> - Sets the pipe name to capture audio on "
"Linux.\n"
-#endif // defined(OS_LINUX)
+#endif // BUILDFLAG(IS_LINUX)
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
" --list-audio-devices - List all audio devices and their device "
"UID.\n"
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
" --console - Runs the daemon interactively.\n"
" --elevate=<binary> - Runs <binary> elevated.\n"
@@ -85,7 +85,7 @@
printf(kUsageMessage, program_name.MaybeAsASCII().c_str());
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// Runs the binary specified by the command line, elevated.
int RunElevated() {
@@ -132,7 +132,7 @@
return kSuccessExitCode;
}
-#endif // !defined(OS_WIN)
+#endif // !BUILDFLAG(IS_WIN)
// Select the entry point corresponding to the process type.
MainRoutineFn SelectMainRoutine(const std::string& process_type) {
@@ -140,7 +140,7 @@
if (process_type == kProcessTypeHost) {
main_routine = &HostProcessMain;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
} else if (process_type == kProcessTypeDaemon) {
main_routine = &DaemonProcessMain;
} else if (process_type == kProcessTypeDesktop) {
@@ -151,11 +151,11 @@
main_routine = &RdpDesktopSessionMain;
} else if (process_type == kProcessTypeUrlForwarderConfigurator) {
main_routine = &UrlForwarderConfiguratorMain;
-#endif // defined(OS_WIN)
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_WIN)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
} else if (process_type == kProcessTypeXSessionChooser) {
main_routine = &XSessionChooserMain;
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
}
return main_routine;
@@ -164,7 +164,7 @@
} // namespace
int HostMain(int argc, char** argv) {
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
// Needed so we don't leak objects when threads are created.
base::mac::ScopedNSAutoreleasePool pool;
#endif
@@ -185,11 +185,11 @@
return kSuccessExitCode;
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
if (command_line->HasSwitch(kElevateSwitchName)) {
return RunElevated();
}
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
// Assume the host process by default.
std::string process_type = kProcessTypeHost;
@@ -222,13 +222,13 @@
}
#endif // defined(REMOTING_ENABLE_BREAKPAD)
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// Register and initialize common controls.
INITCOMMONCONTROLSEX info;
info.dwSize = sizeof(info);
info.dwICC = ICC_STANDARD_CLASSES;
InitCommonControlsEx(&info);
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
MainRoutineFn main_routine = SelectMainRoutine(process_type);
if (!main_routine) {
diff --git a/remoting/host/input_monitor/local_input_monitor_unittest.cc b/remoting/host/input_monitor/local_input_monitor_unittest.cc
index 1ae9ffe..db00b5d 100644
--- a/remoting/host/input_monitor/local_input_monitor_unittest.cc
+++ b/remoting/host/input_monitor/local_input_monitor_unittest.cc
@@ -34,12 +34,12 @@
void SetUp() override;
base::test::TaskEnvironment task_environment_ {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
base::test::TaskEnvironment::MainThreadType::UI
-#else // !defined(OS_WIN)
+#else // !BUILDFLAG(IS_WIN)
// Required to watch a file descriptor from NativeMessageProcessHost.
base::test::TaskEnvironment::MainThreadType::IO
-#endif // !defined(OS_WIN)
+#endif // !BUILDFLAG(IS_WIN)
};
base::RunLoop run_loop_;
diff --git a/remoting/host/ipc_constants.cc b/remoting/host/ipc_constants.cc
index 634afea..ffffae9b 100644
--- a/remoting/host/ipc_constants.cc
+++ b/remoting/host/ipc_constants.cc
@@ -16,7 +16,7 @@
namespace {
-#if !defined(NDEBUG) && defined(OS_LINUX)
+#if !defined(NDEBUG) && BUILDFLAG(IS_LINUX)
// Use a different IPC name for Linux debug builds so that we can run the host
// directly from out/Debug without interfering with the production host that
// might also be running.
@@ -45,9 +45,9 @@
base::FilePath path = dir_path.Append(binary);
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
path = path.ReplaceExtension(FILE_PATH_LITERAL("exe"));
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
*full_path = path;
return true;
diff --git a/remoting/host/it2me/it2me_host_unittest.cc b/remoting/host/it2me/it2me_host_unittest.cc
index cf10a8e6..a8a395b 100644
--- a/remoting/host/it2me/it2me_host_unittest.cc
+++ b/remoting/host/it2me/it2me_host_unittest.cc
@@ -34,9 +34,9 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include "base/linux_util.h"
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
namespace remoting {
@@ -232,7 +232,7 @@
It2MeHostTest::~It2MeHostTest() = default;
void It2MeHostTest::SetUp() {
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// Need to prime the host OS version value for linux to prevent IO on the
// network thread. base::GetLinuxDistro() caches the result.
base::GetLinuxDistro();
diff --git a/remoting/host/it2me/it2me_native_messaging_host.cc b/remoting/host/it2me/it2me_native_messaging_host.cc
index 6ceaa053..3a7b620 100644
--- a/remoting/host/it2me/it2me_native_messaging_host.cc
+++ b/remoting/host/it2me/it2me_native_messaging_host.cc
@@ -43,12 +43,12 @@
#include "remoting/signaling/xmpp_log_to_server.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "remoting/host/win/elevated_native_messaging_host.h"
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
namespace remoting {
@@ -56,12 +56,12 @@
namespace {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
const base::FilePath::CharType kBaseHostBinaryName[] =
FILE_PATH_LITERAL("remote_assistance_host.exe");
const base::FilePath::CharType kElevatedHostBinaryName[] =
FILE_PATH_LITERAL("remote_assistance_host_uiaccess.exe");
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
constexpr char kAnonymousUserName[] = "anonymous_user";
@@ -204,7 +204,7 @@
return;
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// Requests that the support host is launched with UiAccess on Windows.
// This value, in conjuction with the platform policy, is used to determine
// if an elevated host should be used.
@@ -562,7 +562,7 @@
absl::optional<bool>
It2MeNativeMessagingHost::GetAllowElevatedHostPolicyValue() {
DCHECK(policy_received_);
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
std::unique_ptr<base::DictionaryValue> platform_policies =
policy_watcher_->GetPlatformPolicies();
if (platform_policies) {
@@ -575,7 +575,7 @@
return value;
}
}
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
return absl::nullopt;
}
@@ -641,7 +641,7 @@
return auth_service_with_token.substr(strlen(kOAuth2ServicePrefix));
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
bool It2MeNativeMessagingHost::DelegateToElevatedHost(
std::unique_ptr<base::DictionaryValue> message) {
@@ -672,7 +672,7 @@
return false;
}
-#else // !defined(OS_WIN)
+#else // !BUILDFLAG(IS_WIN)
bool It2MeNativeMessagingHost::DelegateToElevatedHost(
std::unique_ptr<base::DictionaryValue> message) {
@@ -680,6 +680,6 @@
return false;
}
-#endif // !defined(OS_WIN)
+#endif // !BUILDFLAG(IS_WIN)
} // namespace remoting
diff --git a/remoting/host/it2me/it2me_native_messaging_host.h b/remoting/host/it2me/it2me_native_messaging_host.h
index ca6b608..e4dc459b 100644
--- a/remoting/host/it2me/it2me_native_messaging_host.h
+++ b/remoting/host/it2me/it2me_native_messaging_host.h
@@ -114,12 +114,12 @@
// Forward messages to an |elevated_host_|.
bool use_elevated_host_ = false;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// Controls the lifetime of the elevated native messaging host process.
// Note: 'elevated' in this instance means having the UiAccess privilege, not
// being run as a higher privilege user.
std::unique_ptr<ElevatedNativeMessagingHost> elevated_host_;
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
raw_ptr<Client> client_ = nullptr;
DelegatingSignalStrategy::IqCallback incoming_message_callback_;
diff --git a/remoting/host/it2me/it2me_native_messaging_host_main.cc b/remoting/host/it2me/it2me_native_messaging_host_main.cc
index c507991..deadd8c 100644
--- a/remoting/host/it2me/it2me_native_messaging_host_main.cc
+++ b/remoting/host/it2me/it2me_native_messaging_host_main.cc
@@ -30,32 +30,32 @@
#include "remoting/host/resources.h"
#include "remoting/host/usage_stats_consent.h"
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include <gtk/gtk.h>
#include "base/linux_util.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/x/xlib_support.h"
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
#include "base/mac/mac_util.h"
#include "base/mac/scoped_nsautorelease_pool.h"
#include "remoting/host/desktop_capturer_checker.h"
#include "remoting/host/mac/permission_utils.h"
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include <windows.h>
#include <commctrl.h>
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
namespace remoting {
namespace {
-#if defined(OS_WIN) && defined(OFFICIAL_BUILD)
+#if BUILDFLAG(IS_WIN) && defined(OFFICIAL_BUILD)
bool CurrentProcessHasUiAccess() {
HANDLE process_token;
OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &process_token);
@@ -69,18 +69,18 @@
CloseHandle(process_token);
return uiaccess_value != 0;
}
-#endif // defined(OS_WIN) && defined(OFFICIAL_BUILD)
+#endif // BUILDFLAG(IS_WIN) && defined(OFFICIAL_BUILD)
} // namespace
// Creates a It2MeNativeMessagingHost instance, attaches it to stdin/stdout and
// runs the task executor until It2MeNativeMessagingHost signals shutdown.
int It2MeNativeMessagingHostMain(int argc, char** argv) {
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// Initialize Xlib for multi-threaded use, allowing non-Chromium code to
// use X11 safely (such as the WebRTC capturer, GTK ...)
x11::InitXlib();
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// This object instance is required by Chrome code (such as
// SingleThreadTaskExecutor).
@@ -90,10 +90,10 @@
remoting::InitHostLogging();
remoting::HostSettings::Initialize();
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
// Needed so we don't leak objects when threads are created.
base::mac::ScopedNSAutoreleasePool pool;
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
#if defined(REMOTING_ENABLE_BREAKPAD)
// Initialize Breakpad as early as possible. On Mac the command-line needs to
@@ -104,13 +104,13 @@
}
#endif // defined(REMOTING_ENABLE_BREAKPAD)
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// Register and initialize common controls.
INITCOMMONCONTROLSEX info;
info.dwSize = sizeof(info);
info.dwICC = ICC_STANDARD_CLASSES;
InitCommonControlsEx(&info);
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
// Required to find the ICU data file, used by some file_util routines.
base::i18n::InitializeICU();
@@ -121,7 +121,7 @@
remoting::LoadResources("");
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// Required for any calls into GTK functions, such as the Disconnect and
// Continue windows. Calling with nullptr arguments because we don't have
// any command line arguments for gtk to consume.
@@ -134,13 +134,13 @@
// Need to prime the host OS version value for linux to prevent IO on the
// network thread. base::GetLinuxDistro() caches the result.
base::GetLinuxDistro();
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
base::File read_file;
base::File write_file;
bool is_process_elevated_ = false;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
@@ -202,7 +202,7 @@
SetStdHandle(STD_INPUT_HANDLE, nullptr);
SetStdHandle(STD_OUTPUT_HANDLE, nullptr);
}
-#elif defined(OS_POSIX)
+#elif BUILDFLAG(IS_POSIX)
// The files are automatically closed.
read_file = base::File(STDIN_FILENO);
write_file = base::File(STDOUT_FILENO);
@@ -213,7 +213,7 @@
base::SingleThreadTaskExecutor main_task_executor(base::MessagePumpType::UI);
base::RunLoop run_loop;
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
auto* cmd_line = base::CommandLine::ForCurrentProcess();
if (cmd_line->HasSwitch(kCheckAccessibilityPermissionSwitchName)) {
return mac::CanInjectInput() ? EXIT_SUCCESS : EXIT_FAILURE;
@@ -228,7 +228,7 @@
}
return mac::CanRecordScreen() ? EXIT_SUCCESS : EXIT_FAILURE;
}
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
// NetworkChangeNotifier must be initialized after SingleThreadTaskExecutor.
std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier(
@@ -243,9 +243,9 @@
std::unique_ptr<extensions::NativeMessagingChannel> channel(
new PipeMessagingChannel(std::move(read_file), std::move(write_file)));
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
PipeMessagingChannel::ReopenStdinStdout();
-#endif // defined(OS_POSIX)
+#endif // BUILDFLAG(IS_POSIX)
std::unique_ptr<ChromotingHostContext> context =
ChromotingHostContext::Create(new remoting::AutoThreadTaskRunner(
@@ -254,7 +254,7 @@
PolicyWatcher::CreateWithTaskRunner(context->file_task_runner(),
context->management_service());
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// Create an X11EventSource on all UI threads, so the global X11 connection
// (x11::Connection::Get()) can dispatch X events.
auto event_source =
@@ -263,7 +263,7 @@
input_task_runner->PostTask(FROM_HERE, base::BindOnce([]() {
new ui::X11EventSource(x11::Connection::Get());
}));
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
std::unique_ptr<extensions::NativeMessageHost> host(
new It2MeNativeMessagingHost(is_process_elevated_,
@@ -276,11 +276,11 @@
// Run the loop until channel is alive.
run_loop.Run();
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
input_task_runner->PostTask(FROM_HERE, base::BindOnce([]() {
delete ui::X11EventSource::GetInstance();
}));
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// Block until tasks blocking shutdown have completed their execution.
base::ThreadPoolInstance::Get()->Shutdown();
diff --git a/remoting/host/it2me_desktop_environment.cc b/remoting/host/it2me_desktop_environment.cc
index 43bc1f8a8..f92dbba8 100644
--- a/remoting/host/it2me_desktop_environment.cc
+++ b/remoting/host/it2me_desktop_environment.cc
@@ -17,10 +17,10 @@
#include "remoting/host/input_monitor/local_input_monitor.h"
#include "remoting/protocol/capability_names.h"
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
#include <sys/types.h>
#include <unistd.h>
-#endif // defined(OS_POSIX)
+#endif // BUILDFLAG(IS_POSIX)
namespace remoting {
@@ -51,7 +51,7 @@
bool enable_user_interface = options.enable_user_interface();
bool enable_notifications = options.enable_notifications();
// The host UI should be created on the UI thread.
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
// Don't try to display any UI on top of the system's login screen as this
// is rejected by the Window Server on OS X 10.7.4, and prevents the
// capturer from working (http://crbug.com/140984).
@@ -60,7 +60,7 @@
// running in the LoginWindow context, and refactor this into a separate
// function to be used here and in CurtainMode::ActivateCurtain().
enable_user_interface = getuid() != 0;
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
// Create the continue window. The implication of this window is that the
// session length will be limited. If the user interface is disabled,
diff --git a/remoting/host/me2me_desktop_environment.cc b/remoting/host/me2me_desktop_environment.cc
index f9e071a..d534a772 100644
--- a/remoting/host/me2me_desktop_environment.cc
+++ b/remoting/host/me2me_desktop_environment.cc
@@ -27,14 +27,14 @@
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
#include <sys/types.h>
#include <unistd.h>
-#endif // defined(OS_POSIX)
+#endif // BUILDFLAG(IS_POSIX)
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "base/win/windows_version.h"
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
namespace remoting {
@@ -76,7 +76,7 @@
capabilities += protocol::kFileTransferCapability;
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
capabilities += " ";
capabilities += protocol::kSendAttentionSequenceAction;
@@ -85,7 +85,7 @@
capabilities += " ";
capabilities += protocol::kLockWorkstationAction;
}
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
if (desktop_environment_options().enable_remote_open_url() &&
IsRemoteOpenUrlSupported()) {
@@ -143,9 +143,9 @@
// Otherwise, if the session is shared with the local user start monitoring
// the local input and create the in-session UI.
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
bool want_user_interface = false;
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
// Don't try to display any UI on top of the system's login screen as this
// is rejected by the Window Server on OS X 10.7.4, and prevents the
// capturer from working (http://crbug.com/140984).
@@ -167,7 +167,7 @@
client_session_control);
// Create the disconnect window.
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
disconnect_window_ =
HostWindow::CreateAutoHidingDisconnectWindow(LocalInputMonitor::Create(
caller_task_runner(), input_task_runner(), ui_task_runner()));
diff --git a/remoting/host/mojo_ipc/mojo_ipc_server.cc b/remoting/host/mojo_ipc/mojo_ipc_server.cc
index 0c1bd22..265f43d 100644
--- a/remoting/host/mojo_ipc/mojo_ipc_server.cc
+++ b/remoting/host/mojo_ipc/mojo_ipc_server.cc
@@ -16,10 +16,10 @@
#include "build/build_config.h"
#include "remoting/host/mojo_ipc/mojo_server_endpoint_connector.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "base/strings/stringprintf.h"
#include "base/win/win_util.h"
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
namespace remoting {
@@ -34,7 +34,7 @@
mojo::NamedPlatformChannel::Options options;
options.server_name = server_name;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
options.enforce_uniqueness = false;
// Create a named pipe owned by the current user (the LocalService account
// (SID: S-1-5-19) when running in the network process) which is available to
@@ -47,7 +47,7 @@
}
options.security_descriptor = base::StringPrintf(
L"O:%lsG:%lsD:(A;;GA;;;AU)", user_sid.c_str(), user_sid.c_str());
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
mojo::NamedPlatformChannel channel(options);
return channel.TakeServerEndpoint();
diff --git a/remoting/host/mojo_ipc/mojo_ipc_test_util.cc b/remoting/host/mojo_ipc/mojo_ipc_test_util.cc
index 8e1e6b3..b6ae3890 100644
--- a/remoting/host/mojo_ipc/mojo_ipc_test_util.cc
+++ b/remoting/host/mojo_ipc/mojo_ipc_test_util.cc
@@ -18,7 +18,7 @@
mojo::NamedPlatformChannel::ServerName GenerateRandomServerName() {
std::string temp_path;
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
// Posix server names should start with the temp directory path. Otherwise the
// socket file will be created under the current working directory.
base::FilePath temp_file_path;
diff --git a/remoting/host/mojo_ipc/mojo_ipc_util.cc b/remoting/host/mojo_ipc/mojo_ipc_util.cc
index 7dff0a0..c9cf74f 100644
--- a/remoting/host/mojo_ipc/mojo_ipc_util.cc
+++ b/remoting/host/mojo_ipc/mojo_ipc_util.cc
@@ -8,7 +8,7 @@
#include "build/build_config.h"
-#if defined(OS_POSIX) && !defined(OS_MAC)
+#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
@@ -18,7 +18,7 @@
mojo::NamedPlatformChannel::ServerName
WorkingDirectoryIndependentServerNameFromUTF8(base::StringPiece name) {
-#if defined(OS_POSIX) && !defined(OS_MAC)
+#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
// The channel name on non-mac POSIX (basically Linux) is the path to a unix
// domain socket, so it needs to be an absolute path to allow the IPC binary
// to be executed from any working directory.
diff --git a/remoting/host/native_messaging/native_messaging_reader.cc b/remoting/host/native_messaging/native_messaging_reader.cc
index 8290746..bfe6916697 100644
--- a/remoting/host/native_messaging/native_messaging_reader.cc
+++ b/remoting/host/native_messaging/native_messaging_reader.cc
@@ -23,12 +23,12 @@
#include "base/values.h"
#include "build/build_config.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include <windows.h>
#include "base/threading/platform_thread.h"
#include "base/win/scoped_handle.h"
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
namespace {
@@ -160,7 +160,7 @@
NativeMessagingReader::~NativeMessagingReader() {
read_task_runner_->DeleteSoon(FROM_HERE, core_.release());
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// The ReadMessage() method uses a blocking read (on all platforms) which
// cause a deadlock if the owning thread attempts to destroy this object
// while there is a read operation pending.
@@ -181,7 +181,7 @@
PLOG(ERROR) << "CancelSynchronousIo() failed";
}
}
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
}
void NativeMessagingReader::Start(const MessageCallback& message_callback,
diff --git a/remoting/host/native_messaging/native_messaging_reader_unittest.cc b/remoting/host/native_messaging/native_messaging_reader_unittest.cc
index c0309b8..1d1a597 100644
--- a/remoting/host/native_messaging/native_messaging_reader_unittest.cc
+++ b/remoting/host/native_messaging/native_messaging_reader_unittest.cc
@@ -112,7 +112,7 @@
ASSERT_TRUE(on_error_signaled_);
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// This scenario is only a problem on Windows as closing the write pipe there
// does not trigger the parent process to close the read pipe.
TEST_F(NativeMessagingReaderTest, ReaderDestroyedByOwner) {
@@ -124,7 +124,7 @@
reader_.reset();
ASSERT_FALSE(on_error_signaled_);
}
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
TEST_F(NativeMessagingReaderTest, SingleGoodMessage) {
WriteMessage("{\"foo\": 42}");
diff --git a/remoting/host/native_messaging/pipe_messaging_channel.cc b/remoting/host/native_messaging/pipe_messaging_channel.cc
index 1603e8f7..914a218 100644
--- a/remoting/host/native_messaging/pipe_messaging_channel.cc
+++ b/remoting/host/native_messaging/pipe_messaging_channel.cc
@@ -30,7 +30,7 @@
// static
void PipeMessagingChannel::ReopenStdinStdout() {
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
base::FilePath dev_null("/dev/null");
int new_stdin =
base::File(dev_null, base::File::FLAG_OPEN | base::File::FLAG_READ)
@@ -40,7 +40,7 @@
base::File(dev_null, base::File::FLAG_OPEN | base::File::FLAG_WRITE)
.TakePlatformFile();
DCHECK_EQ(new_stdout, STDOUT_FILENO);
-#endif // defined(OS_POSIX)
+#endif // BUILDFLAG(IS_POSIX)
}
void PipeMessagingChannel::Start(EventHandler* event_handler) {
diff --git a/remoting/host/policy_watcher.cc b/remoting/host/policy_watcher.cc
index 588c211..75410c188 100644
--- a/remoting/host/policy_watcher.cc
+++ b/remoting/host/policy_watcher.cc
@@ -34,12 +34,12 @@
#include "base/json/json_reader.h"
#endif
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "components/policy/core/common/policy_loader_win.h"
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
#include "components/policy/core/common/policy_loader_mac.h"
#include "components/policy/core/common/preferences_mac.h"
-#elif defined(OS_POSIX) && !defined(OS_ANDROID)
+#elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID)
#include "components/policy/core/common/config_dir_policy_loader.h"
#endif
@@ -49,7 +49,7 @@
namespace {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
constexpr wchar_t kChromePolicyKey[] = L"SOFTWARE\\Policies\\Google\\Chrome";
#endif
@@ -384,7 +384,7 @@
const policy::PolicyMap& current = policy_service_->GetPolicies(ns);
OnPolicyUpdated(ns, current, current);
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
WatchForRegistryChanges();
#endif
}
@@ -416,7 +416,7 @@
CreateSchemaRegistry()));
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
void PolicyWatcher::WatchForRegistryChanges() {
if (!policy_key_.Valid()) {
auto open_result =
@@ -451,21 +451,21 @@
// (even on Chromium) so that policy enforcement can't be bypassed by running
// Chromium.
std::unique_ptr<policy::AsyncPolicyLoader> policy_loader;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
policy_loader = std::make_unique<policy::PolicyLoaderWin>(
file_task_runner, management_service, kChromePolicyKey);
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
CFStringRef bundle_id = CFSTR("com.google.Chrome");
policy_loader = std::make_unique<policy::PolicyLoaderMac>(
file_task_runner,
policy::PolicyLoaderMac::GetManagedPolicyPath(bundle_id),
new MacPreferences(), bundle_id);
-#elif defined(OS_POSIX) && !defined(OS_ANDROID)
+#elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID)
policy_loader = std::make_unique<policy::ConfigDirPolicyLoader>(
file_task_runner,
base::FilePath(FILE_PATH_LITERAL("/etc/opt/chrome/policies")),
policy::POLICY_SCOPE_MACHINE);
-#elif defined(OS_ANDROID)
+#elif BUILDFLAG(IS_ANDROID)
NOTIMPLEMENTED();
policy::PolicyServiceImpl::Providers providers;
std::unique_ptr<policy::PolicyService> owned_policy_service(
diff --git a/remoting/host/policy_watcher.h b/remoting/host/policy_watcher.h
index 3e3e3c1..2b0d08cb 100644
--- a/remoting/host/policy_watcher.h
+++ b/remoting/host/policy_watcher.h
@@ -14,7 +14,7 @@
#include "build/build_config.h"
#include "components/policy/core/common/policy_service.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "base/win/registry.h"
#endif
@@ -156,7 +156,7 @@
const policy::PolicyMap& current) override;
void OnPolicyServiceInitialized(policy::PolicyDomain domain) override;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
void WatchForRegistryChanges();
#endif
@@ -183,7 +183,7 @@
std::unique_ptr<policy::ConfigurationPolicyProvider> owned_policy_provider_;
std::unique_ptr<policy::PolicyService> owned_policy_service_;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// |policy_key_| relies on |policy_service_| to notify the host of policy
// changes. Make sure |policy_key_| is destroyed to prevent any notifications
// from firing while the above objects are being torn down.
diff --git a/remoting/host/policy_watcher_unittest.cc b/remoting/host/policy_watcher_unittest.cc
index 3541227..28b6522 100644
--- a/remoting/host/policy_watcher_unittest.cc
+++ b/remoting/host/policy_watcher_unittest.cc
@@ -517,7 +517,7 @@
ON_CALL(mock_log, Log(_, _, _, _, _)).WillByDefault(testing::Return(true));
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// The PolicyWatcher on Windows tries to open a handle to the Chrome policy
// registry key on Windows which fails on the Chromium bots. The warning that
// gets logged cases the subsequent log assertion to fail so this check was
@@ -589,7 +589,7 @@
testing::InSequence sequence;
EXPECT_CALL(mock_policy_callback_,
OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_)));
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// This setting only affects Windows, it is ignored on other platforms so the
// 2 SetPolicies calls won't result in any calls to OnPolicyUpdate.
EXPECT_CALL(mock_policy_callback_,
@@ -597,7 +597,7 @@
EXPECT_CALL(
mock_policy_callback_,
OnPolicyUpdatePtr(IsPolicies(&remote_assistance_uiaccess_false_)));
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
SetPolicies(empty_);
StartWatching();
@@ -640,7 +640,7 @@
testing::InSequence sequence;
EXPECT_CALL(mock_policy_callback_,
OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_)));
-#if !defined(OS_WIN)
+#if !BUILDFLAG(IS_WIN)
EXPECT_CALL(mock_policy_callback_,
OnPolicyUpdatePtr(IsPolicies(&username_true_)));
EXPECT_CALL(mock_policy_callback_,
@@ -716,7 +716,7 @@
i.Advance()) {
expected_schema[i.key()] = i.value().type();
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// RemoteAccessHostMatchUsername is marked in policy_templates.json as not
// supported on Windows and therefore is (by design) excluded from the schema.
expected_schema.erase(key::kRemoteAccessHostMatchUsername);
@@ -730,7 +730,7 @@
expected_schema.erase(key::kRemoteAccessHostTokenValidationUrl);
expected_schema.erase(key::kRemoteAccessHostTokenValidationCertificateIssuer);
expected_schema.erase(key::kRemoteAccessHostAllowUiAccessForRemoteAssistance);
-#else // !defined(OS_WIN)
+#else // !BUILDFLAG(IS_WIN)
// RemoteAssistanceHostAllowUiAccess does not exist on non-Windows platforms.
expected_schema.erase(key::kRemoteAccessHostAllowUiAccessForRemoteAssistance);
#endif
diff --git a/remoting/host/remote_open_url/remote_open_url_client.cc b/remoting/host/remote_open_url/remote_open_url_client.cc
index f3abd24..b6f9dea8 100644
--- a/remoting/host/remote_open_url/remote_open_url_client.cc
+++ b/remoting/host/remote_open_url/remote_open_url_client.cc
@@ -15,9 +15,9 @@
#include "remoting/host/mojom/chromoting_host_services.mojom.h"
#include "remoting/host/mojom/remote_url_opener.mojom.h"
-#if defined(OS_LINUX)
+#if BUILDFLAG(IS_LINUX)
#include "remoting/host/remote_open_url/remote_open_url_client_delegate_linux.h"
-#elif defined(OS_WIN)
+#elif BUILDFLAG(IS_WIN)
#include "remoting/host/remote_open_url/remote_open_url_client_delegate_win.h"
#endif
@@ -28,9 +28,9 @@
constexpr base::TimeDelta kRequestTimeout = base::Seconds(5);
std::unique_ptr<RemoteOpenUrlClient::Delegate> CreateDelegate() {
-#if defined(OS_LINUX)
+#if BUILDFLAG(IS_LINUX)
return std::make_unique<RemoteOpenUrlClientDelegateLinux>();
-#elif defined(OS_WIN)
+#elif BUILDFLAG(IS_WIN)
return std::make_unique<RemoteOpenUrlClientDelegateWin>();
#else
NOTREACHED();
diff --git a/remoting/host/remote_open_url/remote_open_url_constants.cc b/remoting/host/remote_open_url/remote_open_url_constants.cc
index b32b7d1..0dc94302 100644
--- a/remoting/host/remote_open_url/remote_open_url_constants.cc
+++ b/remoting/host/remote_open_url/remote_open_url_constants.cc
@@ -10,7 +10,7 @@
const char kRemoteOpenUrlDataChannelName[] = "remote-open-url";
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#if defined(OFFICIAL_BUILD)
const wchar_t kUrlForwarderProgId[] = L"ChromeRemoteDesktopUrlForwarder";
diff --git a/remoting/host/remote_open_url/remote_open_url_constants.h b/remoting/host/remote_open_url/remote_open_url_constants.h
index 1c6257f..4d807f6d37 100644
--- a/remoting/host/remote_open_url/remote_open_url_constants.h
+++ b/remoting/host/remote_open_url/remote_open_url_constants.h
@@ -11,7 +11,7 @@
extern const char kRemoteOpenUrlDataChannelName[];
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// The ProgID of the URL forwarder.
extern const wchar_t kUrlForwarderProgId[];
diff --git a/remoting/host/remote_open_url/remote_open_url_util.cc b/remoting/host/remote_open_url/remote_open_url_util.cc
index 1710da5..ce3cad5d 100644
--- a/remoting/host/remote_open_url/remote_open_url_util.cc
+++ b/remoting/host/remote_open_url/remote_open_url_util.cc
@@ -7,7 +7,7 @@
#include "base/logging.h"
#include "build/build_config.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "base/win/registry.h"
#include "base/win/windows_types.h"
#include "base/win/windows_version.h"
@@ -15,7 +15,7 @@
namespace remoting {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#if defined(OFFICIAL_BUILD)
const wchar_t kUrlForwarderRegisteredAppName[] =
@@ -30,9 +30,9 @@
#endif // defined (OS_WIN)
bool IsRemoteOpenUrlSupported() {
-#if defined(OS_LINUX)
+#if BUILDFLAG(IS_LINUX)
return true;
-#elif defined(OS_WIN)
+#elif BUILDFLAG(IS_WIN)
// The modern default apps settings dialog is only available to Windows 8+.
// Given older Windows versions are EOL, we only advertise the feature on
// Windows 8+.
diff --git a/remoting/host/remote_open_url/url_forwarder_configurator.cc b/remoting/host/remote_open_url/url_forwarder_configurator.cc
index 0f4ee27..71fdd92 100644
--- a/remoting/host/remote_open_url/url_forwarder_configurator.cc
+++ b/remoting/host/remote_open_url/url_forwarder_configurator.cc
@@ -12,7 +12,7 @@
UrlForwarderConfigurator::~UrlForwarderConfigurator() = default;
-#if !defined(OS_LINUX) && !defined(OS_WIN)
+#if !BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_WIN)
// static
std::unique_ptr<UrlForwarderConfigurator> UrlForwarderConfigurator::Create() {
@@ -22,6 +22,6 @@
return nullptr;
}
-#endif // !defined(OS_LINUX) && !defined(OS_WIN)
+#endif // !BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_WIN)
} // namespace remoting
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index 0dcd77f..06e272d 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -106,24 +106,24 @@
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/webrtc/api/scoped_refptr.h"
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>
#include "base/file_descriptor_posix.h"
#include "remoting/host/pam_authorization_factory_posix.h"
#include "remoting/host/posix/signal_handler.h"
-#endif // defined(OS_POSIX)
+#endif // BUILDFLAG(IS_POSIX)
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
#include "base/mac/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "remoting/host/audio_capturer_mac.h"
#include "remoting/host/desktop_capturer_checker.h"
#include "remoting/host/mac/permission_utils.h"
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include <gtk/gtk.h>
#include "base/linux_util.h"
@@ -131,21 +131,21 @@
#include "remoting/host/linux/certificate_watcher.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/x/xlib_support.h"
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include <commctrl.h>
#include "base/win/registry.h"
#include "base/win/scoped_handle.h"
#include "base/win/windows_version.h"
#include "remoting/host/pairing_registry_delegate_win.h"
#include "remoting/host/win/session_desktop_environment.h"
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
using remoting::protocol::PairingRegistry;
using remoting::protocol::NetworkSettings;
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
// The following creates a section that tells Mac OS X that it is OK to let us
// inject input in the login screen. Just the name of the section is important,
@@ -154,7 +154,7 @@
__attribute__((section ("__CGPreLoginApp,__cgpreloginapp")))
static const char magic_section[] = "";
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
namespace {
@@ -167,17 +167,17 @@
const char kStdinConfigPath[] = "-";
#endif // !defined(REMOTING_MULTI_PROCESS)
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// The command line switch used to pass name of the pipe to capture audio on
// linux.
const char kAudioPipeSwitchName[] = "audio-pipe-name";
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
// The command line switch used to pass name of the unix domain socket used to
// listen for security key requests.
const char kAuthSocknameSwitchName[] = "ssh-auth-sockname";
-#endif // defined(OS_POSIX)
+#endif // BUILDFLAG(IS_POSIX)
// The command line switch used by the parent to request the host to signal it
// when it is successfully started.
@@ -285,7 +285,7 @@
void ShutdownOnNetworkThread();
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
// Callback passed to RegisterSignalHandler() to handle SIGTERM events.
void SigTermHandler(int signal_number);
#endif
@@ -355,7 +355,7 @@
void GoOffline(const std::string& host_offline_reason);
void OnHostOfflineReasonAck(bool success);
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// mojom::RemotingHostControl implementation.
void CrashHostProcess(const std::string& function_name,
const std::string& file_name,
@@ -368,7 +368,7 @@
std::unique_ptr<ChromotingHostContext> context_;
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// Watch for certificate changes and kill the host when changes occur
std::unique_ptr<CertificateWatcher> cert_watcher_;
#endif
@@ -463,13 +463,13 @@
mojo::AssociatedReceiver<mojom::RemotingHostControl> remoting_host_control_{
this};
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
// When using the command line option to check the Accessibility or Screen
// Recording permission, these track the permission state and indicate that
// the host should exit immediately with the result.
bool checking_permission_state_ = false;
bool permission_granted_ = false;
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
};
HostProcess::HostProcess(std::unique_ptr<ChromotingHostContext> context,
@@ -487,7 +487,7 @@
StartOnUiThread();
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
if (checking_permission_state_) {
*exit_code_out = (permission_granted_ ? EXIT_SUCCESS : EXIT_FAILURE);
}
@@ -510,7 +510,7 @@
}
bool HostProcess::InitWithCommandLine(const base::CommandLine* cmd_line) {
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
if (cmd_line->HasSwitch(kCheckAccessibilityPermissionSwitchName)) {
checking_permission_state_ = true;
permission_granted_ = mac::CanInjectInput();
@@ -539,7 +539,7 @@
}
return false;
}
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
// Mojo keeps the task runner passed to it alive forever, so an
// AutoThreadTaskRunner should not be passed to it. Otherwise, the process may
@@ -731,22 +731,22 @@
}
#endif // !defined(REMOTING_MULTI_PROCESS)
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
remoting::RegisterSignalHandler(
SIGTERM, base::BindRepeating(&HostProcess::SigTermHandler,
base::Unretained(this)));
-#endif // defined(OS_POSIX)
+#endif // BUILDFLAG(IS_POSIX)
}
void HostProcess::ShutdownOnNetworkThread() {
DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
config_watcher_.reset();
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
cert_watcher_.reset();
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
}
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
void HostProcess::SigTermHandler(int signal_number) {
DCHECK(signal_number == SIGTERM);
DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
@@ -775,7 +775,7 @@
if (allow_pairing_) {
// On Windows |pairing_registry_| is initialized in
// InitializePairingRegistry().
-#if !defined(OS_WIN)
+#if !BUILDFLAG(IS_WIN)
if (!pairing_registry_) {
std::unique_ptr<PairingRegistry::Delegate> delegate =
CreatePairingRegistryDelegate();
@@ -784,7 +784,7 @@
pairing_registry_ = new PairingRegistry(context_->file_task_runner(),
std::move(delegate));
}
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
pairing_registry = pairing_registry_;
}
@@ -800,7 +800,7 @@
DCHECK(third_party_auth_config_.token_url.is_valid());
DCHECK(third_party_auth_config_.token_validation_url.is_valid());
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
if (!cert_watcher_) {
cert_watcher_ = std::make_unique<CertificateWatcher>(
base::BindRepeating(&HostProcess::ShutdownHost,
@@ -809,7 +809,7 @@
cert_watcher_->Start();
}
cert_watcher_->SetMonitor(host_->status_monitor());
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
scoped_refptr<protocol::TokenValidatorFactory> token_validator_factory =
new TokenValidatorFactoryImpl(third_party_auth_config_, key_pair_,
@@ -819,10 +819,10 @@
token_validator_factory);
}
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
// On Linux and Mac, perform a PAM authorization step after authentication.
factory = std::make_unique<PamAuthorizationFactory>(std::move(factory));
-#endif // defined(OS_POSIX)
+#endif // BUILDFLAG(IS_POSIX)
host_->SetAuthenticatorFactory(std::move(factory));
}
@@ -914,7 +914,7 @@
base::BindRepeating(&HostProcess::OnPolicyUpdate, base::Unretained(this)),
base::BindRepeating(&HostProcess::OnPolicyError, base::Unretained(this)));
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// If an audio pipe is specific on the command-line then initialize
// AudioCapturerLinux to capture from it.
base::FilePath audio_pipe_name = base::CommandLine::ForCurrentProcess()->
@@ -923,9 +923,9 @@
remoting::AudioCapturerLinux::InitializePipeReader(
context_->audio_task_runner(), audio_pipe_name);
}
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
base::FilePath security_key_socket_name =
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
kAuthSocknameSwitchName);
@@ -935,7 +935,7 @@
} else {
security_key_extension_supported_ = false;
}
-#endif // defined(OS_POSIX)
+#endif // BUILDFLAG(IS_POSIX)
// Create a desktop environment factory appropriate to the build type &
// platform.
@@ -975,7 +975,7 @@
// It is now safe for the HostProcess to be deleted.
self_ = nullptr;
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// Cause the global AudioPipeReader to be freed, otherwise the audio
// thread will remain in-use and prevent the process from exiting.
// TODO(wez): DesktopEnvironmentFactory should own the pipe reader.
@@ -998,7 +998,7 @@
return;
}
HOST_LOG << "Host ready to receive connections.";
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
if (signal_parent_) {
kill(getppid(), SIGUSR1);
signal_parent_ = false;
@@ -1011,7 +1011,7 @@
ShutdownHost(kHostDeletedExitCode);
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
void HostProcess::ApplyHostConfig(base::Value config) {
DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
OnConfigParsed(std::move(config));
@@ -1050,7 +1050,7 @@
// initialized.
CreateAuthenticatorFactory();
}
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
// Applies the host config, returning true if successful.
bool HostProcess::ApplyConfig(const base::Value& config) {
@@ -1276,7 +1276,7 @@
!base::StartsWith(host_owner_, username + std::string("@"),
base::CompareCase::INSENSITIVE_ASCII);
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
// On Mac, we run as root at the login screen, so the username won't match.
// However, there's no need to enforce the policy at the login screen, as
// the client will have to reconnect if a login occurs.
@@ -1288,10 +1288,10 @@
// Curtain-mode on Windows presents the standard OS login prompt to the user
// for each connection, removing the need for an explicit user-name matching
// check.
-#if defined(OS_WIN) && defined(REMOTING_RDP_SESSION)
+#if BUILDFLAG(IS_WIN) && defined(REMOTING_RDP_SESSION)
if (desktop_environment_options_.enable_curtaining())
return;
-#endif // defined(OS_WIN) && defined(REMOTING_RDP_SESSION)
+#endif // BUILDFLAG(IS_WIN) && defined(REMOTING_RDP_SESSION)
// Shutdown the host if the username does not match.
if (shutdown) {
@@ -1382,7 +1382,7 @@
desktop_environment_options_.set_enable_curtaining(curtain_required.value());
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
if (curtain_required.value()) {
// When curtain mode is in effect on Mac, the host process runs in the
// user's switched-out session, but launchd will also run an instance at
@@ -1685,7 +1685,7 @@
// The feature is enabled for all Googlers using a supported platform.
desktop_environment_options_.set_enable_remote_open_url(is_googler_);
-#if defined(OS_LINUX) || !defined(NDEBUG)
+#if BUILDFLAG(IS_LINUX) || !defined(NDEBUG)
// Experimental feature. Enabled on Linux for easier testing.
if (is_googler_) {
desktop_environment_options_.set_enable_remote_webauthn(true);
@@ -1741,7 +1741,7 @@
HostEventLogger::Create(host_->status_monitor(), kApplicationName);
#endif // !defined(REMOTING_MULTI_PROCESS)
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
// Don't run the permission-checks as root (i.e. at the login screen), as they
// are not actionable there.
// Also, the permission-checks are not needed on MacOS 10.15+, as they are
@@ -1750,7 +1750,7 @@
if (getuid() != 0U && base::mac::IsAtMostOS10_14()) {
mac::PromptUserToChangeTrustStateIfNeeded(context_->ui_task_runner());
}
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
host_->Start(host_owner_);
host_->StartChromotingHostServices();
@@ -1870,7 +1870,7 @@
}
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
void HostProcess::CrashHostProcess(const std::string& function_name,
const std::string& file_name,
int line_number) {
@@ -1882,7 +1882,7 @@
int HostProcessMain() {
HOST_LOG << "Starting host process: version " << STRINGIZE(VERSION);
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// Initialize Xlib for multi-threaded use, allowing non-Chromium code to
// use X11 safely (such as the WebRTC capturer, GTK ...)
x11::InitXlib();
@@ -1902,7 +1902,7 @@
// Need to prime the host OS version value for linux to prevent IO on the
// network thread. base::GetLinuxDistro() caches the result.
base::GetLinuxDistro();
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
base::ThreadPoolInstance::CreateAndStartWithDefaultParams("Me2Me");
@@ -1919,7 +1919,7 @@
std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier(
net::NetworkChangeNotifier::CreateIfNeeded());
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// Create an X11EventSource on all UI threads, so the global X11 connection
// (x11::Connection::Get()) can dispatch X events.
auto event_source =
@@ -1927,7 +1927,7 @@
context->input_task_runner()->PostTask(
FROM_HERE,
base::BindOnce([]() { new ui::X11EventSource(x11::Connection::Get()); }));
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// Create & start the HostProcess using these threads.
// TODO(wez): The HostProcess holds a reference to itself until Shutdown().
diff --git a/remoting/host/resources_unittest.cc b/remoting/host/resources_unittest.cc
index b29f70c..1cd23a4 100644
--- a/remoting/host/resources_unittest.cc
+++ b/remoting/host/resources_unittest.cc
@@ -33,7 +33,7 @@
#endif // BUILDFLAGdefined(GOOGLE_CRANDING)
// Chrome-style i18n is not used on Windows or Android.
-#if defined(OS_WIN) || defined(OS_ANDROID)
+#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_ANDROID)
EXPECT_FALSE(resources_available_);
#else
EXPECT_TRUE(resources_available_);
diff --git a/remoting/host/security_key/fake_security_key_ipc_server.cc b/remoting/host/security_key/fake_security_key_ipc_server.cc
index 0ccf292..c21769c 100644
--- a/remoting/host/security_key/fake_security_key_ipc_server.cc
+++ b/remoting/host/security_key/fake_security_key_ipc_server.cc
@@ -88,7 +88,7 @@
base::TimeDelta request_timeout) {
mojo::NamedPlatformChannel::Options options;
options.server_name = server_name;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
options.enforce_uniqueness = false;
#endif
mojo::NamedPlatformChannel channel(options);
diff --git a/remoting/host/security_key/remote_security_key_main.cc b/remoting/host/security_key/remote_security_key_main.cc
index cdd23cd..a46c6ac 100644
--- a/remoting/host/security_key/remote_security_key_main.cc
+++ b/remoting/host/security_key/remote_security_key_main.cc
@@ -22,16 +22,16 @@
#include "remoting/host/security_key/security_key_ipc_client.h"
#include "remoting/host/security_key/security_key_message_handler.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include <windows.h>
#include "remoting/host/win/acl_util.h"
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
namespace remoting {
int StartRemoteSecurityKey() {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
if (!AddProcessAccessRightForWellKnownSid(
WinLocalServiceSid, PROCESS_QUERY_LIMITED_INFORMATION)) {
return kInitializationFailed;
@@ -54,7 +54,7 @@
// handles as soon as we retrieve the corresponding file handles.
SetStdHandle(STD_INPUT_HANDLE, nullptr);
SetStdHandle(STD_OUTPUT_HANDLE, nullptr);
-#elif defined(OS_POSIX)
+#elif BUILDFLAG(IS_POSIX)
// The files are automatically closed.
base::File read_file(STDIN_FILENO);
base::File write_file(STDOUT_FILENO);
diff --git a/remoting/host/security_key/security_key_auth_handler.h b/remoting/host/security_key/security_key_auth_handler.h
index 6bbe16d..bc5ff4e 100644
--- a/remoting/host/security_key/security_key_auth_handler.h
+++ b/remoting/host/security_key/security_key_auth_handler.h
@@ -42,11 +42,11 @@
const SendMessageCallback& send_message_callback,
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner);
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
// Specify the name of the socket to listen to security key requests on.
static void SetSecurityKeySocketName(
const base::FilePath& security_key_socket_name);
-#endif // defined(OS_POSIX)
+#endif // BUILDFLAG(IS_POSIX)
// Sets the callback used to send messages to the client.
virtual void SetSendMessageCallback(const SendMessageCallback& callback) = 0;
diff --git a/remoting/host/security_key/security_key_ipc_client.cc b/remoting/host/security_key/security_key_ipc_client.cc
index aaa6b5c3..d0b5164 100644
--- a/remoting/host/security_key/security_key_ipc_client.cc
+++ b/remoting/host/security_key/security_key_ipc_client.cc
@@ -16,7 +16,7 @@
#include "ipc/ipc_listener.h"
#include "remoting/host/security_key/security_key_ipc_constants.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include <Windows.h>
#endif
@@ -104,7 +104,7 @@
void SecurityKeyIpcClient::OnChannelConnected(int32_t peer_pid) {
DCHECK(thread_checker_.CalledOnValidThread());
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
DWORD peer_session_id;
if (!ProcessIdToSessionId(peer_pid, &peer_session_id)) {
PLOG(ERROR) << "ProcessIdToSessionId failed";
@@ -119,7 +119,7 @@
std::move(connection_error_callback_).Run();
return;
}
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
std::move(connected_callback_).Run();
}
diff --git a/remoting/host/security_key/security_key_ipc_client_unittest.cc b/remoting/host/security_key/security_key_ipc_client_unittest.cc
index 56398bd3..6b09da76 100644
--- a/remoting/host/security_key/security_key_ipc_client_unittest.cc
+++ b/remoting/host/security_key/security_key_ipc_client_unittest.cc
@@ -17,7 +17,7 @@
#include "remoting/host/security_key/security_key_ipc_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
@@ -125,14 +125,14 @@
SecurityKeyIpcClientTest::~SecurityKeyIpcClientTest() = default;
void SecurityKeyIpcClientTest::SetUp() {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
DWORD session_id = 0;
// If we are on Windows, then we need to set the correct session ID or the
// IPC connection will not be created successfully.
ASSERT_TRUE(ProcessIdToSessionId(GetCurrentProcessId(), &session_id));
session_id_ = session_id;
security_key_ipc_client_.SetExpectedIpcServerSessionIdForTest(session_id_);
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
}
void SecurityKeyIpcClientTest::OperationComplete(bool failed) {
@@ -338,7 +338,7 @@
ASSERT_TRUE(operation_failed_);
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
TEST_F(SecurityKeyIpcClientTest, SecurityKeyIpcServerRunningInWrongSession) {
// Set the expected session Id to a different session than we are running in.
security_key_ipc_client_.SetExpectedIpcServerSessionIdForTest(session_id_ +
@@ -359,6 +359,6 @@
EstablishConnection(/*expect_error=*/true);
}
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
} // namespace remoting
diff --git a/remoting/host/security_key/security_key_ipc_constants.cc b/remoting/host/security_key/security_key_ipc_constants.cc
index 0100a9a..3a3e1830 100644
--- a/remoting/host/security_key/security_key_ipc_constants.cc
+++ b/remoting/host/security_key/security_key_ipc_constants.cc
@@ -7,11 +7,11 @@
#include "base/lazy_instance.h"
#include "build/build_config.h"
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
-#endif // defined(OS_POSIX)
+#endif // BUILDFLAG(IS_POSIX)
namespace {
@@ -43,14 +43,14 @@
std::string GetChannelNamePathPrefixForTest() {
std::string base_path;
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
base::FilePath base_file_path;
if (base::GetTempDir(&base_file_path)) {
base_path = base_file_path.AsEndingWithSeparator().value();
} else {
LOG(ERROR) << "Failed to retrieve temporary directory.";
}
-#endif // defined(OS_POSIX)
+#endif // BUILDFLAG(IS_POSIX)
return base_path;
}
diff --git a/remoting/host/security_key/security_key_ipc_server_impl.cc b/remoting/host/security_key/security_key_ipc_server_impl.cc
index ccd0ac2..097571ef 100644
--- a/remoting/host/security_key/security_key_ipc_server_impl.cc
+++ b/remoting/host/security_key/security_key_ipc_server_impl.cc
@@ -22,13 +22,13 @@
#include "remoting/base/logging.h"
#include "remoting/host/client_session_details.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include <windows.h>
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/win_util.h"
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
namespace {
@@ -74,7 +74,7 @@
mojo::NamedPlatformChannel::Options options;
options.server_name = server_name;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
options.enforce_uniqueness = false;
// Create a named pipe owned by the current user (the LocalService account
// (SID: S-1-5-19) when running in the network process) which is available to
@@ -87,7 +87,7 @@
options.security_descriptor = base::StringPrintf(
L"O:%lsG:%lsD:(A;;GA;;;AU)", user_sid.c_str(), user_sid.c_str());
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
mojo::NamedPlatformChannel channel(options);
mojo_connection_ = std::make_unique<mojo::IsolatedConnection>();
@@ -140,7 +140,7 @@
void SecurityKeyIpcServerImpl::OnChannelConnected(int32_t peer_pid) {
DCHECK(thread_checker_.CalledOnValidThread());
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
bool channel_error = false;
DWORD peer_session_id;
if (!ProcessIdToSessionId(peer_pid, &peer_session_id)) {
@@ -155,9 +155,9 @@
OnChannelError();
return;
}
-#else // !defined(OS_WIN)
+#else // !BUILDFLAG(IS_WIN)
CHECK_EQ(client_session_details_->desktop_session_id(), UINT32_MAX);
-#endif // !defined(OS_WIN)
+#endif // !BUILDFLAG(IS_WIN)
if (connect_callback_) {
std::move(connect_callback_).Run();
diff --git a/remoting/host/security_key/security_key_ipc_server_unittest.cc b/remoting/host/security_key/security_key_ipc_server_unittest.cc
index c17b64f1..83215a4b 100644
--- a/remoting/host/security_key/security_key_ipc_server_unittest.cc
+++ b/remoting/host/security_key/security_key_ipc_server_unittest.cc
@@ -22,7 +22,7 @@
#include "remoting/host/security_key/security_key_ipc_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
@@ -94,10 +94,10 @@
SecurityKeyIpcServerTest::SecurityKeyIpcServerTest()
: run_loop_(new base::RunLoop()) {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
EXPECT_TRUE(ProcessIdToSessionId(
GetCurrentProcessId(), reinterpret_cast<DWORD*>(&peer_session_id_)));
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
security_key_ipc_server_ = remoting::SecurityKeyIpcServer::Create(
kTestConnectionId, this, base::Milliseconds(kInitialConnectTimeoutMs),
@@ -351,7 +351,7 @@
}
// Flaky on mac, https://crbug.com/936583
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
#define MAYBE_NoSecurityKeyRequestTimeout DISABLED_NoSecurityKeyRequestTimeout
#else
#define MAYBE_NoSecurityKeyRequestTimeout NoSecurityKeyRequestTimeout
@@ -460,7 +460,7 @@
// because the channel shutdown is a series of asynchronous tasks posted on the
// IO thread, and there is not a way to synchronize it with the test main
// thread.
-#if !defined(OS_APPLE)
+#if !BUILDFLAG(IS_APPLE)
TEST_F(SecurityKeyIpcServerTest, CleanupPendingConnection) {
// Test that servers correctly close pending OS connections on
// |server_name|. If multiple servers do remain, the client may happen to
@@ -511,9 +511,9 @@
// Typically the client will be the one to close the connection.
fake_ipc_client.CloseIpcConnection();
}
-#endif // !defined(OS_APPLE)
+#endif // !BUILDFLAG(IS_APPLE)
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
TEST_F(SecurityKeyIpcServerTest, IpcConnectionFailsFromInvalidSession) {
// Change the expected session ID to not match the current session.
peer_session_id_++;
@@ -532,6 +532,6 @@
RunPendingTasks();
ASSERT_FALSE(fake_ipc_client.ipc_channel_connected());
}
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
} // namespace remoting
diff --git a/remoting/host/server_log_entry_host_unittest.cc b/remoting/host/server_log_entry_host_unittest.cc
index 553e665..2209315 100644
--- a/remoting/host/server_log_entry_host_unittest.cc
+++ b/remoting/host/server_log_entry_host_unittest.cc
@@ -45,16 +45,16 @@
key_value_pairs["session-state"] = "connected";
std::set<std::string> keys;
keys.insert("cpu");
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
key_value_pairs["os-name"] = "Windows";
keys.insert("os-version");
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
key_value_pairs["os-name"] = "Mac";
keys.insert("os-version");
#elif BUILDFLAG(IS_CHROMEOS_ASH)
key_value_pairs["os-name"] = "ChromeOS";
keys.insert("os-version");
-#elif defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
+#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
key_value_pairs["os-name"] = "Linux";
keys.insert("os-version");
#endif
diff --git a/remoting/host/setup/daemon_controller.cc b/remoting/host/setup/daemon_controller.cc
index 341b3d2..fca5091a 100644
--- a/remoting/host/setup/daemon_controller.cc
+++ b/remoting/host/setup/daemon_controller.cc
@@ -27,7 +27,7 @@
delegate_(std::move(delegate)) {
// Launch the delegate thread.
delegate_thread_ = std::make_unique<AutoThread>(kDaemonControllerThreadName);
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
delegate_thread_->SetComInitType(AutoThread::COM_INIT_STA);
delegate_task_runner_ =
delegate_thread_->StartWithType(base::MessagePumpType::UI);
diff --git a/remoting/host/setup/me2me_native_messaging_host.cc b/remoting/host/setup/me2me_native_messaging_host.cc
index 767c83f..1c8a2e2 100644
--- a/remoting/host/setup/me2me_native_messaging_host.cc
+++ b/remoting/host/setup/me2me_native_messaging_host.cc
@@ -31,15 +31,15 @@
#include "remoting/host/pin_hash.h"
#include "remoting/protocol/pairing_registry.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "remoting/host/win/elevated_native_messaging_host.h"
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
namespace {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
const int kElevatedHostTimeoutSeconds = 300;
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
// redirect_uri to use when authenticating service accounts (service account
// codes are obtained "out-of-band", i.e., not through an OAuth redirect).
@@ -50,9 +50,9 @@
"pairingRegistry",
"oauthClient",
"getRefreshTokenFromAuthCode",
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
"it2mePermissionCheck",
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
};
// Helper to extract the "config" part of a message as a DictionaryValue.
@@ -79,7 +79,7 @@
scoped_refptr<protocol::PairingRegistry> pairing_registry,
std::unique_ptr<OAuthClient> oauth_client)
: needs_elevation_(needs_elevation),
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
parent_window_handle_(parent_window_handle),
#endif
host_context_(std::move(host_context)),
@@ -582,7 +582,7 @@
client_->CloseChannel(std::string());
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
Me2MeNativeMessagingHost::DelegationResult
Me2MeNativeMessagingHost::DelegateToElevatedHost(
@@ -613,7 +613,7 @@
}
}
-#else // defined(OS_WIN)
+#else // BUILDFLAG(IS_WIN)
Me2MeNativeMessagingHost::DelegationResult
Me2MeNativeMessagingHost::DelegateToElevatedHost(
@@ -622,6 +622,6 @@
return DELEGATION_FAILED;
}
-#endif // !defined(OS_WIN)
+#endif // !BUILDFLAG(IS_WIN)
} // namespace remoting
diff --git a/remoting/host/setup/me2me_native_messaging_host.h b/remoting/host/setup/me2me_native_messaging_host.h
index a3489193..73fb940 100644
--- a/remoting/host/setup/me2me_native_messaging_host.h
+++ b/remoting/host/setup/me2me_native_messaging_host.h
@@ -135,13 +135,13 @@
bool needs_elevation_;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// Controls the lifetime of the elevated native messaging host process.
std::unique_ptr<ElevatedNativeMessagingHost> elevated_host_;
// Handle of the parent window.
intptr_t parent_window_handle_;
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
raw_ptr<extensions::NativeMessageHost::Client> client_;
std::unique_ptr<ChromotingHostContext> host_context_;
diff --git a/remoting/host/setup/me2me_native_messaging_host_main.cc b/remoting/host/setup/me2me_native_messaging_host_main.cc
index 6f849bb..2417f7f 100644
--- a/remoting/host/setup/me2me_native_messaging_host_main.cc
+++ b/remoting/host/setup/me2me_native_messaging_host_main.cc
@@ -39,17 +39,17 @@
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/transitional_url_loader_factory_owner.h"
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
#include "base/mac/scoped_nsautorelease_pool.h"
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "base/process/process_info.h"
#include "base/win/registry.h"
#include "remoting/host/pairing_registry_delegate_win.h"
#include <windows.h>
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
#if defined(USE_GLIB) && !BUILDFLAG(IS_CHROMEOS_ASH)
#include <glib-object.h>
@@ -70,10 +70,10 @@
remoting::InitHostLogging();
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
// Needed so we don't leak objects when threads are created.
base::mac::ScopedNSAutoreleasePool pool;
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
#if defined(USE_GLIB) && !BUILDFLAG(IS_CHROMEOS_ASH)
// g_type_init will be deprecated in 2.36. 2.35 is the development
@@ -111,7 +111,7 @@
scoped_refptr<DaemonController> daemon_controller =
DaemonController::Create();
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
if (command_line->HasSwitch(kCheckPermissionSwitchName)) {
int exit_code;
daemon_controller->CheckPermission(
@@ -128,7 +128,7 @@
run_loop.Run();
return exit_code;
}
-#endif // defined(OS_APPLE)
+#endif // BUILDFLAG(IS_APPLE)
// Pass handle of the native view to the controller so that the UAC prompts
// are focused properly.
@@ -146,7 +146,7 @@
base::File write_file;
bool needs_elevation = false;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
needs_elevation = !base::IsCurrentProcessElevated();
if (command_line->HasSwitch(kElevateSwitchName)) {
@@ -200,7 +200,7 @@
SetStdHandle(STD_INPUT_HANDLE, nullptr);
SetStdHandle(STD_OUTPUT_HANDLE, nullptr);
}
-#elif defined(OS_POSIX)
+#elif BUILDFLAG(IS_POSIX)
// The files will be automatically closed.
read_file = base::File(STDIN_FILENO);
write_file = base::File(STDOUT_FILENO);
@@ -221,7 +221,7 @@
// Create the pairing registry.
scoped_refptr<PairingRegistry> pairing_registry;
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
base::win::RegKey root;
LONG result = root.Open(HKEY_LOCAL_MACHINE, kPairingRegistryKeyName,
KEY_READ);
@@ -262,10 +262,10 @@
pairing_registry =
new PairingRegistry(io_thread.task_runner(), std::move(delegate));
-#else // defined(OS_WIN)
+#else // BUILDFLAG(IS_WIN)
pairing_registry =
CreatePairingRegistry(io_thread.task_runner());
-#endif // !defined(OS_WIN)
+#endif // !BUILDFLAG(IS_WIN)
std::unique_ptr<NativeMessagingPipe> native_messaging_pipe(
new NativeMessagingPipe());
@@ -274,9 +274,9 @@
std::unique_ptr<extensions::NativeMessagingChannel> channel(
new PipeMessagingChannel(std::move(read_file), std::move(write_file)));
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
PipeMessagingChannel::ReopenStdinStdout();
-#endif // defined(OS_POSIX)
+#endif // BUILDFLAG(IS_POSIX)
std::unique_ptr<ChromotingHostContext> context =
ChromotingHostContext::Create(new remoting::AutoThreadTaskRunner(
diff --git a/remoting/host/setup/start_host_main.cc b/remoting/host/setup/start_host_main.cc
index 2f1d47b..3d9c51c64 100644
--- a/remoting/host/setup/start_host_main.cc
+++ b/remoting/host/setup/start_host_main.cc
@@ -27,21 +27,21 @@
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/transitional_url_loader_factory_owner.h"
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
#include <termios.h>
#include <unistd.h>
-#endif // defined(OS_POSIX)
+#endif // BUILDFLAG(IS_POSIX)
-#if defined(OS_LINUX)
+#if BUILDFLAG(IS_LINUX)
#include "remoting/host/setup/daemon_controller_delegate_linux.h"
#include "remoting/host/setup/start_host_as_root.h"
-#endif // defined(OS_LINUX)
+#endif // BUILDFLAG(IS_LINUX)
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include "base/process/process_info.h"
#include <windows.h>
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
namespace remoting {
@@ -57,7 +57,7 @@
// Lets us hide the PIN that a user types.
void SetEcho(bool echo) {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
DWORD mode;
HANDLE console_handle = GetStdHandle(STD_INPUT_HANDLE);
if (!GetConsoleMode(console_handle, &mode)) {
@@ -75,7 +75,7 @@
term.c_lflag &= ~ECHO;
}
tcsetattr(STDIN_FILENO, TCSANOW, &term);
-#endif // !defined(OS_WIN)
+#endif // !BUILDFLAG(IS_WIN)
}
// Reads a newline-terminated string from stdin.
@@ -126,12 +126,12 @@
} // namespace
int StartHostMain(int argc, char** argv) {
-#if defined(OS_LINUX)
+#if BUILDFLAG(IS_LINUX)
// Minimize the amount of code that runs as root on Posix systems.
if (getuid() == 0) {
return remoting::StartHostAsRoot(argc, argv);
}
-#endif // defined(OS_LINUX)
+#endif // BUILDFLAG(IS_LINUX)
// google_apis::GetOAuth2ClientID/Secret need a static CommandLine.
base::CommandLine::Init(argc, argv);
@@ -163,7 +163,7 @@
// for the account which generated |code|.
std::string host_owner = command_line->GetSwitchValueASCII("host-owner");
-#if defined(OS_LINUX)
+#if BUILDFLAG(IS_LINUX)
if (command_line->HasSwitch("no-start")) {
// On Linux, registering the host with systemd and starting it is the only
// reason start_host requires root. The --no-start options skips that final
@@ -173,15 +173,15 @@
// controller code, and must be configured on the Linux delegate explicitly.
DaemonControllerDelegateLinux::set_start_host_after_setup(false);
}
-#endif // defined(OS_LINUX)
-#if defined(OS_WIN)
+#endif // BUILDFLAG(IS_LINUX)
+#if BUILDFLAG(IS_WIN)
// The tool must be run elevated on Windows so the host has access to the
// directories used to store the configuration JSON files.
if (!base::IsCurrentProcessElevated()) {
fprintf(stderr, "Error: %s must be run as an elevated process.", argv[0]);
return 1;
}
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
if (command_line->HasSwitch("help") || command_line->HasSwitch("h") ||
command_line->HasSwitch("?") || !command_line->GetArgs().empty()) {
diff --git a/remoting/host/setup/test_util.cc b/remoting/host/setup/test_util.cc
index 5b82005..153d181 100644
--- a/remoting/host/setup/test_util.cc
+++ b/remoting/host/setup/test_util.cc
@@ -5,9 +5,9 @@
#include "build/build_config.h"
#include "remoting/host/setup/test_util.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include <windows.h>
-#elif defined(OS_POSIX)
+#elif BUILDFLAG(IS_POSIX)
#include <unistd.h>
#endif
@@ -15,7 +15,7 @@
bool MakePipe(base::File* read_file,
base::File* write_file) {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
base::PlatformFile read_handle;
base::PlatformFile write_handle;
if (!CreatePipe(&read_handle, &write_handle, nullptr, 0))
@@ -23,7 +23,7 @@
*read_file = base::File(read_handle);
*write_file = base::File(write_handle);
return true;
-#elif defined(OS_POSIX)
+#elif BUILDFLAG(IS_POSIX)
int fds[2];
if (pipe(fds) == 0) {
*read_file = base::File(fds[0]);
diff --git a/remoting/host/shutdown_watchdog.cc b/remoting/host/shutdown_watchdog.cc
index f08343a..6907cab 100644
--- a/remoting/host/shutdown_watchdog.cc
+++ b/remoting/host/shutdown_watchdog.cc
@@ -9,9 +9,9 @@
#include "base/logging.h"
#include "build/build_config.h"
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
#include <unistd.h>
-#endif // defined(OS_POSIX)
+#endif // BUILDFLAG(IS_POSIX)
namespace remoting {
diff --git a/remoting/host/token_validator_base.cc b/remoting/host/token_validator_base.cc
index dbead62..12ca8d764 100644
--- a/remoting/host/token_validator_base.cc
+++ b/remoting/host/token_validator_base.cc
@@ -24,9 +24,9 @@
#include "net/ssl/client_cert_store.h"
#if defined(USE_NSS_CERTS)
#include "net/ssl/client_cert_store_nss.h"
-#elif defined(OS_WIN)
+#elif BUILDFLAG(IS_WIN)
#include "net/ssl/client_cert_store_win.h"
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
#include "net/ssl/client_cert_store_mac.h"
#endif
#include "net/ssl/ssl_cert_request_info.h"
@@ -104,7 +104,7 @@
return c1->valid_expiry() < c2->valid_expiry();
}
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
crypto::ScopedHCERTSTORE OpenLocalMachineCertStore() {
return crypto::ScopedHCERTSTORE(::CertOpenStore(
CERT_STORE_PROV_SYSTEM, 0, NULL,
@@ -209,7 +209,7 @@
#if defined(USE_NSS_CERTS)
client_cert_store = new net::ClientCertStoreNSS(
net::ClientCertStoreNSS::PasswordDelegateFactory());
-#elif defined(OS_WIN)
+#elif BUILDFLAG(IS_WIN)
// The network process is running as "Local Service" whose "Current User"
// cert store doesn't contain any certificates. Use the "Local Machine"
// store instead.
@@ -217,7 +217,7 @@
// Machine" cert store needs to allow access by "Local Service".
client_cert_store = new net::ClientCertStoreWin(
base::BindRepeating(&OpenLocalMachineCertStore));
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
client_cert_store = new net::ClientCertStoreMac();
#else
// OpenSSL does not use the ClientCertStore infrastructure.
diff --git a/remoting/host/user_setting_keys.h b/remoting/host/user_setting_keys.h
index 5de01f6..9379b6a6 100644
--- a/remoting/host/user_setting_keys.h
+++ b/remoting/host/user_setting_keys.h
@@ -10,7 +10,7 @@
namespace remoting {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// Windows settings are stored in the registry where the key and value names use
// pascal case.
@@ -18,7 +18,7 @@
constexpr UserSettingKey kWinPreviousDefaultWebBrowserProgId =
"PreviousDefaultBrowserProgId";
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
} // namespace remoting
diff --git a/remoting/host/webauthn/remote_webauthn_main.cc b/remoting/host/webauthn/remote_webauthn_main.cc
index b4277b1..3b8dcbc 100644
--- a/remoting/host/webauthn/remote_webauthn_main.cc
+++ b/remoting/host/webauthn/remote_webauthn_main.cc
@@ -21,9 +21,9 @@
#include "remoting/host/native_messaging/pipe_messaging_channel.h"
#include "remoting/host/webauthn/remote_webauthn_native_messaging_host.h"
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
#include <windows.h>
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
namespace remoting {
@@ -46,10 +46,10 @@
base::File read_file;
base::File write_file;
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
read_file = base::File(STDIN_FILENO);
write_file = base::File(STDOUT_FILENO);
-#elif defined(OS_WIN)
+#elif BUILDFLAG(IS_WIN)
// GetStdHandle() returns pseudo-handles for stdin and stdout even if
// the hosting executable specifies "Windows" subsystem. However the
// returned handles are invalid in that case unless standard input and
@@ -75,9 +75,9 @@
auto channel = std::make_unique<PipeMessagingChannel>(std::move(read_file),
std::move(write_file));
-#if defined(OS_POSIX)
+#if BUILDFLAG(IS_POSIX)
PipeMessagingChannel::ReopenStdinStdout();
-#endif // defined(OS_POSIX)
+#endif // BUILDFLAG(IS_POSIX)
auto native_messaging_host =
std::make_unique<RemoteWebAuthnNativeMessagingHost>(task_runner);
diff --git a/remoting/protocol/connection_unittest.cc b/remoting/protocol/connection_unittest.cc
index e1cd6a16..1e8b2b39 100644
--- a/remoting/protocol/connection_unittest.cc
+++ b/remoting/protocol/connection_unittest.cc
@@ -482,7 +482,7 @@
}
// crbug.com/1224862: Tests are flaky on Mac.
-#if defined(OS_MAC)
+#if BUILDFLAG(IS_MAC)
#define MAYBE_Disconnect DISABLED_Disconnect
#else
#define MAYBE_Disconnect Disconnect
@@ -499,7 +499,7 @@
}
// crbug.com/1224862: Tests are flaky on Mac.
-#if defined(OS_MAC)
+#if BUILDFLAG(IS_MAC)
#define MAYBE_Control DISABLED_Control
#else
#define MAYBE_Control Control
@@ -523,7 +523,7 @@
}
// crbug.com/1224862: Tests are flaky on Mac.
-#if defined(OS_MAC)
+#if BUILDFLAG(IS_MAC)
#define MAYBE_Events DISABLED_Events
#else
#define MAYBE_Events Events
@@ -547,7 +547,7 @@
}
// crbug.com/1224862: Tests are flaky on Mac.
-#if defined(OS_MAC)
+#if BUILDFLAG(IS_MAC)
#define MAYBE_Video DISABLED_Video
#else
#define MAYBE_Video Video
@@ -566,7 +566,7 @@
}
// crbug.com/1224862: Tests are flaky on Mac.
-#if defined(OS_MAC)
+#if BUILDFLAG(IS_MAC)
#define MAYBE_VideoWithSlowSignaling DISABLED_VideoWithSlowSignaling
#else
#define MAYBE_VideoWithSlowSignaling VideoWithSlowSignaling
@@ -588,7 +588,7 @@
}
// crbug.com/1224862: Tests are flaky on Mac.
-#if defined(OS_MAC)
+#if BUILDFLAG(IS_MAC)
#define MAYBE_DestroyOnIncomingMessage DISABLED_DestroyOnIncomingMessage
#else
#define MAYBE_DestroyOnIncomingMessage DestroyOnIncomingMessage
@@ -669,9 +669,9 @@
// Slow/fails on Linux ASan/TSan (crbug.com/1045344) and flaky on Mac
// (crbug.com/1237376).
-#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && \
+#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && \
(defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER)) || \
- defined(OS_MAC)
+ BUILDFLAG(IS_MAC)
#define MAYBE_Audio DISABLED_Audio
#else
#define MAYBE_Audio Audio
diff --git a/remoting/protocol/ice_connection_to_client.cc b/remoting/protocol/ice_connection_to_client.cc
index 5dc54343..6fc254d5 100644
--- a/remoting/protocol/ice_connection_to_client.cc
+++ b/remoting/protocol/ice_connection_to_client.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
+#include "build/build_config.h"
#include "net/base/io_buffer.h"
#include "remoting/codec/audio_encoder.h"
#include "remoting/codec/audio_encoder_opus.h"
@@ -32,7 +33,7 @@
std::unique_ptr<AudioEncoder> CreateAudioEncoder(
const protocol::SessionConfig& config) {
-#if defined(OS_IOS)
+#if BUILDFLAG(IS_IOS)
// TODO(nicholss): iOS should not use Opus. This is to prevent us from
// depending on //media. In the future we will use webrtc for connection
// and this will be a non-issue.
diff --git a/remoting/protocol/ice_transport_unittest.cc b/remoting/protocol/ice_transport_unittest.cc
index 6310b3e0..1a9e41a 100644
--- a/remoting/protocol/ice_transport_unittest.cc
+++ b/remoting/protocol/ice_transport_unittest.cc
@@ -213,7 +213,7 @@
};
// crbug.com/1224862: Tests are flaky on Mac.
-#if defined(OS_MAC)
+#if BUILDFLAG(IS_MAC)
#define MAYBE_DataStream DISABLED_DataStream
#else
#define MAYBE_DataStream DataStream
@@ -237,7 +237,7 @@
}
// crbug.com/1224862: Tests are flaky on Mac.
-#if defined(OS_MAC)
+#if BUILDFLAG(IS_MAC)
#define MAYBE_MuxDataStream DISABLED_MuxDataStream
#else
#define MAYBE_MuxDataStream MuxDataStream
@@ -261,7 +261,7 @@
}
// crbug.com/1224862: Tests are flaky on Mac.
-#if defined(OS_MAC)
+#if BUILDFLAG(IS_MAC)
#define MAYBE_FailedChannelAuth DISABLED_FailedChannelAuth
#else
#define MAYBE_FailedChannelAuth FailedChannelAuth
@@ -341,7 +341,7 @@
}
// crbug.com/1224862: Tests are flaky on Mac.
-#if defined(OS_MAC)
+#if BUILDFLAG(IS_MAC)
#define MAYBE_TestDelayedSignaling DISABLED_TestDelayedSignaling
#else
#define MAYBE_TestDelayedSignaling TestDelayedSignaling
diff --git a/remoting/protocol/webrtc_transport_unittest.cc b/remoting/protocol/webrtc_transport_unittest.cc
index 7044c26..d8f41c783 100644
--- a/remoting/protocol/webrtc_transport_unittest.cc
+++ b/remoting/protocol/webrtc_transport_unittest.cc
@@ -370,7 +370,7 @@
};
// crbug.com/1224862: Tests are flaky on Mac.
-#if defined(OS_MAC)
+#if BUILDFLAG(IS_MAC)
#define MAYBE_Connects DISABLED_Connects
#else
#define MAYBE_Connects Connects
@@ -393,7 +393,7 @@
}
// crbug.com/1224862: Tests are flaky on Mac.
-#if defined(OS_MAC)
+#if BUILDFLAG(IS_MAC)
#define MAYBE_DataStream DISABLED_DataStream
#else
#define MAYBE_DataStream DataStream
@@ -430,7 +430,7 @@
}
// crbug.com/1224862: Tests are flaky on Mac.
-#if defined(OS_MAC)
+#if BUILDFLAG(IS_MAC)
#define MAYBE_DataStreamLate DISABLED_DataStreamLate
#else
#define MAYBE_DataStreamLate DataStreamLate
@@ -452,7 +452,7 @@
}
// crbug.com/1224862: Tests are flaky on Mac.
-#if defined(OS_MAC)
+#if BUILDFLAG(IS_MAC)
#define MAYBE_TerminateDataChannel DISABLED_TerminateDataChannel
#else
#define MAYBE_TerminateDataChannel TerminateDataChannel
@@ -491,7 +491,7 @@
}
// crbug.com/1224862: Tests are flaky on Mac.
-#if defined(OS_MAC)
+#if BUILDFLAG(IS_MAC)
#define MAYBE_ThreadJoinBlockedDuringConnectionTeardown_WatchdogFired \
DISABLED_ThreadJoinBlockedDuringConnectionTeardown_WatchdogFired
#else
diff --git a/remoting/signaling/ftl_host_device_id_provider.cc b/remoting/signaling/ftl_host_device_id_provider.cc
index db4d6b1..15e3feb 100644
--- a/remoting/signaling/ftl_host_device_id_provider.cc
+++ b/remoting/signaling/ftl_host_device_id_provider.cc
@@ -11,13 +11,13 @@
namespace {
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
constexpr char kDeviceIdPrefix[] = "crd-win-host-";
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
constexpr char kDeviceIdPrefix[] = "crd-mac-host-";
#elif BUILDFLAG(IS_CHROMEOS_ASH)
constexpr char kDeviceIdPrefix[] = "crd-cros-host-";
-#elif defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
+#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
constexpr char kDeviceIdPrefix[] = "crd-linux-host-";
#else
constexpr char kDeviceIdPrefix[] = "crd-unknown-host-";
diff --git a/remoting/signaling/ftl_services_context.cc b/remoting/signaling/ftl_services_context.cc
index 8a49221..9267f5d 100644
--- a/remoting/signaling/ftl_services_context.cc
+++ b/remoting/signaling/ftl_services_context.cc
@@ -89,9 +89,9 @@
client_info->set_version_minor(VERSION_BUILD);
client_info->set_version_point(VERSION_PATCH);
ftl::Platform_Type platform_type;
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
platform_type = ftl::Platform_Type_FTL_ANDROID;
-#elif defined(OS_IOS)
+#elif BUILDFLAG(IS_IOS)
platform_type = ftl::Platform_Type_FTL_IOS;
#else
platform_type = ftl::Platform_Type_FTL_DESKTOP;
diff --git a/remoting/test/it2me_cli_host_main.cc b/remoting/test/it2me_cli_host_main.cc
index de55256c3..9552e22 100644
--- a/remoting/test/it2me_cli_host_main.cc
+++ b/remoting/test/it2me_cli_host_main.cc
@@ -12,9 +12,9 @@
#include "remoting/host/resources.h"
#include "remoting/test/it2me_cli_host.h"
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include "base/linux_util.h"
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
int main(int argc, char const* argv[]) {
base::AtExitManager exitManager;
@@ -25,11 +25,11 @@
return 0;
}
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// Need to prime the host OS version value for linux to prevent IO on the
// network thread. base::GetLinuxDistro() caches the result.
base::GetLinuxDistro();
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
base::SingleThreadTaskExecutor io_task_executor(base::MessagePumpType::IO);
remoting::It2MeCliHost cli_host;
diff --git a/remoting/test/it2me_standalone_host.cc b/remoting/test/it2me_standalone_host.cc
index d0798d2c..00cf3be 100644
--- a/remoting/test/it2me_standalone_host.cc
+++ b/remoting/test/it2me_standalone_host.cc
@@ -15,6 +15,7 @@
#include "base/memory/ref_counted.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
+#include "build/build_config.h"
#include "remoting/base/auto_thread_task_runner.h"
#include "remoting/host/chromoting_host_context.h"
#include "remoting/host/host_extension.h"
@@ -50,7 +51,7 @@
context_->ui_task_runner()),
connection_(base::WrapUnique(new testing::NiceMock<MockSession>())),
session_jid_(kSessionJid),
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// We cannot support audio capturing for linux, since a pipe name is
// needed to initialize AudioCapturerLinux.
config_(protocol::SessionConfig::ForTest()),
diff --git a/remoting/test/it2me_standalone_host_main.cc b/remoting/test/it2me_standalone_host_main.cc
index 57f773f..ac6f33e 100644
--- a/remoting/test/it2me_standalone_host_main.cc
+++ b/remoting/test/it2me_standalone_host_main.cc
@@ -5,23 +5,24 @@
#include "base/at_exit.h"
#include "base/check_op.h"
#include "base/command_line.h"
+#include "build/build_config.h"
#include "remoting/host/resources.h"
#include "remoting/proto/event.pb.h"
#include "remoting/test/it2me_standalone_host.h"
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include <gtk/gtk.h>
#include "base/linux_util.h"
#include "ui/events/platform/x11/x11_event_source.h"
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
int main(int argc, const char** argv) {
base::AtExitManager at_exit_manager;
base::CommandLine::Init(argc, argv);
remoting::test::It2MeStandaloneHost host;
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// Create an X11EventSource so the global X11 connection
// (x11::Connection::Get()) can dispatch X events.
auto event_source =
@@ -39,7 +40,7 @@
// Need to prime the host OS version value for linux to prevent IO on the
// network thread. base::GetLinuxDistro() caches the result.
base::GetLinuxDistro();
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
remoting::LoadResources("");
host.StartOutputTimer();
host.Run();