Convert defined(OS_XXX) to BUILDFLAG(IS_XXX) in libcef

See https://crbug.com/1234043 for background.
This commit is contained in:
Marshall Greenblatt
2022-01-24 12:58:02 -05:00
parent 7b0bb931b1
commit ebde595370
68 changed files with 280 additions and 282 deletions

View File

@@ -48,11 +48,11 @@
#include "ui/base/ui_base_paths.h"
#include "ui/base/ui_base_switches.h"
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include "libcef/common/util_mac.h"
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "ui/base/resource/resource_bundle_win.h"
#endif
@@ -74,7 +74,7 @@ AlloyMainDelegate::AlloyMainDelegate(CefMainRunnerHandler* runner,
extern void base_impl_stub();
base_impl_stub();
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
resource_util::OverrideAssetPath();
#endif
}
@@ -90,7 +90,7 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) {
std::string process_type =
command_line->GetSwitchValueASCII(switches::kProcessType);
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
// Read the crash configuration file. Platforms using Breakpad also add a
// command-line switch. On Windows this is done from chrome_elf.
crash_reporting::BasicStartupComplete(command_line);
@@ -117,7 +117,7 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) {
command_line->AppendSwitchPath(switches::kBrowserSubprocessPath,
file_path);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// The sandbox is not supported when using a separate subprocess
// executable on Windows.
no_sandbox = true;
@@ -125,7 +125,7 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) {
}
}
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
if (settings_->framework_dir_path.length > 0) {
base::FilePath file_path =
base::FilePath(CefString(&settings_->framework_dir_path));
@@ -243,7 +243,7 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) {
base::NumberToString(settings_->uncaught_exception_stack_size));
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
std::vector<std::string> disable_features;
if (features::kCalculateNativeWinOcclusion.default_state ==
@@ -271,7 +271,7 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) {
command_line->AppendSwitchASCII(switches::kDisableFeatures,
disable_features_str);
}
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
}
if (application_) {
@@ -335,7 +335,7 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) {
content::SetContentClient(&content_client_);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
util_mac::BasicStartupComplete();
#endif
@@ -350,7 +350,7 @@ void AlloyMainDelegate::PreSandboxStartup() {
if (process_type.empty()) {
// Only override these paths when executing the main process.
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
util_mac::PreSandboxStartup();
#endif
@@ -395,7 +395,7 @@ void AlloyMainDelegate::ProcessExiting(const std::string& process_type) {
ui::ResourceBundle::CleanupSharedInstance();
}
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
void AlloyMainDelegate::ZygoteForked() {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
const std::string& process_type =
@@ -505,7 +505,7 @@ void AlloyMainDelegate::InitializeResourceBundle() {
base::PathService::Override(ui::DIR_LOCALES, locales_dir);
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// From chrome/app/chrome_main_delegate.cc
// Throbber icons and cursors are still stored in chrome.dll,
// this can be killed once those are merged into resources.pak. See

View File

@@ -51,7 +51,7 @@ class AlloyMainDelegate : public content::ContentMainDelegate,
const std::string& process_type,
content::MainFunctionParams main_function_params) override;
void ProcessExiting(const std::string& process_type) override;
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
void ZygoteForked() override;
#endif
content::ContentBrowserClient* CreateContentBrowserClient() override;

View File

@@ -13,7 +13,7 @@
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/common/content_switches.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#include "base/path_service.h"
#endif
@@ -90,7 +90,7 @@ void CefAppManager::AddAdditionalSchemes(
scheme_info_list_locked_ = true;
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
const wchar_t* CefAppManager::GetResourceDllName() {
static wchar_t file_path[MAX_PATH + 1] = {0};
@@ -106,4 +106,4 @@ const wchar_t* CefAppManager::GetResourceDllName() {
return file_path;
}
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)

View File

@@ -54,7 +54,7 @@ class CefAppManager {
const CefRequestContextSettings& settings,
base::OnceClosure initialized_cb) = 0;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Returns the module name (usually libcef.dll).
const wchar_t* GetResourceDllName();
#endif

View File

@@ -12,7 +12,7 @@
#include "base/threading/platform_thread.h"
#include "base/trace_event/trace_event.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "base/win/win_util.h"
#endif
@@ -341,7 +341,7 @@ CEF_EXPORT cef_platform_thread_id_t cef_get_current_platform_thread_id() {
CEF_EXPORT cef_platform_thread_handle_t
cef_get_current_platform_thread_handle() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
return base::PlatformThread::CurrentId();
#else
return base::PlatformThread::CurrentHandle().platform_handle();
@@ -349,7 +349,7 @@ cef_get_current_platform_thread_handle() {
}
void CefEnableHighDPISupport() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
base::win::EnableHighDPISupport();
#endif
}

View File

@@ -131,13 +131,13 @@ const char kUserAgentProductAndVersion[] = "user-agent-product";
const char kDisableRequestHandlingForTesting[] =
"disable-request-handling-for-testing";
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// Path to the framework directory.
const char kFrameworkDirPath[] = "framework-dir-path";
const char kMainBundlePath[] = "main-bundle-path";
#endif
#if !defined(OS_WIN)
#if !BUILDFLAG(IS_WIN)
// Renderer process that runs the non-PPAPI PDF plugin.
// This is defined in content/public/common/content_switches.h for Windows.
const char kPdfRenderer[] = "pdf-renderer";

View File

@@ -57,12 +57,12 @@ extern const char kDisableChromeLoginPrompt[];
extern const char kUserAgentProductAndVersion[];
extern const char kDisableRequestHandlingForTesting[];
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
extern const char kFrameworkDirPath[];
extern const char kMainBundlePath[];
#endif
#if !defined(OS_WIN)
#if !BUILDFLAG(IS_WIN)
extern const char kPdfRenderer[];
#endif

View File

@@ -23,7 +23,7 @@
#include "third_party/blink/public/common/switches.h"
#include "ui/base/ui_base_switches.h"
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include "libcef/common/util_mac.h"
#endif
@@ -41,7 +41,7 @@ ChromeMainDelegateCef::ChromeMainDelegateCef(CefMainRunnerHandler* runner,
runner_(runner),
settings_(settings),
application_(application) {
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
resource_util::OverrideAssetPath();
#endif
}
@@ -56,7 +56,7 @@ bool ChromeMainDelegateCef::BasicStartupComplete(int* exit_code) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
// Read the crash configuration file. Platforms using Breakpad also add a
// command-line switch. On Windows this is done from chrome_elf.
crash_reporting::BasicStartupComplete(command_line);
@@ -129,7 +129,7 @@ bool ChromeMainDelegateCef::BasicStartupComplete(int* exit_code) {
ignore_result(commandLinePtr->Detach(nullptr));
}
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
util_mac::BasicStartupComplete();
#endif
@@ -142,11 +142,11 @@ void ChromeMainDelegateCef::PreSandboxStartup() {
const std::string& process_type =
command_line->GetSwitchValueASCII(switches::kProcessType);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
if (process_type.empty()) {
util_mac::PreSandboxStartup();
}
#endif // defined(OS_MAC)
#endif // BUILDFLAG(IS_MAC)
// Since this may be configured via CefSettings we override the value on
// all platforms. We can't use the default implementation on macOS because
@@ -180,7 +180,7 @@ ChromeMainDelegateCef::RunProcess(
std::move(main_function_params));
}
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
void ChromeMainDelegateCef::ZygoteForked() {
ChromeMainDelegate::ZygoteForked();
@@ -191,7 +191,7 @@ void ChromeMainDelegateCef::ZygoteForked() {
// Initialize crash reporting state for the newly forked process.
crash_reporting::ZygoteForked(command_line, process_type);
}
#endif // defined(OS_LINUX)
#endif // BUILDFLAG(IS_LINUX)
content::ContentClient* ChromeMainDelegateCef::CreateContentClient() {
return &chrome_content_client_cef_;

View File

@@ -42,7 +42,7 @@ class ChromeMainDelegateCef : public ChromeMainDelegate,
absl::variant<int, content::MainFunctionParams> RunProcess(
const std::string& process_type,
content::MainFunctionParams main_function_params) override;
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
void ZygoteForked() override;
#endif
content::ContentClient* CreateContentClient() override;

View File

@@ -33,7 +33,7 @@ ChromeMainRunnerDelegate::GetContentMainDelegate() {
void ChromeMainRunnerDelegate::BeforeMainThreadInitialize(
const CefMainArgs& args) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
base::CommandLine::Init(0, nullptr);
#else
base::CommandLine::Init(args.argc, args.argv);

View File

@@ -33,7 +33,7 @@ CefRefPtr<CefCommandLine> CefCommandLineImpl::Copy() {
}
void CefCommandLineImpl::InitFromArgv(int argc, const char* const* argv) {
#if !defined(OS_WIN)
#if !BUILDFLAG(IS_WIN)
CEF_VALUE_VERIFY_RETURN_VOID(true);
mutable_value()->InitFromArgv(argc, argv);
#else
@@ -42,7 +42,7 @@ void CefCommandLineImpl::InitFromArgv(int argc, const char* const* argv) {
}
void CefCommandLineImpl::InitFromString(const CefString& command_line) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
CEF_VALUE_VERIFY_RETURN_VOID(true);
const std::wstring& str16 = command_line;
mutable_value()->ParseFromString(str16);
@@ -116,7 +116,7 @@ void CefCommandLineImpl::AppendSwitch(const CefString& name) {
void CefCommandLineImpl::AppendSwitchWithValue(const CefString& name,
const CefString& value) {
CEF_VALUE_VERIFY_RETURN_VOID(true);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
mutable_value()->AppendSwitchNative(name.ToString(), value.ToWString());
#else
mutable_value()->AppendSwitchNative(name.ToString(), value.ToString());
@@ -138,7 +138,7 @@ void CefCommandLineImpl::GetArguments(ArgumentList& arguments) {
void CefCommandLineImpl::AppendArgument(const CefString& argument) {
CEF_VALUE_VERIFY_RETURN_VOID(true);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
mutable_value()->AppendArgNative(argument.ToWString());
#else
mutable_value()->AppendArgNative(argument.ToString());
@@ -147,7 +147,7 @@ void CefCommandLineImpl::AppendArgument(const CefString& argument) {
void CefCommandLineImpl::PrependWrapper(const CefString& wrapper) {
CEF_VALUE_VERIFY_RETURN_VOID(true);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
mutable_value()->PrependWrapper(wrapper.ToWString());
#else
mutable_value()->PrependWrapper(wrapper.ToString());

View File

@@ -6,7 +6,7 @@
#include <utility>
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
@@ -22,11 +22,11 @@
#include "content/public/common/content_switches.h"
#include "third_party/crashpad/crashpad/client/annotation.h"
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include "libcef/common/util_mac.h"
#endif
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
// Don't use CommandLine, FilePath or PathService on Windows. FilePath has
// dependencies outside of kernel32, which is disallowed by chrome_elf.
// CommandLine and PathService depend on global state that will not be
@@ -38,12 +38,12 @@
#include "chrome/common/chrome_paths.h"
#endif
#if defined(OS_POSIX) && !defined(OS_MAC)
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
#include "content/public/common/content_switches.h"
#include "libcef/common/cef_crash_report_utils.h"
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "base/debug/leak_annotations.h"
#include "chrome/install_static/install_util.h"
#include "components/crash/core/app/crashpad.h"
@@ -51,7 +51,7 @@
namespace {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
using PathString = std::wstring;
const char kPathSep = '\\';
#else
@@ -59,7 +59,7 @@ using PathString = std::string;
#endif
PathString GetCrashConfigPath() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Start with the path to the running executable.
wchar_t module_path[MAX_PATH];
if (GetModuleFileName(nullptr, module_path, MAX_PATH) == 0)
@@ -75,10 +75,10 @@ PathString GetCrashConfigPath() {
config_path += L"crash_reporter.cfg";
return config_path;
#elif defined(OS_POSIX)
#elif BUILDFLAG(IS_POSIX)
base::FilePath config_path;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// Start with the path to the main app Resources directory. May be empty if
// not running in an app bundle.
config_path = util_mac::GetMainResourcesDirectory();
@@ -91,10 +91,10 @@ PathString GetCrashConfigPath() {
}
return config_path.Append(FILE_PATH_LITERAL("crash_reporter.cfg")).value();
#endif // defined(OS_POSIX)
#endif // BUILDFLAG(IS_POSIX)
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// On Windows, FAT32 and NTFS both limit filenames to a maximum of 255
// characters. On POSIX systems, the typical filename length limit is 255
@@ -229,7 +229,7 @@ std::string joinPath(const std::string& s1, const std::string& s2) {
// This will only be non-nullptr in the chrome_elf address space.
CefCrashReporterClient* g_crash_reporter_client = nullptr;
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
const char kKeyMapDelim = ',';
@@ -267,7 +267,7 @@ int ParseZeroBasedInt(const std::string& value) {
} // namespace
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
extern "C" {
@@ -359,7 +359,7 @@ bool CefCrashReporterClient::ReadCrashConfigFile() {
if (config_path.empty())
return false;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
FILE* fp = _wfopen(config_path.c_str(), L"r");
#else
FILE* fp = fopen(config_path.c_str(), "r");
@@ -427,7 +427,7 @@ bool CefCrashReporterClient::ReadCrashConfigFile() {
} else if (name_str == "MaxDatabaseAgeInDays") {
max_db_age_ = ParseZeroBasedInt(val_str);
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
else if (name_str == "ExternalHandler") {
if (!val_str.empty())
external_handler_ = sanitizePath(val_str);
@@ -438,7 +438,7 @@ bool CefCrashReporterClient::ReadCrashConfigFile() {
app_name_ = val_str;
}
}
#elif defined(OS_MAC)
#elif BUILDFLAG(IS_MAC)
else if (name_str == "BrowserCrashForwardingEnabled") {
enable_browser_crash_forwarding_ = ParseBool(val_str);
}
@@ -533,7 +533,7 @@ bool CefCrashReporterClient::HasCrashConfigFile() const {
return has_crash_config_file_;
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// static
void CefCrashReporterClient::InitializeCrashReportingForProcess() {
@@ -600,7 +600,7 @@ bool CefCrashReporterClient::GetCrashMetricsLocation(
return GetDefaultUserDataDirectory(metrics_dir, base::UTF8ToWide(app_name_));
}
#elif defined(OS_POSIX)
#elif BUILDFLAG(IS_POSIX)
void CefCrashReporterClient::GetProductNameAndVersion(const char** product_name,
const char** version) {
@@ -615,7 +615,7 @@ void CefCrashReporterClient::GetProductNameAndVersion(std::string* product_name,
*version = product_version_;
}
#if !defined(OS_MAC)
#if !BUILDFLAG(IS_MAC)
base::FilePath CefCrashReporterClient::GetReporterLogFilename() {
return base::FilePath(FILE_PATH_LITERAL("uploads.log"));
@@ -629,7 +629,7 @@ bool CefCrashReporterClient::EnableBreakpadForProcess(
process_type == switches::kGpuProcess;
}
#endif // !defined(OS_MAC)
#endif // !BUILDFLAG(IS_MAC)
bool CefCrashReporterClient::GetCrashDumpLocation(base::FilePath* crash_dir) {
// By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate
@@ -644,7 +644,7 @@ bool CefCrashReporterClient::GetCrashDumpLocation(base::FilePath* crash_dir) {
return base::PathService::Get(chrome::DIR_CRASH_DUMPS, crash_dir);
}
#endif // !defined(OS_POSIX)
#endif // !BUILDFLAG(IS_POSIX)
bool CefCrashReporterClient::GetCollectStatsConsent() {
return true;
@@ -654,7 +654,7 @@ bool CefCrashReporterClient::GetCollectStatsInSample() {
return true;
}
#if defined(OS_WIN) || defined(OS_MAC)
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
bool CefCrashReporterClient::ReportingIsEnforcedByPolicy(
bool* crashpad_enabled) {
*crashpad_enabled = true;
@@ -662,7 +662,7 @@ bool CefCrashReporterClient::ReportingIsEnforcedByPolicy(
}
#endif
#if defined(OS_POSIX) && !defined(OS_MAC)
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
bool CefCrashReporterClient::IsRunningUnattended() {
// Crash upload will only be enabled with Breakpad on Linux if this method
// returns false.
@@ -697,7 +697,7 @@ void CefCrashReporterClient::GetCrashOptionalArguments(
}
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
std::wstring CefCrashReporterClient::GetCrashExternalHandler(
const std::wstring& exe_dir) {
@@ -713,15 +713,15 @@ bool CefCrashReporterClient::HasCrashExternalHandler() const {
return !external_handler_.empty();
}
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
bool CefCrashReporterClient::EnableBrowserCrashForwarding() {
return enable_browser_crash_forwarding_;
}
#endif
#if defined(OS_POSIX) && !defined(OS_MAC)
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
CefCrashReporterClient::ParameterMap CefCrashReporterClient::FilterParameters(
const ParameterMap& parameters) {
return crash_report_utils::FilterParameters(parameters);

View File

@@ -37,7 +37,7 @@ class CefCrashReporterClient : public crash_reporter::CrashReporterClient {
bool ReadCrashConfigFile();
bool HasCrashConfigFile() const;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Called from chrome_elf (chrome_elf/crash/crash_helper.cc) to instantiate
// a process wide instance of CefCrashReporterClient and initialize crash
// reporting for the process. The instance is leaked.
@@ -54,43 +54,43 @@ class CefCrashReporterClient : public crash_reporter::CrashReporterClient {
std::wstring* channel_name) override;
bool GetCrashDumpLocation(std::wstring* crash_dir) override;
bool GetCrashMetricsLocation(std::wstring* metrics_dir) override;
#elif defined(OS_POSIX)
#elif BUILDFLAG(IS_POSIX)
void GetProductNameAndVersion(const char** product_name,
const char** version) override;
void GetProductNameAndVersion(std::string* product_name,
std::string* version,
std::string* channel) override;
#if !defined(OS_MAC)
#if !BUILDFLAG(IS_MAC)
base::FilePath GetReporterLogFilename() override;
bool EnableBreakpadForProcess(const std::string& process_type) override;
#endif
bool GetCrashDumpLocation(base::FilePath* crash_dir) override;
#endif // defined(OS_POSIX)
#endif // BUILDFLAG(IS_POSIX)
// All of these methods must return true to enable crash report upload.
bool GetCollectStatsConsent() override;
bool GetCollectStatsInSample() override;
#if defined(OS_WIN) || defined(OS_MAC)
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
bool ReportingIsEnforcedByPolicy(bool* crashpad_enabled) override;
#endif
#if defined(OS_POSIX) && !defined(OS_MAC)
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
bool IsRunningUnattended() override;
#endif
std::string GetUploadUrl() override;
void GetCrashOptionalArguments(std::vector<std::string>* arguments) override;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
std::wstring GetCrashExternalHandler(const std::wstring& exe_dir) override;
bool HasCrashExternalHandler() const;
#endif
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
bool EnableBrowserCrashForwarding() override;
#endif
#if defined(OS_POSIX) && !defined(OS_MAC)
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
ParameterMap FilterParameters(const ParameterMap& parameters) override;
#endif
@@ -120,12 +120,12 @@ class CefCrashReporterClient : public crash_reporter::CrashReporterClient {
std::string product_name_ = "cef";
std::string product_version_ = CEF_VERSION;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
std::string app_name_ = "CEF";
std::string external_handler_;
#endif
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
bool enable_browser_crash_forwarding_ = false;
#endif
};

View File

@@ -20,19 +20,19 @@
#include "components/crash/core/common/crash_keys.h"
#include "content/public/common/content_switches.h"
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include "base/mac/foundation_util.h"
#include "components/crash/core/app/crashpad.h"
#include "components/crash/core/common/crash_keys.h"
#include "content/public/common/content_paths.h"
#endif
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
#include "base/lazy_instance.h"
#include "libcef/common/crash_reporter_client.h"
#endif
#if defined(OS_POSIX) && !defined(OS_MAC)
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
#include "components/crash/core/app/breakpad_linux.h"
#include "v8/include/v8-wasm-trap-handler-posix.h"
#endif
@@ -41,7 +41,7 @@ namespace crash_reporting {
namespace {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
const base::FilePath::CharType kChromeElfDllName[] =
FILE_PATH_LITERAL("chrome_elf.dll");
@@ -84,11 +84,11 @@ bool IsCrashReportingEnabledTrampoline() {
return false;
}
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
bool g_crash_reporting_enabled = false;
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
base::LazyInstance<CefCrashReporterClient>::Leaky g_crash_reporter_client =
LAZY_INSTANCE_INITIALIZER;
@@ -100,7 +100,7 @@ void InitCrashReporter(const base::CommandLine& command_line,
crash_reporter::SetCrashReporterClient(crash_client);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// TODO(mark): Right now, InitializeCrashpad() needs to be called after
// CommandLine::Init() and configuration of chrome::DIR_CRASH_DUMPS. Ideally,
// Crashpad initialization could occur sooner, preferably even before the
@@ -130,7 +130,7 @@ void InitCrashReporter(const base::CommandLine& command_line,
}
g_crash_reporting_enabled = true;
#else // !defined(OS_MAC)
#else // !BUILDFLAG(IS_MAC)
if (process_type != switches::kZygoteProcess) {
// Crash reporting for subprocesses created using the zygote will be
@@ -139,9 +139,9 @@ void InitCrashReporter(const base::CommandLine& command_line,
g_crash_reporting_enabled = true;
}
#endif // !defined(OS_MAC)
#endif // !BUILDFLAG(IS_MAC)
}
#endif // defined(OS_POSIX)
#endif // BUILDFLAG(IS_POSIX)
// Used to exclude command-line flags from crash reporting.
bool IsBoringCEFSwitch(const std::string& flag) {
@@ -183,19 +183,19 @@ bool SetCrashKeyValue(const base::StringPiece& key,
if (!g_crash_reporting_enabled)
return false;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
return SetCrashKeyValueTrampoline(key, value);
#else
return g_crash_reporter_client.Pointer()->SetCrashKeyValue(key, value);
#endif
}
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
// Be aware that logging is not initialized at the time this method is called.
void BasicStartupComplete(base::CommandLine* command_line) {
CefCrashReporterClient* crash_client = g_crash_reporter_client.Pointer();
if (crash_client->ReadCrashConfigFile()) {
#if !defined(OS_MAC)
#if !BUILDFLAG(IS_MAC)
// Breakpad requires this switch.
command_line->AppendSwitch(switches::kEnableCrashReporter);
@@ -207,11 +207,11 @@ void BasicStartupComplete(base::CommandLine* command_line) {
void PreSandboxStartup(const base::CommandLine& command_line,
const std::string& process_type) {
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
// Initialize crash reporting here on macOS and Linux. Crash reporting on
// Windows is initialized from context.cc.
InitCrashReporter(command_line, process_type);
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
g_crash_reporting_enabled = IsCrashReportingEnabledTrampoline();
#endif
@@ -227,7 +227,7 @@ void PreSandboxStartup(const base::CommandLine& command_line,
crash_keys::SetSwitchesFromCommandLine(command_line, &IsBoringCEFSwitch);
}
#if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MAC)
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC)
void ZygoteForked(base::CommandLine* command_line,
const std::string& process_type) {
CefCrashReporterClient* crash_client = g_crash_reporter_client.Pointer();

View File

@@ -22,14 +22,14 @@ bool SetCrashKeyValue(const base::StringPiece& key,
// Functions are called from similarly named methods in AlloyMainDelegate.
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
void BasicStartupComplete(base::CommandLine* command_line);
#endif
void PreSandboxStartup(const base::CommandLine& command_line,
const std::string& process_type);
#if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MAC)
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC)
void ZygoteForked(base::CommandLine* command_line,
const std::string& process_type);
#endif

View File

@@ -25,7 +25,7 @@ bool PdfExtensionEnabled() {
}
bool PrintPreviewEnabled() {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// Not currently supported on macOS.
return false;
#else

View File

@@ -4,7 +4,7 @@
#include "libcef/common/resource_util.h"
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
#include <dlfcn.h>
#endif
@@ -21,17 +21,17 @@
#include "chrome/common/chrome_switches.h"
#include "ui/base/layout.h"
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include "base/mac/foundation_util.h"
#include "libcef/common/util_mac.h"
#endif
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
#include "base/environment.h"
#include "base/nix/xdg_util.h"
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "base/win/registry.h"
#endif
@@ -39,7 +39,7 @@ namespace resource_util {
namespace {
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
// Based on chrome/common/chrome_paths_linux.cc.
// See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
@@ -53,7 +53,7 @@ bool GetDefaultUserDataDirectory(base::FilePath* result) {
return true;
}
#elif defined(OS_MAC)
#elif BUILDFLAG(IS_MAC)
// Based on chrome/common/chrome_paths_mac.mm.
bool GetDefaultUserDataDirectory(base::FilePath* result) {
@@ -64,7 +64,7 @@ bool GetDefaultUserDataDirectory(base::FilePath* result) {
return true;
}
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
// Based on chrome/common/chrome_paths_win.cc.
bool GetDefaultUserDataDirectory(base::FilePath* result) {
@@ -116,7 +116,7 @@ base::FilePath GetUserDataPath(CefSettings* settings,
// to the desktop on any platform.
// From chrome/browser/download/download_prefs.cc.
bool DownloadPathIsDangerous(const base::FilePath& download_path) {
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
base::FilePath home_dir = base::GetHomeDir();
if (download_path == home_dir) {
return true;
@@ -142,7 +142,7 @@ bool GetDefaultDownloadSafeDirectory(base::FilePath* result) {
return false;
if (DownloadPathIsDangerous(*result)) {
#if defined(OS_WIN) || defined(OS_LINUX)
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
// Explicitly switch to the safe download directory.
return chrome::GetUserDownloadsDirectorySafe(result);
#else
@@ -156,7 +156,7 @@ bool GetDefaultDownloadSafeDirectory(base::FilePath* result) {
} // namespace
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
base::FilePath GetResourcesDir() {
return util_mac::GetFrameworkResourcesDirectory();
@@ -171,7 +171,7 @@ base::FilePath GetDefaultLogFilePath() {
.Append(FILE_PATH_LITERAL(exe_name + "_debug.log"));
}
#else // !defined(OS_MAC)
#else // !BUILDFLAG(IS_MAC)
base::FilePath GetResourcesDir() {
base::FilePath pak_dir;
@@ -186,7 +186,7 @@ base::FilePath GetDefaultLogFilePath() {
return log_path.Append(FILE_PATH_LITERAL("debug.log"));
}
#endif // !defined(OS_MAC)
#endif // !BUILDFLAG(IS_MAC)
void OverrideDefaultDownloadDir() {
base::FilePath dir_default_download;
@@ -226,7 +226,7 @@ bool IsScaleFactorSupported(ui::ResourceScaleFactor scale_factor) {
scale_factor) != supported_scale_factors.end();
}
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
void OverrideAssetPath() {
Dl_info dl_info;
if (dladdr(reinterpret_cast<const void*>(&OverrideAssetPath), &dl_info)) {

View File

@@ -32,7 +32,7 @@ void OverrideUserDataDir(CefSettings* settings,
// Returns true if |scale_factor| is supported by this platform.
bool IsScaleFactorSupported(ui::ResourceScaleFactor scale_factor);
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
// Look for binary files (*.bin, *.dat, *.pak, chrome-sandbox, libGLESv2.so,
// libEGL.so, locales/*.pak, swiftshader/*.so) next to libcef instead of the exe
// on Linux. This is already the default on Windows.

View File

@@ -97,7 +97,7 @@ bool CefThreadImpl::Create(const CefString& display_name,
options.joinable = stoppable;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
if (com_init_mode != COM_INIT_MODE_NONE) {
if (com_init_mode == COM_INIT_MODE_STA)
options.message_pump_type = base::MessagePumpType::UI;

View File

@@ -6,7 +6,7 @@
#include "base/ignore_result.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include <limits>
namespace {
@@ -21,7 +21,7 @@ bool CanConvertToFileTime(int64_t us) {
}
} // namespace
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
void cef_time_to_basetime(const cef_time_t& cef_time, base::Time& time) {
base::Time::Exploded exploded;
@@ -37,7 +37,7 @@ void cef_time_to_basetime(const cef_time_t& cef_time, base::Time& time) {
}
void cef_time_from_basetime(const base::Time& time, cef_time_t& cef_time) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
int64_t t = time.ToDeltaSinceWindowsEpoch().InMicroseconds();
if (!CanConvertToFileTime(t))
return;