headless: 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).
R=thakis@chromium.org
Bug: 1234043
Test: No functionality change
Change-Id: I2ffbdc2bf509d3d16217fbc8f9171cb5ee2184c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3371757
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Owners-Override: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#956764}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
c0823763b0
commit
2d5a55ece0
headless
app
lib
browser
headless_browser_main_parts.ccheadless_browser_main_parts.hheadless_browser_main_parts_linux.ccheadless_content_browser_client.ccheadless_content_browser_client.hheadless_devtools.ccheadless_request_context_manager.ccheadless_web_contents_impl.cc
headless_content_main_delegate.ccheadless_content_main_delegate.hheadless_crash_reporter_client.ccheadless_crash_reporter_client.hpolicy
protocol
public
test
@ -21,7 +21,7 @@
|
||||
#include "headless/public/headless_web_contents.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "content/public/app/sandbox_helper_win.h"
|
||||
#include "sandbox/win/src/sandbox_types.h"
|
||||
@ -149,7 +149,7 @@ void OnHeadlessBrowserStarted(headless::HeadlessBrowser* browser) {
|
||||
browser->Shutdown();
|
||||
return;
|
||||
}
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
GURL url(base::WideToUTF16(args[0]));
|
||||
#else
|
||||
GURL url(args[0]);
|
||||
@ -171,7 +171,7 @@ void OnHeadlessBrowserStarted(headless::HeadlessBrowser* browser) {
|
||||
}
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
#if !defined(OS_WIN)
|
||||
#if !BUILDFLAG(IS_WIN)
|
||||
// This function must be the first thing we call to make sure child processes
|
||||
// such as the renderer are started properly. The headless library starts
|
||||
// child processes by forking and exec'ing the main application.
|
||||
@ -182,7 +182,7 @@ int main(int argc, const char** argv) {
|
||||
// and it can only be initialized once.
|
||||
headless::HeadlessBrowser::Options::Builder builder(argc, argv);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// In windows, you must initialize and set the sandbox, or pass it along
|
||||
// if it has already been initialized.
|
||||
sandbox::SandboxInterfaceInfo sandbox_info = {nullptr};
|
||||
|
@ -52,13 +52,13 @@
|
||||
#include "third_party/blink/public/common/switches.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "components/crash/core/app/crash_switches.h" // nogncheck
|
||||
#include "components/crash/core/app/run_as_crashpad_handler_win.h"
|
||||
#include "sandbox/win/src/sandbox_types.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
#include "components/os_crypt/os_crypt_switches.h" // nogncheck
|
||||
#endif
|
||||
|
||||
@ -110,7 +110,7 @@ bool ParseFontRenderHinting(
|
||||
}
|
||||
|
||||
GURL ConvertArgumentToURL(const base::CommandLine::StringType& arg) {
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
GURL url(base::WideToUTF8(arg));
|
||||
#else
|
||||
GURL url(arg);
|
||||
@ -145,7 +145,7 @@ base::FilePath GetSSLKeyLogFile(const base::CommandLine* command_line) {
|
||||
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
||||
std::string path_str;
|
||||
env->GetVar("SSLKEYLOGFILE", &path_str);
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// base::Environment returns environment variables in UTF-8 on Windows.
|
||||
return base::FilePath(base::UTF8ToWide(path_str));
|
||||
#else
|
||||
@ -157,12 +157,12 @@ int RunContentMain(
|
||||
HeadlessBrowser::Options options,
|
||||
base::OnceCallback<void(HeadlessBrowser*)> on_browser_start_callback) {
|
||||
content::ContentMainParams params(nullptr);
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// Sandbox info has to be set and initialized.
|
||||
CHECK(options.sandbox_info);
|
||||
params.instance = options.instance;
|
||||
params.sandbox_info = std::move(options.sandbox_info);
|
||||
#elif !defined(OS_ANDROID)
|
||||
#elif !BUILDFLAG(IS_ANDROID)
|
||||
params.argc = options.argc;
|
||||
params.argv = options.argv;
|
||||
#endif
|
||||
@ -270,7 +270,7 @@ void HeadlessShell::OnStart(HeadlessBrowser* browser) {
|
||||
// driven by debugger.
|
||||
if (args.empty() && !base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kRemoteDebuggingPipe)) {
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
args.push_back(L"about:blank");
|
||||
#else
|
||||
args.push_back("about:blank");
|
||||
@ -676,7 +676,7 @@ bool HeadlessShell::RemoteDebuggingEnabled() const {
|
||||
command_line.HasSwitch(switches::kRemoteDebuggingPipe));
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
int HeadlessShellMain(HINSTANCE instance,
|
||||
sandbox::SandboxInterfaceInfo* sandbox_info) {
|
||||
base::CommandLine::Init(0, nullptr);
|
||||
@ -699,10 +699,10 @@ int HeadlessShellMain(int argc, const char** argv) {
|
||||
base::CommandLine::Init(argc, argv);
|
||||
RunChildProcessIfNeeded(argc, argv);
|
||||
HeadlessBrowser::Options::Builder builder(argc, argv);
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
HeadlessShell shell;
|
||||
|
||||
#if defined(OS_FUCHSIA)
|
||||
#if BUILDFLAG(IS_FUCHSIA)
|
||||
// TODO(fuchsia): Remove this when GPU accelerated compositing is ready.
|
||||
base::CommandLine::ForCurrentProcess()->AppendSwitch(::switches::kDisableGpu);
|
||||
#endif
|
||||
@ -711,7 +711,7 @@ int HeadlessShellMain(int argc, const char** argv) {
|
||||
if (!ValidateCommandLine(command_line))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
command_line.AppendSwitch(os_crypt::switches::kUseMockKeychain);
|
||||
#endif
|
||||
|
||||
@ -845,14 +845,14 @@ int HeadlessShellMain(int argc, const char** argv) {
|
||||
}
|
||||
|
||||
int HeadlessShellMain(const content::ContentMainParams& params) {
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
return HeadlessShellMain(params.instance, params.sandbox_info);
|
||||
#else
|
||||
return HeadlessShellMain(params.argc, params.argv);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
void RunChildProcessIfNeeded(HINSTANCE instance,
|
||||
sandbox::SandboxInterfaceInfo* sandbox_info) {
|
||||
base::CommandLine::Init(0, nullptr);
|
||||
@ -863,7 +863,7 @@ void RunChildProcessIfNeeded(HINSTANCE instance,
|
||||
void RunChildProcessIfNeeded(int argc, const char** argv) {
|
||||
base::CommandLine::Init(argc, argv);
|
||||
HeadlessBrowser::Options::Builder builder(argc, argv);
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
const base::CommandLine& command_line(
|
||||
*base::CommandLine::ForCurrentProcess());
|
||||
|
||||
|
@ -5,29 +5,29 @@
|
||||
#include "build/build_config.h"
|
||||
#include "headless/public/headless_shell.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "content/public/app/sandbox_helper_win.h"
|
||||
#include "sandbox/win/src/sandbox_types.h" // nogncheck
|
||||
#elif defined(OS_MAC)
|
||||
#elif BUILDFLAG(IS_MAC)
|
||||
#include "base/check.h"
|
||||
#include "sandbox/mac/seatbelt_exec.h"
|
||||
#endif
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
sandbox::SandboxInterfaceInfo sandbox_info = {nullptr};
|
||||
content::InitializeSandboxInfo(&sandbox_info);
|
||||
return headless::HeadlessShellMain(0, &sandbox_info);
|
||||
#else
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
sandbox::SeatbeltExecServer::CreateFromArgumentsResult seatbelt =
|
||||
sandbox::SeatbeltExecServer::CreateFromArguments(
|
||||
argv[0], argc, const_cast<char**>(argv));
|
||||
if (seatbelt.sandbox_required) {
|
||||
CHECK(seatbelt.server->InitializeSandbox());
|
||||
}
|
||||
#endif // defined(OS_MAC)
|
||||
#endif // BUILDFLAG(IS_MAC)
|
||||
|
||||
return headless::HeadlessShellMain(argc, argv);
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "base/debug/alias.h"
|
||||
#include "build/build_config.h"
|
||||
#include "content/public/common/result_codes.h"
|
||||
#include "headless/app/headless_shell_switches.h"
|
||||
#include "headless/lib/browser/headless_browser_context_impl.h"
|
||||
@ -28,11 +29,11 @@
|
||||
#include "headless/lib/browser/policy/headless_policies.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
#include "services/device/public/cpp/geolocation/geolocation_manager.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "base/command_line.h"
|
||||
#endif
|
||||
|
||||
@ -88,7 +89,7 @@ void HeadlessBrowserMainParts::PostMainMessageLoopRun() {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
device::GeolocationManager* HeadlessBrowserMainParts::GetGeolocationManager() {
|
||||
return geolocation_manager_.get();
|
||||
}
|
||||
@ -148,7 +149,7 @@ void HeadlessBrowserMainParts::CreatePrefService() {
|
||||
}
|
||||
|
||||
auto pref_registry = base::MakeRefCounted<user_prefs::PrefRegistrySyncable>();
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
OSCrypt::RegisterLocalPrefs(pref_registry.get());
|
||||
#endif
|
||||
|
||||
@ -170,13 +171,13 @@ void HeadlessBrowserMainParts::CreatePrefService() {
|
||||
factory.set_user_prefs(pref_store);
|
||||
local_state_ = factory.Create(std::move(pref_registry));
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
if (!command_line->HasSwitch(switches::kDisableCookieEncryption) &&
|
||||
OSCrypt::InitWithExistingKey(local_state_.get()) != OSCrypt::kSuccess) {
|
||||
command_line->AppendSwitch(switches::kDisableCookieEncryption);
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
}
|
||||
#endif // defined(HEADLESS_USE_PREFS)
|
||||
|
||||
|
@ -47,15 +47,15 @@ class HEADLESS_EXPORT HeadlessBrowserMainParts
|
||||
void WillRunMainMessageLoop(
|
||||
std::unique_ptr<base::RunLoop>& run_loop) override;
|
||||
void PostMainMessageLoopRun() override;
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
void PreCreateMainMessageLoop() override;
|
||||
#endif
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
void PostCreateMainMessageLoop() override;
|
||||
#endif
|
||||
void QuitMainMessageLoop();
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
device::GeolocationManager* GetGeolocationManager();
|
||||
void SetGeolocationManagerForTesting(
|
||||
std::unique_ptr<device::GeolocationManager> fake_geolocation_manager);
|
||||
@ -88,7 +88,7 @@ class HEADLESS_EXPORT HeadlessBrowserMainParts
|
||||
|
||||
bool devtools_http_handler_started_ = false;
|
||||
base::OnceClosure quit_main_message_loop_;
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
std::unique_ptr<device::GeolocationManager> geolocation_manager_;
|
||||
#endif
|
||||
};
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "build/chromeos_buildflags.h"
|
||||
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
|
||||
|
||||
#if !defined(OS_CHROMEOS)
|
||||
#if !BUILDFLAG(IS_CHROMEOS)
|
||||
#include "base/command_line.h"
|
||||
#include "components/os_crypt/key_storage_config_linux.h"
|
||||
#include "components/os_crypt/os_crypt.h"
|
||||
@ -19,7 +19,7 @@
|
||||
|
||||
namespace headless {
|
||||
|
||||
#if !defined(OS_CHROMEOS)
|
||||
#if !BUILDFLAG(IS_CHROMEOS)
|
||||
constexpr char kProductName[] = "HeadlessChrome";
|
||||
#endif
|
||||
|
||||
@ -28,7 +28,7 @@ void HeadlessBrowserMainParts::PostCreateMainMessageLoop() {
|
||||
bluez::BluezDBusManager::Initialize(/*system_bus=*/nullptr);
|
||||
#endif
|
||||
|
||||
#if !defined(OS_CHROMEOS)
|
||||
#if !BUILDFLAG(IS_CHROMEOS)
|
||||
// Set up crypt config. This needs to be done before anything starts the
|
||||
// network service, as the raw encryption key needs to be shared with the
|
||||
// network service for encrypted cookie storage.
|
||||
@ -46,7 +46,7 @@ void HeadlessBrowserMainParts::PostCreateMainMessageLoop() {
|
||||
config->should_use_preference = false;
|
||||
config->user_data_path = base::FilePath();
|
||||
OSCrypt::SetConfig(std::move(config));
|
||||
#endif // !defined(OS_CHROMEOS)
|
||||
#endif // !BUILDFLAG(IS_CHROMEOS)
|
||||
}
|
||||
|
||||
} // namespace headless
|
||||
|
@ -48,11 +48,11 @@
|
||||
#include "ui/base/ui_base_switches.h"
|
||||
#include "ui/gfx/switches.h"
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
#include "components/crash/core/app/crash_switches.h"
|
||||
#include "components/crash/core/app/crashpad.h"
|
||||
#include "content/public/common/content_descriptors.h"
|
||||
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
#if defined(HEADLESS_USE_POLICY)
|
||||
#include "components/policy/content/policy_blocklist_navigation_throttle.h"
|
||||
@ -67,7 +67,7 @@
|
||||
|
||||
namespace headless {
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
namespace {
|
||||
|
||||
int GetCrashSignalFD(const base::CommandLine& command_line,
|
||||
@ -78,7 +78,7 @@ int GetCrashSignalFD(const base::CommandLine& command_line,
|
||||
}
|
||||
|
||||
} // namespace
|
||||
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
// Implements a stub BadgeService. This implementation does nothing, but is
|
||||
// required because inbound Mojo messages which do not have a registered
|
||||
@ -181,7 +181,7 @@ HeadlessContentBrowserClient::GetGeneratedCodeCacheSettings(
|
||||
return content::GeneratedCodeCacheSettings(true, 0, context->GetPath());
|
||||
}
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
void HeadlessContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
|
||||
const base::CommandLine& command_line,
|
||||
int child_process_id,
|
||||
@ -190,7 +190,7 @@ void HeadlessContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
|
||||
if (crash_signal_fd >= 0)
|
||||
mappings->Share(kCrashDumpSignal, crash_signal_fd);
|
||||
}
|
||||
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
void HeadlessContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
base::CommandLine* command_line,
|
||||
@ -207,7 +207,7 @@ void HeadlessContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
old_command_line.GetSwitchValueNative(switches::kUserAgent));
|
||||
}
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
int fd;
|
||||
pid_t pid;
|
||||
if (crash_reporter::GetHandlerSocket(&fd, &pid)) {
|
||||
@ -215,7 +215,7 @@ void HeadlessContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
crash_reporter::switches::kCrashpadHandlerPid,
|
||||
base::NumberToString(pid));
|
||||
}
|
||||
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
// If we're spawning a renderer, then override the language switch.
|
||||
std::string process_type =
|
||||
@ -264,7 +264,7 @@ void HeadlessContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
process_type, child_process_id);
|
||||
}
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
// Processes may only query perf_event_open with the BPF sandbox disabled.
|
||||
if (old_command_line.HasSwitch(::switches::kEnableThreadInstructionCount) &&
|
||||
old_command_line.HasSwitch(sandbox::policy::switches::kNoSandbox)) {
|
||||
@ -361,7 +361,7 @@ bool HeadlessContentBrowserClient::CanAcceptUntrustedExchangesIfNeeded() {
|
||||
|
||||
device::GeolocationManager*
|
||||
HeadlessContentBrowserClient::GetGeolocationManager() {
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
return browser_->browser_main_parts()->GetGeolocationManager();
|
||||
#else
|
||||
return nullptr;
|
||||
|
@ -47,7 +47,7 @@ class HeadlessContentBrowserClient : public content::ContentBrowserClient {
|
||||
override;
|
||||
content::GeneratedCodeCacheSettings GetGeneratedCodeCacheSettings(
|
||||
content::BrowserContext* context) override;
|
||||
#if defined(OS_POSIX) && !defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
void GetAdditionalMappedFilesForChildProcess(
|
||||
const base::CommandLine& command_line,
|
||||
int child_process_id,
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "build/build_config.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/devtools_agent_host.h"
|
||||
@ -81,7 +82,7 @@ class TCPEndpointServerSocketFactory : public content::DevToolsSocketFactory {
|
||||
net::HostPortPair endpoint_;
|
||||
};
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
class TCPAdoptServerSocketFactory : public content::DevToolsSocketFactory {
|
||||
public:
|
||||
// Construct a factory to use an already-open, already-listening socket.
|
||||
@ -112,7 +113,7 @@ class TCPAdoptServerSocketFactory : public content::DevToolsSocketFactory {
|
||||
|
||||
size_t socket_fd_;
|
||||
};
|
||||
#else // defined(OS_POSIX)
|
||||
#else // BUILDFLAG(IS_POSIX)
|
||||
|
||||
// Placeholder class to use when a socket_fd is passed in on non-Posix.
|
||||
class DummyTCPServerSocketFactory : public content::DevToolsSocketFactory {
|
||||
@ -133,7 +134,7 @@ class DummyTCPServerSocketFactory : public content::DevToolsSocketFactory {
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
#endif // defined(OS_POSIX)
|
||||
#endif // BUILDFLAG(IS_POSIX)
|
||||
|
||||
void PostTaskToCloseBrowser(base::WeakPtr<HeadlessBrowserImpl> browser) {
|
||||
content::GetUIThreadTaskRunner({})->PostTask(
|
||||
|
@ -65,11 +65,11 @@ void SetCryptKeyOnce(const base::FilePath& user_data_path) {
|
||||
return;
|
||||
done_once = true;
|
||||
|
||||
#if (defined(OS_WIN) || defined(OS_LINUX)) && defined(HEADLESS_USE_PREFS)
|
||||
#if (BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)) && defined(HEADLESS_USE_PREFS)
|
||||
// The OSCrypt keys are process bound, so if network service is out of
|
||||
// process, send it the required key if it is available.
|
||||
if (content::IsOutOfProcessNetworkService()
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
&& OSCrypt::IsEncryptionAvailable()
|
||||
#endif
|
||||
) {
|
||||
@ -204,7 +204,7 @@ HeadlessRequestContextManager::HeadlessRequestContextManager(
|
||||
base::FilePath user_data_path)
|
||||
:
|
||||
// On Windows, Cookie encryption requires access to local_state prefs.
|
||||
#if defined(OS_WIN) && !defined(HEADLESS_USE_PREFS)
|
||||
#if BUILDFLAG(IS_WIN) && !defined(HEADLESS_USE_PREFS)
|
||||
cookie_encryption_enabled_(false),
|
||||
#else
|
||||
cookie_encryption_enabled_(
|
||||
|
@ -57,12 +57,12 @@ namespace headless {
|
||||
namespace {
|
||||
|
||||
void UpdatePrefsFromSystemSettings(blink::RendererPreferences* prefs) {
|
||||
#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || BUILDFLAG(IS_WIN)
|
||||
content::UpdateFontRendererPreferencesFromSystemSettings(prefs);
|
||||
#endif
|
||||
|
||||
// The values were copied from chrome/browser/renderer_preferences_util.cc.
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
prefs->focus_ring_color = SkColorSetRGB(0x00, 0x5F, 0xCC);
|
||||
#else
|
||||
prefs->focus_ring_color = SkColorSetRGB(0x10, 0x10, 0x10);
|
||||
|
@ -23,16 +23,16 @@
|
||||
#include "headless/lib/browser/policy/headless_mode_policy.h"
|
||||
#include "headless/lib/browser/policy/headless_policies.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "base/win/registry.h"
|
||||
#include "components/policy/core/common/policy_loader_win.h"
|
||||
#elif defined(OS_MAC)
|
||||
#elif BUILDFLAG(IS_MAC)
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#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" // nogncheck http://crbug.com/1227148
|
||||
#endif
|
||||
|
||||
@ -119,14 +119,14 @@ HeadlessBrowserPolicyConnector::CreatePolicyProviders() {
|
||||
|
||||
std::unique_ptr<ConfigurationPolicyProvider>
|
||||
HeadlessBrowserPolicyConnector::CreatePlatformProvider() {
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
std::unique_ptr<AsyncPolicyLoader> loader(PolicyLoaderWin::Create(
|
||||
base::ThreadPool::CreateSequencedTaskRunner(
|
||||
{base::MayBlock(), base::TaskPriority::BEST_EFFORT}),
|
||||
&platform_management_service_, kRegistryChromePolicyKey));
|
||||
return std::make_unique<AsyncPolicyProvider>(GetSchemaRegistry(),
|
||||
std::move(loader));
|
||||
#elif defined(OS_MAC)
|
||||
#elif BUILDFLAG(IS_MAC)
|
||||
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
|
||||
// Explicitly watch the "com.google.Chrome" bundle ID, no matter what this
|
||||
// app's bundle ID actually is. All channels of Chrome should obey the same
|
||||
@ -143,7 +143,7 @@ HeadlessBrowserPolicyConnector::CreatePlatformProvider() {
|
||||
new MacPreferences(), bundle_id);
|
||||
return std::make_unique<AsyncPolicyProvider>(GetSchemaRegistry(),
|
||||
std::move(loader));
|
||||
#elif defined(OS_POSIX)
|
||||
#elif BUILDFLAG(IS_POSIX)
|
||||
// The following should match chrome::DIR_POLICY_FILES definition in
|
||||
// chrome/common/chrome_paths.cc
|
||||
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
|
||||
|
@ -34,7 +34,7 @@ Response TargetHandler::CreateTarget(const std::string& url,
|
||||
Maybe<bool> new_window,
|
||||
Maybe<bool> background,
|
||||
std::string* out_target_id) {
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
if (enable_begin_frame_control.fromMaybe(false)) {
|
||||
return Response::ServerError(
|
||||
"BeginFrameControl is not supported on MacOS yet");
|
||||
|
@ -47,15 +47,15 @@
|
||||
#include "headless/embedded_resource_pak.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_MAC) || defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
#include "components/crash/core/app/crashpad.h"
|
||||
#endif // defined(OS_MAC) || defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#endif // BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
#include "components/crash/core/app/crash_switches.h"
|
||||
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
@ -77,7 +77,7 @@ const int kTraceEventBrowserProcessSortIndex = -6;
|
||||
|
||||
HeadlessContentMainDelegate* g_current_headless_content_main_delegate = nullptr;
|
||||
|
||||
#if !defined(OS_FUCHSIA)
|
||||
#if !BUILDFLAG(IS_FUCHSIA)
|
||||
base::LazyInstance<HeadlessCrashReporterClient>::Leaky g_headless_crash_client =
|
||||
LAZY_INSTANCE_INITIALIZER;
|
||||
#endif
|
||||
@ -120,7 +120,7 @@ void InitializeResourceBundle(const base::CommandLine& command_line) {
|
||||
base::FilePath chrome_200_pak =
|
||||
resource_dir.Append(FILE_PATH_LITERAL("chrome_200_percent.pak"));
|
||||
|
||||
#if defined(OS_MAC) && !defined(COMPONENT_BUILD)
|
||||
#if BUILDFLAG(IS_MAC) && !defined(COMPONENT_BUILD)
|
||||
// In non component builds, check if fall back in Resources/ folder is
|
||||
// available.
|
||||
if (!base::PathExists(resources_pak)) {
|
||||
@ -210,7 +210,7 @@ bool HeadlessContentMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
// in content/public/common/content_switch_dependent_feature_overrides.cc
|
||||
command_line->AppendSwitch(::blink::switches::kAllowPreCommitInput);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
command_line->AppendSwitch(
|
||||
::switches::kDisableGpuProcessForDX12InfoCollection);
|
||||
#endif
|
||||
@ -223,14 +223,14 @@ void HeadlessContentMainDelegate::InitLogging(
|
||||
const base::CommandLine& command_line) {
|
||||
const std::string process_type =
|
||||
command_line.GetSwitchValueASCII(::switches::kProcessType);
|
||||
#if !defined(OS_WIN)
|
||||
#if !BUILDFLAG(IS_WIN)
|
||||
if (!command_line.HasSwitch(::switches::kEnableLogging))
|
||||
return;
|
||||
#else
|
||||
// Child processes in Windows are not able to initialize logging.
|
||||
if (!process_type.empty())
|
||||
return;
|
||||
#endif // !defined(OS_WIN)
|
||||
#endif // !BUILDFLAG(IS_WIN)
|
||||
|
||||
logging::LoggingDestination log_mode;
|
||||
base::FilePath log_filename(FILE_PATH_LITERAL("chrome_debug.log"));
|
||||
@ -276,7 +276,7 @@ void HeadlessContentMainDelegate::InitLogging(
|
||||
|
||||
// Otherwise we log to where the executable is.
|
||||
if (log_path.empty()) {
|
||||
#if defined(OS_FUCHSIA)
|
||||
#if BUILDFLAG(IS_FUCHSIA)
|
||||
// TODO(crbug.com/1262330): Use the same solution as used for LOG_DIR.
|
||||
// Use -1 to allow this to compile.
|
||||
if (base::PathService::Get(-1, &log_path)) {
|
||||
@ -313,7 +313,7 @@ void HeadlessContentMainDelegate::InitCrashReporter(
|
||||
if (!options()->enable_crash_reporter)
|
||||
return;
|
||||
|
||||
#if defined(OS_FUCHSIA)
|
||||
#if BUILDFLAG(IS_FUCHSIA)
|
||||
// TODO(crbug.com/1226159): Implement this when crash reporting is available
|
||||
// for Fuchsia.
|
||||
NOTIMPLEMENTED();
|
||||
@ -325,13 +325,13 @@ void HeadlessContentMainDelegate::InitCrashReporter(
|
||||
crash_reporter::InitializeCrashKeys();
|
||||
crash_keys::SetSwitchesFromCommandLine(command_line, nullptr);
|
||||
|
||||
#if !defined(OS_WIN)
|
||||
#if !BUILDFLAG(IS_WIN)
|
||||
const std::string process_type =
|
||||
command_line.GetSwitchValueASCII(::switches::kProcessType);
|
||||
if (process_type != switches::kZygoteProcess)
|
||||
crash_reporter::InitializeCrashpad(process_type.empty(), process_type);
|
||||
#endif // !defined(OS_WIN)
|
||||
#endif // defined(OS_FUCHSIA)
|
||||
#endif // !BUILDFLAG(IS_WIN)
|
||||
#endif // BUILDFLAG(IS_FUCHSIA)
|
||||
|
||||
// Mark any bug reports from headless mode as such.
|
||||
static crash_reporter::CrashKeyString<32> headless_key(kHeadlessCrashKey);
|
||||
@ -341,14 +341,14 @@ void HeadlessContentMainDelegate::InitCrashReporter(
|
||||
void HeadlessContentMainDelegate::PreSandboxStartup() {
|
||||
const base::CommandLine& command_line(
|
||||
*base::CommandLine::ForCurrentProcess());
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// Windows always needs to initialize logging, otherwise you get a renderer
|
||||
// crash.
|
||||
InitLogging(command_line);
|
||||
#else
|
||||
if (command_line.HasSwitch(::switches::kEnableLogging))
|
||||
InitLogging(command_line);
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
InitCrashReporter(command_line);
|
||||
|
||||
@ -387,7 +387,7 @@ HeadlessContentMainDelegate::RunProcess(
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
void SIGTERMProfilingShutdown(int signal) {
|
||||
content::Profiling::Stop();
|
||||
struct sigaction sigact;
|
||||
@ -419,7 +419,7 @@ void HeadlessContentMainDelegate::ZygoteForked() {
|
||||
crash_reporter::InitializeCrashpad(false, process_type);
|
||||
}
|
||||
}
|
||||
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
// static
|
||||
HeadlessContentMainDelegate* HeadlessContentMainDelegate::GetInstance() {
|
||||
|
@ -46,7 +46,7 @@ class HEADLESS_EXPORT HeadlessContentMainDelegate
|
||||
absl::variant<int, content::MainFunctionParams> RunProcess(
|
||||
const std::string& process_type,
|
||||
content::MainFunctionParams main_function_params) override;
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
void PreBrowserMain() override;
|
||||
#endif
|
||||
content::ContentClient* CreateContentClient() override;
|
||||
@ -58,7 +58,7 @@ class HEADLESS_EXPORT HeadlessContentMainDelegate
|
||||
|
||||
HeadlessBrowserImpl* browser() const { return browser_.get(); }
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
void ZygoteForked() override;
|
||||
#endif
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace headless {
|
||||
|
||||
namespace {
|
||||
|
||||
#if defined(OS_POSIX) && !defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
|
||||
constexpr char kChromeHeadlessProductName[] = "Chrome_Headless";
|
||||
|
||||
@ -30,7 +30,7 @@ constexpr char kChromeHeadlessProductName[] = "Chrome_Headless";
|
||||
HeadlessCrashReporterClient::HeadlessCrashReporterClient() = default;
|
||||
HeadlessCrashReporterClient::~HeadlessCrashReporterClient() = default;
|
||||
|
||||
#if defined(OS_POSIX) && !defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
void HeadlessCrashReporterClient::GetProductNameAndVersion(
|
||||
std::string* product_name,
|
||||
std::string* version,
|
||||
@ -39,10 +39,10 @@ void HeadlessCrashReporterClient::GetProductNameAndVersion(
|
||||
*version = PRODUCT_VERSION;
|
||||
*channel = "";
|
||||
}
|
||||
#endif // defined(OS_POSIX) && !defined(OS_MAC)
|
||||
#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
|
||||
bool HeadlessCrashReporterClient::GetCrashDumpLocation(
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
std::wstring* crash_dir
|
||||
#else
|
||||
base::FilePath* crash_dir
|
||||
@ -57,7 +57,7 @@ bool HeadlessCrashReporterClient::GetCrashDumpLocation(
|
||||
if (crash_dumps_dir_.empty()) {
|
||||
crash_directory = crash_directory.Append(FILE_PATH_LITERAL("Crashpad"));
|
||||
}
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
*crash_dir = crash_directory.value();
|
||||
#else
|
||||
*crash_dir = std::move(crash_directory);
|
||||
|
@ -28,13 +28,13 @@ class HeadlessCrashReporterClient : public crash_reporter::CrashReporterClient {
|
||||
}
|
||||
const base::FilePath& crash_dumps_dir() const { return crash_dumps_dir_; }
|
||||
|
||||
#if defined(OS_POSIX) && !defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
void GetProductNameAndVersion(std::string* product_name,
|
||||
std::string* version,
|
||||
std::string* channel) override;
|
||||
#endif // defined(OS_POSIX) && !defined(OS_MAC)
|
||||
#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
bool GetCrashDumpLocation(std::wstring* crash_dir) override;
|
||||
#else
|
||||
bool GetCrashDumpLocation(base::FilePath* crash_dir) override;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "headless/public/version.h"
|
||||
#include "ui/gl/gl_switches.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "sandbox/win/src/sandbox_types.h"
|
||||
#endif
|
||||
|
||||
@ -42,7 +42,7 @@ Options::Options(int argc, const char** argv)
|
||||
user_agent(content::BuildUserAgentFromProduct(product_name_and_version)),
|
||||
window_size(kDefaultWindowSize),
|
||||
font_render_hinting(kDefaultFontRenderHinting) {
|
||||
#if defined(OS_LINUX) || defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN)
|
||||
gl_implementation = gl::kGLImplementationANGLEName;
|
||||
angle_implementation = gl::kANGLEImplementationSwiftShaderForWebGLName;
|
||||
#endif
|
||||
@ -136,7 +136,7 @@ Builder& Builder::SetAppendCommandLineFlagsCallback(
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
Builder& Builder::SetInstance(HINSTANCE hinstance) {
|
||||
options_.instance = hinstance;
|
||||
return *this;
|
||||
@ -146,7 +146,7 @@ Builder& Builder::SetSandboxInfo(sandbox::SandboxInterfaceInfo* info) {
|
||||
options_.sandbox_info = info;
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
Builder& Builder::SetUserDataDir(const base::FilePath& dir) {
|
||||
options_.user_data_dir = dir;
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "ui/gfx/font_render_params.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "sandbox/win/src/sandbox_types.h"
|
||||
#endif
|
||||
|
||||
@ -116,7 +116,7 @@ struct HEADLESS_EXPORT HeadlessBrowser::Options {
|
||||
int argc;
|
||||
raw_ptr<const char*> argv;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// Set hardware instance if available, otherwise it defaults to 0.
|
||||
HINSTANCE instance = 0;
|
||||
|
||||
@ -249,7 +249,7 @@ class HEADLESS_EXPORT HeadlessBrowser::Options::Builder {
|
||||
Builder& SetANGLEImplementation(const std::string& implementation);
|
||||
Builder& SetAppendCommandLineFlagsCallback(
|
||||
const Options::AppendCommandLineFlagsCallback& callback);
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
Builder& SetInstance(HINSTANCE hinstance);
|
||||
Builder& SetSandboxInfo(sandbox::SandboxInterfaceInfo* info);
|
||||
#endif
|
||||
@ -278,7 +278,7 @@ class HEADLESS_EXPORT HeadlessBrowser::Options::Builder {
|
||||
Options options_;
|
||||
};
|
||||
|
||||
#if !defined(OS_WIN)
|
||||
#if !BUILDFLAG(IS_WIN)
|
||||
// The headless browser may need to create child processes (e.g., a renderer
|
||||
// which runs web content). This is done by re-executing the parent process as
|
||||
// a zygote[1] and forking each child process from that zygote.
|
||||
@ -307,7 +307,7 @@ void RunChildProcessIfNeeded(int argc, const char** argv);
|
||||
// the child process.
|
||||
void RunChildProcessIfNeeded(HINSTANCE instance,
|
||||
sandbox::SandboxInterfaceInfo* sandbox_info);
|
||||
#endif // !defined(OS_WIN)
|
||||
#endif // !BUILDFLAG(IS_WIN)
|
||||
|
||||
// Main entry point for running the headless browser. This function constructs
|
||||
// the headless browser instance, passing it to the given
|
||||
|
@ -5,9 +5,10 @@
|
||||
#ifndef HEADLESS_PUBLIC_HEADLESS_SHELL_H_
|
||||
#define HEADLESS_PUBLIC_HEADLESS_SHELL_H_
|
||||
|
||||
#include "build/build_config.h"
|
||||
#include "content/public/app/content_main.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "sandbox/win/src/sandbox_types.h"
|
||||
#endif
|
||||
|
||||
@ -20,12 +21,12 @@ int HeadlessShellMain(const content::ContentMainParams& params);
|
||||
|
||||
// Start the Headless Shell application. Intended to be called early in main().
|
||||
// Returns the exit code for the process.
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
int HeadlessShellMain(HINSTANCE instance,
|
||||
sandbox::SandboxInterfaceInfo* sandbox_info);
|
||||
#else
|
||||
int HeadlessShellMain(int argc, const char** argv);
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
} // namespace headless
|
||||
|
||||
#endif // HEADLESS_PUBLIC_HEADLESS_SHELL_H_
|
||||
|
@ -52,7 +52,7 @@
|
||||
#include "ui/base/clipboard/scoped_clipboard_writer.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
|
||||
#if !defined(OS_FUCHSIA)
|
||||
#if !BUILDFLAG(IS_FUCHSIA)
|
||||
#include "third_party/crashpad/crashpad/client/crash_report_database.h" // nogncheck
|
||||
#endif
|
||||
|
||||
@ -223,7 +223,7 @@ class HeadlessBrowserTestWithProxy : public HeadlessBrowserTest {
|
||||
net::EmbeddedTestServer proxy_server_;
|
||||
};
|
||||
|
||||
#if defined(OS_MAC) && defined(ADDRESS_SANITIZER)
|
||||
#if BUILDFLAG(IS_MAC) && defined(ADDRESS_SANITIZER)
|
||||
// TODO(crbug.com/1086872): Disabled due to flakiness on Mac ASAN.
|
||||
#define MAYBE_SetProxyConfig DISABLED_SetProxyConfig
|
||||
#else
|
||||
@ -300,7 +300,7 @@ IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, DefaultSizes) {
|
||||
HeadlessBrowser::Options::Builder builder;
|
||||
const HeadlessBrowser::Options kDefaultOptions = builder.Build();
|
||||
|
||||
#if !defined(OS_MAC)
|
||||
#if !BUILDFLAG(IS_MAC)
|
||||
// On Mac headless does not override the screen dimensions, so they are
|
||||
// left with the actual screen values.
|
||||
EXPECT_EQ(kDefaultOptions.window_size.width(),
|
||||
@ -313,7 +313,7 @@ IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, DefaultSizes) {
|
||||
->GetResult()
|
||||
->GetValue()
|
||||
->GetInt());
|
||||
#endif // !defined(OS_MAC)
|
||||
#endif // !BUILDFLAG(IS_MAC)
|
||||
EXPECT_EQ(kDefaultOptions.window_size.width(),
|
||||
EvaluateScript(web_contents, "window.innerWidth")
|
||||
->GetResult()
|
||||
@ -371,7 +371,7 @@ class CookieSetter {
|
||||
|
||||
// TODO(skyostil): This test currently relies on being able to run a shell
|
||||
// script.
|
||||
#if defined(OS_POSIX)
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
class HeadlessBrowserRendererCommandPrefixTest : public HeadlessBrowserTest {
|
||||
public:
|
||||
const base::FilePath& launcher_stamp() const { return launcher_stamp_; }
|
||||
@ -386,11 +386,11 @@ class HeadlessBrowserRendererCommandPrefixTest : public HeadlessBrowserTest {
|
||||
launcher_stamp_.value().c_str());
|
||||
fprintf(launcher_file.get(), "exec $@\n");
|
||||
launcher_file.reset();
|
||||
#if !defined(OS_FUCHSIA)
|
||||
#if !BUILDFLAG(IS_FUCHSIA)
|
||||
base::SetPosixFilePermissions(launcher_script_,
|
||||
base::FILE_PERMISSION_READ_BY_USER |
|
||||
base::FILE_PERMISSION_EXECUTE_BY_USER);
|
||||
#endif // !defined(OS_FUCHSIA)
|
||||
#endif // !BUILDFLAG(IS_FUCHSIA)
|
||||
|
||||
HeadlessBrowserTest::SetUp();
|
||||
}
|
||||
@ -431,7 +431,7 @@ IN_PROC_BROWSER_TEST_F(HeadlessBrowserRendererCommandPrefixTest, Prefix) {
|
||||
EXPECT_TRUE(base::ReadFileToString(launcher_stamp(), &stamp));
|
||||
EXPECT_GE(stamp.find("--type=renderer"), 0u);
|
||||
}
|
||||
#endif // defined(OS_POSIX)
|
||||
#endif // BUILDFLAG(IS_POSIX)
|
||||
|
||||
class CrashReporterTest : public HeadlessBrowserTest,
|
||||
public HeadlessWebContents::Observer,
|
||||
@ -473,7 +473,7 @@ class CrashReporterTest : public HeadlessBrowserTest,
|
||||
base::FilePath crash_dumps_dir_;
|
||||
};
|
||||
|
||||
#if !defined(OS_FUCHSIA) && !defined(OS_WIN)
|
||||
#if !BUILDFLAG(IS_FUCHSIA) && !BUILDFLAG(IS_WIN)
|
||||
IN_PROC_BROWSER_TEST_F(CrashReporterTest, GenerateMinidump) {
|
||||
content::ScopedAllowRendererCrashes scoped_allow_renderer_crashes;
|
||||
|
||||
@ -513,7 +513,7 @@ IN_PROC_BROWSER_TEST_F(CrashReporterTest, GenerateMinidump) {
|
||||
browser_context_->Close();
|
||||
browser_context_ = nullptr;
|
||||
}
|
||||
#endif // !defined(OS_FUCHSIA) && !defined(OS_WIN)
|
||||
#endif // !BUILDFLAG(IS_FUCHSIA) && !BUILDFLAG(IS_WIN)
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, PermissionManagerAlwaysASK) {
|
||||
GURL url("https://example.com");
|
||||
@ -599,12 +599,12 @@ class TraceHelper : public tracing::ExperimentalObserver {
|
||||
} // namespace
|
||||
|
||||
// Flaky, http://crbug.com/1269261.
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#define MAYBE_TraceUsingBrowserDevToolsTarget \
|
||||
DISABLED_TraceUsingBrowserDevToolsTarget
|
||||
#else
|
||||
#define MAYBE_TraceUsingBrowserDevToolsTarget TraceUsingBrowserDevToolsTarget
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest,
|
||||
MAYBE_TraceUsingBrowserDevToolsTarget) {
|
||||
HeadlessDevToolsTarget* target = browser()->GetDevToolsTarget();
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "ui/gl/gl_switches.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
#include "services/device/public/cpp/test/fake_geolocation_manager.h"
|
||||
#endif
|
||||
|
||||
@ -137,14 +137,14 @@ void LoadObserver::OnResponseReceived(
|
||||
}
|
||||
|
||||
HeadlessBrowserTest::HeadlessBrowserTest() {
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
// On Mac the source root is not set properly. We override it by assuming
|
||||
// that is two directories up from the execution test file.
|
||||
base::FilePath dir_exe_path;
|
||||
CHECK(base::PathService::Get(base::DIR_EXE, &dir_exe_path));
|
||||
dir_exe_path = dir_exe_path.Append("../../");
|
||||
CHECK(base::PathService::Override(base::DIR_SOURCE_ROOT, dir_exe_path));
|
||||
#endif // defined(OS_MAC)
|
||||
#endif // BUILDFLAG(IS_MAC)
|
||||
base::FilePath headless_test_data(FILE_PATH_LITERAL("headless/test/data"));
|
||||
CreateTestServer(headless_test_data);
|
||||
}
|
||||
@ -194,7 +194,7 @@ void HeadlessBrowserTest::PostRunTestOnMainThread() {
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
void HeadlessBrowserTest::CreatedBrowserMainParts(
|
||||
content::BrowserMainParts* parts) {
|
||||
auto fake_geolocation_manager =
|
||||
@ -273,7 +273,7 @@ HeadlessAsyncDevTooledBrowserTest::~HeadlessAsyncDevTooledBrowserTest() =
|
||||
void HeadlessAsyncDevTooledBrowserTest::DevToolsTargetReady() {
|
||||
EXPECT_TRUE(web_contents_->GetDevToolsTarget());
|
||||
web_contents_->GetDevToolsTarget()->AttachClient(devtools_client_.get());
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
devtools_client_->GetEmulation()->SetDeviceMetricsOverride(
|
||||
emulation::SetDeviceMetricsOverrideParams::Builder()
|
||||
.SetWidth(0)
|
||||
|
@ -72,7 +72,7 @@ class HeadlessBrowserTest : public content::BrowserTestBase {
|
||||
void SetUp() override;
|
||||
void PreRunTestOnMainThread() override;
|
||||
void PostRunTestOnMainThread() override;
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
void CreatedBrowserMainParts(content::BrowserMainParts* parts) override;
|
||||
#endif
|
||||
|
||||
|
@ -48,8 +48,8 @@ class HeadlessCompositorBrowserTest : public HeadlessProtocolBrowserTest {
|
||||
// chromium/src/headless/lib/browser/protocol/target_handler.cc?
|
||||
// rcl=5811aa08e60ba5ac7622f029163213cfbdb682f7&l=32
|
||||
// TODO(crbug.com/1020046): Suite is flaky on TSan Linux.
|
||||
#if defined(OS_MAC) || \
|
||||
((defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(THREAD_SANITIZER))
|
||||
#if BUILDFLAG(IS_MAC) || ((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && \
|
||||
defined(THREAD_SANITIZER))
|
||||
#define HEADLESS_COMPOSITOR_TEST(TEST_NAME, SCRIPT_NAME) \
|
||||
IN_PROC_BROWSER_TEST_F(HeadlessCompositorBrowserTest, \
|
||||
DISABLED_##TEST_NAME) { \
|
||||
@ -72,8 +72,8 @@ HEADLESS_COMPOSITOR_TEST(CompositorImageAnimation,
|
||||
"emulation/compositor-image-animation-test.js")
|
||||
|
||||
// Flaky on all platforms. TODO(crbug.com/986027): Re-enable.
|
||||
#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \
|
||||
defined(OS_FUCHSIA)
|
||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \
|
||||
BUILDFLAG(IS_FUCHSIA)
|
||||
#define MAYBE_CompositorCssAnimation DISABLED_CompositorCssAnimation
|
||||
#else
|
||||
#define MAYBE_CompositorCssAnimation CompositorCssAnimation
|
||||
|
@ -140,10 +140,10 @@ class HeadlessDevToolsClientWindowManagementTest
|
||||
std::unique_ptr<browser::GetWindowBoundsResult> result) {
|
||||
const browser::Bounds* actual_bounds = result->GetBounds();
|
||||
// Mac does not support repositioning, as we don't show any actual window.
|
||||
#if !defined(OS_MAC)
|
||||
#if !BUILDFLAG(IS_MAC)
|
||||
EXPECT_EQ(bounds.x(), actual_bounds->GetLeft());
|
||||
EXPECT_EQ(bounds.y(), actual_bounds->GetTop());
|
||||
#endif // !defined(OS_MAC)
|
||||
#endif // !BUILDFLAG(IS_MAC)
|
||||
EXPECT_EQ(bounds.width(), actual_bounds->GetWidth());
|
||||
EXPECT_EQ(bounds.height(), actual_bounds->GetHeight());
|
||||
EXPECT_EQ(state, actual_bounds->GetWindowState());
|
||||
@ -175,7 +175,7 @@ class HeadlessDevToolsClientChangeWindowBoundsTest
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(OS_MAC) && defined(ADDRESS_SANITIZER)
|
||||
#if BUILDFLAG(IS_MAC) && defined(ADDRESS_SANITIZER)
|
||||
// TODO(crbug.com/1086872): Disabled due to flakiness on Mac ASAN.
|
||||
DISABLED_HEADLESS_ASYNC_DEVTOOLED_TEST_F(
|
||||
HeadlessDevToolsClientChangeWindowBoundsTest);
|
||||
@ -506,12 +506,12 @@ class HeadlessCrashObserverTest : public HeadlessAsyncDevTooledBrowserTest,
|
||||
// Make sure we don't fail because the renderer crashed!
|
||||
void RenderProcessExited(base::TerminationStatus status,
|
||||
int exit_code) override {
|
||||
#if defined(OS_WIN) && defined(ADDRESS_SANITIZER)
|
||||
#if BUILDFLAG(IS_WIN) && defined(ADDRESS_SANITIZER)
|
||||
// TODO(crbug.com/845011): Make ASan not interfere and expect a crash.
|
||||
// ASan's normal error exit code is 1, which base categorizes as the process
|
||||
// being killed.
|
||||
EXPECT_EQ(base::TERMINATION_STATUS_PROCESS_WAS_KILLED, status);
|
||||
#elif defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX)
|
||||
#elif BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
|
||||
EXPECT_EQ(base::TERMINATION_STATUS_PROCESS_CRASHED, status);
|
||||
#else
|
||||
EXPECT_EQ(base::TERMINATION_STATUS_ABNORMAL_TERMINATION, status);
|
||||
@ -894,7 +894,7 @@ class DomTreeExtractionBrowserTest : public HeadlessAsyncDevTooledBrowserTest,
|
||||
dom_nodes_result += result_json;
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
ASSERT_TRUE(base::RemoveChars(dom_nodes_result, "\r", &dom_nodes_result));
|
||||
#endif
|
||||
|
||||
@ -917,7 +917,7 @@ class DomTreeExtractionBrowserTest : public HeadlessAsyncDevTooledBrowserTest,
|
||||
computed_styles_result += result_json;
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
ASSERT_TRUE(base::RemoveChars(computed_styles_result, "\r",
|
||||
&computed_styles_result));
|
||||
#endif
|
||||
@ -1120,7 +1120,7 @@ class DevtoolsInterceptionWithAuthProxyTest
|
||||
std::set<std::string> files_loaded_;
|
||||
};
|
||||
|
||||
#if defined(OS_MAC) && defined(ADDRESS_SANITIZER)
|
||||
#if BUILDFLAG(IS_MAC) && defined(ADDRESS_SANITIZER)
|
||||
// TODO(crbug.com/1086872): Disabled due to flakiness on Mac ASAN.
|
||||
DISABLED_HEADLESS_ASYNC_DEVTOOLED_TEST_F(DevtoolsInterceptionWithAuthProxyTest);
|
||||
#else
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
#if !defined(OS_WIN)
|
||||
#if !BUILDFLAG(IS_WIN)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
@ -119,7 +119,7 @@ namespace {
|
||||
class CaptureStdErr {
|
||||
public:
|
||||
CaptureStdErr() {
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
CHECK_EQ(_pipe(pipes_, 4096, O_BINARY), 0);
|
||||
#else
|
||||
CHECK_EQ(pipe(pipes_), 0);
|
||||
@ -224,7 +224,7 @@ INSTANTIATE_TEST_CASE_P(HeadlessBrowserTestWithRemoteDebuggingAllowedPolicy,
|
||||
|
||||
// Remote debugging with ephemeral port is not working on Fuchsia, see
|
||||
// crbug.com/1209251.
|
||||
#if defined(OS_FUCHSIA)
|
||||
#if BUILDFLAG(IS_FUCHSIA)
|
||||
#define MAYBE_RemoteDebuggingDisallowed DISABLED_RemoteDebuggingDisallowed
|
||||
#else
|
||||
#define MAYBE_RemoteDebuggingDisallowed RemoteDebuggingDisallowed
|
||||
|
@ -177,7 +177,7 @@ void HeadlessProtocolBrowserTest::FinishTest() {
|
||||
}
|
||||
|
||||
// TODO(crbug.com/1086872): The whole test suite is flaky on Mac ASAN.
|
||||
#if (defined(OS_MAC) && defined(ADDRESS_SANITIZER))
|
||||
#if (BUILDFLAG(IS_MAC) && defined(ADDRESS_SANITIZER))
|
||||
#define HEADLESS_PROTOCOL_TEST(TEST_NAME, SCRIPT_NAME) \
|
||||
IN_PROC_BROWSER_TEST_F(HeadlessProtocolBrowserTest, DISABLED_##TEST_NAME) { \
|
||||
test_folder_ = "/protocol/"; \
|
||||
@ -199,8 +199,8 @@ HEADLESS_PROTOCOL_TEST(VirtualTimeInterrupt,
|
||||
"emulation/virtual-time-interrupt.js")
|
||||
|
||||
// Flaky on Linux, Mac & Win. TODO(crbug.com/930717): Re-enable.
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_MAC) || \
|
||||
defined(OS_WIN) || defined(OS_FUCHSIA)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_MAC) || \
|
||||
BUILDFLAG(IS_WIN) || BUILDFLAG(IS_FUCHSIA)
|
||||
#define MAYBE_VirtualTimeCrossProcessNavigation \
|
||||
DISABLED_VirtualTimeCrossProcessNavigation
|
||||
#else
|
||||
@ -235,7 +235,7 @@ HEADLESS_PROTOCOL_TEST(VirtualTimeHistoryNavigationSameDoc,
|
||||
"emulation/virtual-time-history-navigation-same-doc.js")
|
||||
|
||||
// Flaky on Mac. TODO(crbug.com/1164173): Re-enable.
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
#define MAYBE_VirtualTimeFetchKeepalive DISABLED_VirtualTimeFetchKeepalive
|
||||
#else
|
||||
#define MAYBE_VirtualTimeFetchKeepalive VirtualTimeFetchKeepalive
|
||||
@ -250,7 +250,7 @@ HEADLESS_PROTOCOL_TEST(VirtualTimePausesDocumentLoading,
|
||||
HEADLESS_PROTOCOL_TEST(PageBeforeUnload, "page/page-before-unload.js")
|
||||
|
||||
// http://crbug.com/633321
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
#define MAYBE_VirtualTimeTimerOrder DISABLED_VirtualTimeTimerOrder
|
||||
#define MAYBE_VirtualTimeTimerSuspend DISABLED_VirtualTimeTimerSuspend
|
||||
#else
|
||||
@ -269,7 +269,7 @@ HEADLESS_PROTOCOL_TEST(Geolocation, "emulation/geolocation-crash.js")
|
||||
HEADLESS_PROTOCOL_TEST(DragStarted, "input/dragIntercepted.js")
|
||||
|
||||
// https://crbug.com/1204620
|
||||
#if defined(OS_LINUX) || defined(OS_MAC) || defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
|
||||
#define MAYBE_InputClipboardOps DISABLED_InputClipboardOps
|
||||
#else
|
||||
#define MAYBE_InputClipboardOps InputClipboardOps
|
||||
|
@ -17,9 +17,9 @@
|
||||
#include "headless/lib/utility/headless_content_utility_client.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "base/win/win_util.h"
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
namespace headless {
|
||||
namespace {
|
||||
@ -76,7 +76,7 @@ int main(int argc, char** argv) {
|
||||
if (parallel_jobs == 0U)
|
||||
return 1;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// Load and pin user32.dll to avoid having to load it once tests start while
|
||||
// on the main thread loop where blocking calls are disallowed.
|
||||
base::win::PinUser32();
|
||||
|
@ -113,14 +113,14 @@ IN_PROC_BROWSER_TEST_F(HeadlessWebContentsTest, WindowOpen) {
|
||||
EXPECT_NE(parent->window_tree_host(), child->window_tree_host());
|
||||
|
||||
gfx::Rect expected_bounds(0, 0, 200, 100);
|
||||
#if !defined(OS_MAC)
|
||||
#if !BUILDFLAG(IS_MAC)
|
||||
EXPECT_EQ(expected_bounds, child->web_contents()->GetViewBounds());
|
||||
EXPECT_EQ(expected_bounds, child->web_contents()->GetContainerBounds());
|
||||
#else // !defined(OS_MAC)
|
||||
#else // !BUILDFLAG(IS_MAC)
|
||||
// Mac does not support GetViewBounds() and view positions are random.
|
||||
EXPECT_EQ(expected_bounds.size(),
|
||||
child->web_contents()->GetContainerBounds().size());
|
||||
#endif // !defined(OS_MAC)
|
||||
#endif // !BUILDFLAG(IS_MAC)
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(HeadlessWebContentsTest,
|
||||
@ -260,7 +260,7 @@ class HeadlessWebContentsScreenshotWindowPositionTest
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(OS_MAC) && defined(ADDRESS_SANITIZER)
|
||||
#if BUILDFLAG(IS_MAC) && defined(ADDRESS_SANITIZER)
|
||||
// TODO(crbug.com/1086872): Disabled due to flakiness on Mac ASAN.
|
||||
DISABLED_HEADLESS_ASYNC_DEVTOOLED_TEST_P(
|
||||
HeadlessWebContentsScreenshotWindowPositionTest);
|
||||
@ -727,7 +727,7 @@ IN_PROC_BROWSER_TEST_F(HeadlessWebContentsTest, BrowserOpenInTab) {
|
||||
}
|
||||
|
||||
// BeginFrameControl is not supported on MacOS.
|
||||
#if !defined(OS_MAC)
|
||||
#if !BUILDFLAG(IS_MAC)
|
||||
|
||||
class HeadlessWebContentsBeginFrameControlTest
|
||||
: public HeadlessBrowserTest,
|
||||
@ -1043,7 +1043,7 @@ class HeadlessWebContentsBeginFrameControlViewportTest
|
||||
HEADLESS_ASYNC_DEVTOOLED_TEST_F(
|
||||
HeadlessWebContentsBeginFrameControlViewportTest);
|
||||
|
||||
#endif // !defined(OS_MAC)
|
||||
#endif // !BUILDFLAG(IS_MAC)
|
||||
|
||||
class CookiesEnabled : public HeadlessAsyncDevTooledBrowserTest,
|
||||
page::Observer {
|
||||
|
Reference in New Issue
Block a user