content/common: 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: Ic35d7d343d8ea258a14181a5ac4b3534997728c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3373894
Reviewed-by: Nico Weber <thakis@chromium.org>
Owners-Override: Nico Weber <thakis@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#957330}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
de8109f0b3
commit
b317893a6b
content/common
ax_serialization_utils.ccchild_process_host_impl.cccontent_constants_internal.hcontent_message_generator.hcontent_navigation_policy.cccontent_param_traits_macros.hcontent_paths.cccontent_switches_internal.cc
cursors
drop_data_unittest.ccexternal_ipc_dumper.ccfont_list_unittest.ccinput
mojo_core_library_support.ccpartition_alloc_support.ccprofiling_utils.ccset_process_title.ccskia_utils.ccurl_schemes.ccurl_utils.ccurl_utils.hurl_utils_unittest.ccuser_agent.ccuser_agent_unittest.cc@ -9,7 +9,7 @@
|
||||
namespace content {
|
||||
|
||||
bool AXShouldIncludePageScaleFactorInRoot() {
|
||||
#if !defined(OS_ANDROID) && !defined(OS_MAC)
|
||||
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
|
@ -39,12 +39,12 @@
|
||||
#include "services/resource_coordinator/public/mojom/memory_instrumentation/constants.mojom.h"
|
||||
#include "services/service_manager/public/cpp/interface_provider.h"
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
#include "base/linux_util.h"
|
||||
#elif defined(OS_MAC)
|
||||
#elif BUILDFLAG(IS_MAC)
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "content/common/mac_helpers.h"
|
||||
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
namespace {
|
||||
|
||||
@ -71,7 +71,7 @@ base::FilePath ChildProcessHost::GetChildPath(int flags) {
|
||||
child_path = base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
|
||||
switches::kBrowserSubprocessPath);
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
// Use /proc/self/exe rather than our known binary path so updates
|
||||
// can't swap out the binary from underneath us.
|
||||
if (child_path.empty() && flags & CHILD_ALLOW_SELF)
|
||||
@ -83,7 +83,7 @@ base::FilePath ChildProcessHost::GetChildPath(int flags) {
|
||||
if (child_path.empty())
|
||||
base::PathService::Get(CHILD_PROCESS_EXE, &child_path);
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
std::string child_base_name = child_path.BaseName().value();
|
||||
|
||||
if (flags != CHILD_NORMAL && base::mac::AmIBundled()) {
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
namespace content {
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
// The mobile hang timer is shorter than the desktop hang timer because the
|
||||
// screen is smaller and more intimate, and therefore requires more nimbleness.
|
||||
constexpr base::TimeDelta kHungRendererDelay = base::Seconds(5);
|
||||
|
@ -8,10 +8,10 @@
|
||||
#include "build/build_config.h"
|
||||
#include "media/media_buildflags.h"
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
#undef CONTENT_COMMON_GIN_JAVA_BRIDGE_MESSAGES_H_
|
||||
#include "content/common/gin_java_bridge_messages.h"
|
||||
#ifndef CONTENT_COMMON_GIN_JAVA_BRIDGE_MESSAGES_H_
|
||||
#error "Failed to include content/common/gin_java_bridge_messages.h"
|
||||
#endif
|
||||
#endif // defined(OS_ANDROID)
|
||||
#endif // BUILDFLAG(IS_ANDROID)
|
||||
|
@ -26,7 +26,7 @@ bool DeviceHasEnoughMemoryForBackForwardCache() {
|
||||
// devices. The default threshold value is set to 1700 MB to account for all
|
||||
// 2GB devices which report lower RAM due to carveouts.
|
||||
int default_memory_threshold_mb =
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
1700;
|
||||
#else
|
||||
// Desktop has lower memory limitations compared to Android allowing us
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "ipc/ipc_message_macros.h"
|
||||
#include "ui/native_theme/native_theme.h"
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
#include "third_party/blink/public/platform/mac/web_scrollbar_theme.h"
|
||||
#endif
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(content::NavigationGesture,
|
||||
content::NavigationGestureLast)
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(blink::ScrollerStyle, blink::kScrollerStyleOverlay)
|
||||
#endif
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "base/path_service.h"
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
#include "base/mac/bundle_locations.h"
|
||||
#endif
|
||||
|
||||
|
@ -20,17 +20,17 @@
|
||||
#include "content/public/common/use_zoom_for_dsf_policy.h"
|
||||
#include "third_party/blink/public/mojom/v8_cache_options.mojom.h"
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
#include "base/debug/debugger.h"
|
||||
#include "base/feature_list.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_POSIX) && !defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID)
|
||||
#include <signal.h>
|
||||
static void SigUSR1Handler(int signal) {}
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "base/win/windows_version.h"
|
||||
|
||||
#include <windows.h>
|
||||
@ -40,7 +40,7 @@ namespace content {
|
||||
|
||||
namespace {
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
|
||||
std::wstring ToNativeString(base::StringPiece string) {
|
||||
return base::ASCIIToWide(string);
|
||||
@ -50,7 +50,7 @@ std::string FromNativeString(base::WStringPiece string) {
|
||||
return base::WideToASCII(string);
|
||||
}
|
||||
|
||||
#else // defined(OS_WIN)
|
||||
#else // BUILDFLAG(IS_WIN)
|
||||
|
||||
std::string ToNativeString(const std::string& string) {
|
||||
return string;
|
||||
@ -60,7 +60,7 @@ std::string FromNativeString(const std::string& string) {
|
||||
return string;
|
||||
}
|
||||
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -89,7 +89,7 @@ blink::mojom::V8CacheOptions GetV8CacheOptions() {
|
||||
}
|
||||
|
||||
void WaitForDebugger(const std::string& label) {
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
|
||||
std::string title = "Google Chrome";
|
||||
#else // BUILDFLAG(CHROMIUM_BRANDING)
|
||||
@ -102,8 +102,8 @@ void WaitForDebugger(const std::string& label) {
|
||||
message += base::NumberToString(base::GetCurrentProcId());
|
||||
::MessageBox(NULL, base::UTF8ToWide(message).c_str(),
|
||||
base::UTF8ToWide(title).c_str(), MB_OK | MB_SETFOREGROUND);
|
||||
#elif defined(OS_POSIX)
|
||||
#if defined(OS_ANDROID)
|
||||
#elif BUILDFLAG(IS_POSIX)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
LOG(ERROR) << label << " waiting for GDB.";
|
||||
// Wait 24 hours for a debugger to be attached to the current process.
|
||||
base::debug::WaitForDebugger(24 * 60 * 60, true);
|
||||
@ -121,8 +121,8 @@ void WaitForDebugger(const std::string& label) {
|
||||
sigaction(SIGUSR1, &sa, nullptr);
|
||||
|
||||
pause();
|
||||
#endif // defined(OS_ANDROID)
|
||||
#endif // defined(OS_POSIX)
|
||||
#endif // BUILDFLAG(IS_ANDROID)
|
||||
#endif // BUILDFLAG(IS_POSIX)
|
||||
}
|
||||
|
||||
std::vector<std::string> FeaturesFromSwitch(
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
#include "ui/gfx/geometry/skia_conversions.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include <windows.h>
|
||||
|
||||
#include "ui/base/win/win_cursor.h"
|
||||
@ -192,7 +192,7 @@ TEST(WebCursorTest, UnscaledImageCopy) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
void ScaleCursor(float scale, int hotspot_x, int hotspot_y) {
|
||||
ui::Cursor cursor(ui::mojom::CursorType::kCustom);
|
||||
cursor.set_custom_hotspot(gfx::Point(hotspot_x, hotspot_y));
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#define CONVERT_IF_NEEDED(x) base::UTF8ToWide((x))
|
||||
#else
|
||||
|
@ -17,7 +17,7 @@ typedef void (*SetDumpDirectoryFunction)(const base::FilePath&);
|
||||
const char kFilterEntryName[] = "GetFilter";
|
||||
const char kSetDumpDirectoryEntryName[] = "SetDumpDirectory";
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#define IPC_MESSAGE_DUMP_MODULE FILE_PATH_LITERAL("ipc_message_dump.dll")
|
||||
#else
|
||||
#define IPC_MESSAGE_DUMP_MODULE FILE_PATH_LITERAL("libipc_message_dump.so")
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
#if !defined(OS_ANDROID) && !defined(OS_FUCHSIA)
|
||||
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_FUCHSIA)
|
||||
bool HasFontWithName(const base::ListValue& list,
|
||||
base::StringPiece expected_font_id,
|
||||
base::StringPiece expected_display_name) {
|
||||
@ -32,11 +32,11 @@ bool HasFontWithName(const base::ListValue& list,
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif // !defined(OS_ANDROID) && !defined(OS_FUCHSI
|
||||
#endif // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_FUCHSIA)
|
||||
|
||||
} // namespace
|
||||
|
||||
#if !defined(OS_ANDROID) && !defined(OS_FUCHSIA)
|
||||
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_FUCHSIA)
|
||||
// GetFontList is not implemented on Android and Fuchsia.
|
||||
TEST(FontList, GetFontList) {
|
||||
base::test::TaskEnvironment task_environment;
|
||||
@ -47,11 +47,11 @@ TEST(FontList, GetFontList) {
|
||||
content::GetFontList_SlowBlocking();
|
||||
ASSERT_TRUE(fonts);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
EXPECT_TRUE(HasFontWithName(*fonts, "MS Gothic", "MS Gothic"));
|
||||
EXPECT_TRUE(HasFontWithName(*fonts, "Segoe UI", "Segoe UI"));
|
||||
EXPECT_TRUE(HasFontWithName(*fonts, "Verdana", "Verdana"));
|
||||
#elif defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
EXPECT_TRUE(HasFontWithName(*fonts, "Arimo", "Arimo"));
|
||||
#else
|
||||
EXPECT_TRUE(HasFontWithName(*fonts, "Arial", "Arial"));
|
||||
@ -59,9 +59,9 @@ TEST(FontList, GetFontList) {
|
||||
}));
|
||||
task_environment.RunUntilIdle();
|
||||
}
|
||||
#endif // !defined(OS_ANDROID) && !defined(OS_FUCHSIA)
|
||||
#endif // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_FUCHSIA)
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
TEST(FontList, GetFontListLocalized) {
|
||||
base::i18n::SetICUDefaultLocale("ja-JP");
|
||||
std::unique_ptr<base::ListValue> ja_fonts =
|
||||
@ -75,9 +75,9 @@ TEST(FontList, GetFontListLocalized) {
|
||||
ASSERT_TRUE(ko_fonts);
|
||||
EXPECT_TRUE(HasFontWithName(*ko_fonts, "Malgun Gothic", "맑은 고딕"));
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
// On some macOS versions, CTFontManager returns LastResort and/or hidden fonts.
|
||||
// Ensure that someone (CTFontManager or our FontList code) filters these fonts
|
||||
// on all OS versions that we support.
|
||||
@ -95,4 +95,4 @@ TEST(FontList, GetFontListDoesNotIncludeHiddenFonts) {
|
||||
<< font_id << " seems like a hidden font, which should be filtered";
|
||||
}
|
||||
}
|
||||
#endif // defined(OS_MAC)
|
||||
#endif // BUILDFLAG(IS_MAC)
|
||||
|
@ -25,7 +25,7 @@ bool SyntheticGestureParams::IsGestureSourceTypeSupported(
|
||||
#if defined(USE_AURA)
|
||||
return gesture_source_type == mojom::GestureSourceType::kTouchInput ||
|
||||
gesture_source_type == mojom::GestureSourceType::kMouseInput;
|
||||
#elif defined(OS_ANDROID)
|
||||
#elif BUILDFLAG(IS_ANDROID)
|
||||
// Android supports mouse wheel events, but mouse drag is not yet
|
||||
// supported. See crbug.com/468806.
|
||||
return gesture_source_type == mojom::GestureSourceType::kTouchInput ||
|
||||
|
@ -15,7 +15,7 @@ bool IsMojoCoreSharedLibraryEnabled() {
|
||||
}
|
||||
|
||||
absl::optional<base::FilePath> GetMojoCoreSharedLibraryPath() {
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
const base::CommandLine& command_line =
|
||||
*base::CommandLine::ForCurrentProcess();
|
||||
if (!command_line.HasSwitch(switches::kMojoCoreLibraryPath))
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "build/build_config.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
#include "base/system/sys_info.h"
|
||||
#endif
|
||||
|
||||
@ -373,20 +373,20 @@ void PartitionAllocSupport::ReconfigureAfterTaskRunnerInit(
|
||||
|
||||
base::allocator::StartThreadCachePeriodicPurge();
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
// Lower thread cache limits to avoid stranding too much memory in the caches.
|
||||
if (base::SysInfo::IsLowEndDevice()) {
|
||||
base::internal::ThreadCacheRegistry::Instance().SetThreadCacheMultiplier(
|
||||
base::internal::ThreadCache::kDefaultMultiplier / 2.);
|
||||
}
|
||||
#endif // defined(OS_ANDROID)
|
||||
#endif // BUILDFLAG(IS_ANDROID)
|
||||
|
||||
// Renderer processes are more performance-sensitive, increase thread cache
|
||||
// limits.
|
||||
if (process_type == switches::kRendererProcess &&
|
||||
base::FeatureList::IsEnabled(
|
||||
base::features::kPartitionAllocLargeThreadCacheSize)) {
|
||||
#if defined(OS_ANDROID) && !defined(ARCH_CPU_64_BITS)
|
||||
#if BUILDFLAG(IS_ANDROID) && !defined(ARCH_CPU_64_BITS)
|
||||
// Don't use a higher threshold on Android 32 bits, as long as memory usage
|
||||
// is not carefully tuned. Only control the threshold here to avoid changing
|
||||
// the rest of the code below.
|
||||
@ -398,7 +398,7 @@ void PartitionAllocSupport::ReconfigureAfterTaskRunnerInit(
|
||||
base::internal::ThreadCacheLimits::kLargeSizeThreshold;
|
||||
base::internal::ThreadCache::SetLargestCachedSize(
|
||||
base::internal::ThreadCacheLimits::kLargeSizeThreshold);
|
||||
#endif // defined(OS_ANDROID) && !defined(ARCH_CPU_64_BITS)
|
||||
#endif // BUILDFLAG(IS_ANDROID) && !defined(ARCH_CPU_64_BITS)
|
||||
}
|
||||
|
||||
#endif // defined(PA_THREAD_CACHE_SUPPORTED) &&
|
||||
|
@ -37,14 +37,14 @@ base::FilePath GetProfileFileDirectory() {
|
||||
|
||||
// Android differs from the other platforms because it's not possible to
|
||||
// write in base::DIR_CURRENT and environment variables aren't well supported.
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
base::PathService::Get(base::DIR_TEMP, &path);
|
||||
path = path.Append("pgo_profiles/");
|
||||
#else // !defined(OS_ANDROID)
|
||||
#else // !BUILDFLAG(IS_ANDROID)
|
||||
std::string prof_template;
|
||||
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
||||
if (env->GetVar("LLVM_PROFILE_FILE", &prof_template)) {
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
path = base::FilePath(base::UTF8ToWide(prof_template)).DirName();
|
||||
#else
|
||||
path = base::FilePath(prof_template).DirName();
|
||||
@ -74,7 +74,7 @@ base::File OpenProfilingFile() {
|
||||
int pool_index = base::RandInt(0, 3);
|
||||
std::string filename = base::StrCat(
|
||||
{"child_pool-", base::NumberToString(pool_index), ".profraw"});
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
path = path.Append(base::UTF8ToWide(filename));
|
||||
#else
|
||||
path = path.Append(filename);
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if defined(OS_POSIX) && !defined(OS_MAC) && !defined(OS_SOLARIS)
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_SOLARIS)
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
@ -24,9 +24,9 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#endif // defined(OS_POSIX) && !defined(OS_MAC) && !defined(OS_SOLARIS)
|
||||
#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_SOLARIS)
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
#include <errno.h> // Get program_invocation_short_name declaration.
|
||||
#include <sys/prctl.h>
|
||||
|
||||
@ -38,13 +38,13 @@
|
||||
#include "base/threading/platform_thread.h"
|
||||
// Linux/glibc doesn't natively have setproctitle().
|
||||
#include "content/common/set_process_title_linux.h"
|
||||
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
namespace content {
|
||||
|
||||
// TODO(jrg): Find out if setproctitle or equivalent is available on Android.
|
||||
#if defined(OS_POSIX) && !defined(OS_MAC) && !defined(OS_SOLARIS) && \
|
||||
!defined(OS_ANDROID) && !defined(OS_FUCHSIA)
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_SOLARIS) && \
|
||||
!BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_FUCHSIA)
|
||||
|
||||
void SetProcessTitleFromCommandLine(const char** main_argv) {
|
||||
// Build a single string which consists of all the arguments separated
|
||||
@ -53,7 +53,7 @@ void SetProcessTitleFromCommandLine(const char** main_argv) {
|
||||
std::string title;
|
||||
bool have_argv0 = false;
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
DCHECK_EQ(base::PlatformThread::CurrentId(), getpid());
|
||||
|
||||
if (main_argv)
|
||||
@ -88,7 +88,7 @@ void SetProcessTitleFromCommandLine(const char** main_argv) {
|
||||
*base_name_storage = std::move(base_name);
|
||||
program_invocation_short_name = &(*base_name_storage)[0];
|
||||
}
|
||||
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
const base::CommandLine* command_line =
|
||||
base::CommandLine::ForCurrentProcess();
|
||||
|
@ -35,7 +35,7 @@ void InitializeSkia() {
|
||||
|
||||
const int kMB = 1024 * 1024;
|
||||
size_t font_cache_limit;
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
font_cache_limit = base::SysInfo::IsLowEndDevice() ? kMB : 8 * kMB;
|
||||
SkGraphics::SetFontCacheLimit(font_cache_limit);
|
||||
#else
|
||||
|
@ -99,7 +99,7 @@ void RegisterContentSchemes(bool should_lock_registry) {
|
||||
for (auto& scheme : schemes.empty_document_schemes)
|
||||
url::AddEmptyDocumentScheme(scheme.c_str());
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
if (schemes.allow_non_standard_schemes_in_origins)
|
||||
url::EnableNonStandardSchemesForAndroidWebView();
|
||||
#endif
|
||||
|
@ -8,13 +8,14 @@
|
||||
|
||||
#include "base/check_op.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "build/build_config.h"
|
||||
#include "content/common/url_schemes.h"
|
||||
#include "content/public/common/url_constants.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
url::Origin OriginFromAndroidPackageName(const std::string& package_name) {
|
||||
return url::Origin::Create(
|
||||
GURL(base::StrCat({kAndroidAppScheme, ":", package_name})));
|
||||
@ -22,7 +23,7 @@ url::Origin OriginFromAndroidPackageName(const std::string& package_name) {
|
||||
#endif
|
||||
|
||||
bool IsAndroidAppOrigin(const absl::optional<url::Origin>& origin) {
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
return origin && origin->scheme() == kAndroidAppScheme;
|
||||
#else
|
||||
return false;
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
namespace content {
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
CONTENT_EXPORT url::Origin OriginFromAndroidPackageName(
|
||||
const std::string& package_name);
|
||||
#endif
|
||||
|
@ -69,7 +69,7 @@ TEST(UrlUtilsTest, IsSafeRedirectTarget) {
|
||||
#endif
|
||||
EXPECT_FALSE(
|
||||
IsSafeRedirectTarget(GURL(), CreateValidURL("blob:https://foo.com/bar")));
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
EXPECT_FALSE(
|
||||
IsSafeRedirectTarget(GURL(), CreateValidURL("content://foo.bar")));
|
||||
#endif
|
||||
|
@ -14,13 +14,13 @@
|
||||
#include "build/build_config.h"
|
||||
#include "build/util/chromium_git_revision.h"
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
#include "base/mac/mac_util.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "base/win/windows_version.h"
|
||||
#elif defined(OS_POSIX) && !defined(OS_MAC)
|
||||
#elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
#include <sys/utsname.h>
|
||||
#endif
|
||||
|
||||
@ -29,19 +29,19 @@ namespace content {
|
||||
namespace {
|
||||
|
||||
std::string GetUserAgentPlatform() {
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
return "";
|
||||
#elif defined(OS_MAC)
|
||||
#elif BUILDFLAG(IS_MAC)
|
||||
return "Macintosh; ";
|
||||
#elif defined(USE_OZONE)
|
||||
return "X11; "; // strange, but that's what Firefox uses
|
||||
#elif defined(OS_ANDROID)
|
||||
#elif BUILDFLAG(IS_ANDROID)
|
||||
return "Linux; ";
|
||||
#elif defined(OS_FUCHSIA)
|
||||
#elif BUILDFLAG(IS_FUCHSIA)
|
||||
// TODO(https://crbug.com/1225812): Determine what to report for Fuchsia,
|
||||
// considering both backwards compatibility and User-Agent Reduction.
|
||||
return "X11; ";
|
||||
#elif defined(OS_POSIX)
|
||||
#elif BUILDFLAG(IS_POSIX)
|
||||
return "Unknown; ";
|
||||
#endif
|
||||
}
|
||||
@ -49,13 +49,13 @@ std::string GetUserAgentPlatform() {
|
||||
} // namespace
|
||||
|
||||
std::string GetUnifiedPlatform() {
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
return frozen_user_agent_strings::kUnifiedPlatformAndroid;
|
||||
#elif defined(OS_CHROMEOS)
|
||||
#elif BUILDFLAG(IS_CHROMEOS)
|
||||
return frozen_user_agent_strings::kUnifiedPlatformCrOS;
|
||||
#elif defined(OS_MAC)
|
||||
#elif BUILDFLAG(IS_MAC)
|
||||
return frozen_user_agent_strings::kUnifiedPlatformMacOS;
|
||||
#elif defined(OS_WIN)
|
||||
#elif BUILDFLAG(IS_WIN)
|
||||
return frozen_user_agent_strings::kUnifiedPlatformWindows;
|
||||
#else
|
||||
return frozen_user_agent_strings::kUnifiedPlatformLinux;
|
||||
@ -74,9 +74,9 @@ std::string GetChromiumGitRevision() {
|
||||
std::string BuildCpuInfo() {
|
||||
std::string cpuinfo;
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
cpuinfo = "Intel";
|
||||
#elif defined(OS_WIN)
|
||||
#elif BUILDFLAG(IS_WIN)
|
||||
base::win::OSInfo* os_info = base::win::OSInfo::GetInstance();
|
||||
if (os_info->IsWowX86OnAMD64()) {
|
||||
cpuinfo = "WOW64";
|
||||
@ -88,7 +88,7 @@ std::string BuildCpuInfo() {
|
||||
else if (windows_architecture == base::win::OSInfo::IA64_ARCHITECTURE)
|
||||
cpuinfo = "Win64; IA64";
|
||||
}
|
||||
#elif defined(OS_POSIX) && !defined(OS_MAC)
|
||||
#elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
// Should work on any Posix system.
|
||||
struct utsname unixinfo;
|
||||
uname(&unixinfo);
|
||||
@ -108,7 +108,7 @@ std::string BuildCpuInfo() {
|
||||
// Return the CPU architecture in Windows/Mac/POSIX and the empty string
|
||||
// elsewhere.
|
||||
std::string GetLowEntropyCpuArchitecture() {
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
base::win::OSInfo::WindowsArchitecture windows_architecture =
|
||||
base::win::OSInfo::GetInstance()->GetArchitecture();
|
||||
base::win::OSInfo* os_info = base::win::OSInfo::GetInstance();
|
||||
@ -122,7 +122,7 @@ std::string GetLowEntropyCpuArchitecture() {
|
||||
(windows_architecture == base::win::OSInfo::X64_ARCHITECTURE)) {
|
||||
return "x86";
|
||||
}
|
||||
#elif defined(OS_MAC)
|
||||
#elif BUILDFLAG(IS_MAC)
|
||||
base::mac::CPUType cpu_type = base::mac::GetCPUType();
|
||||
if (cpu_type == base::mac::CPUType::kIntel) {
|
||||
return "x86";
|
||||
@ -130,7 +130,7 @@ std::string GetLowEntropyCpuArchitecture() {
|
||||
cpu_type == base::mac::CPUType::kTranslatedIntel) {
|
||||
return "arm";
|
||||
}
|
||||
#elif defined(OS_POSIX) && !defined(OS_ANDROID)
|
||||
#elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID)
|
||||
std::string cpu_info = BuildCpuInfo();
|
||||
if (base::StartsWith(cpu_info, "arm") ||
|
||||
base::StartsWith(cpu_info, "aarch")) {
|
||||
@ -145,14 +145,14 @@ std::string GetLowEntropyCpuArchitecture() {
|
||||
}
|
||||
|
||||
std::string GetLowEntropyCpuBitness() {
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
return (base::win::OSInfo::GetInstance()->GetArchitecture() ==
|
||||
base::win::OSInfo::X86_ARCHITECTURE)
|
||||
? "32"
|
||||
: "64";
|
||||
#elif defined(OS_MAC)
|
||||
#elif BUILDFLAG(IS_MAC)
|
||||
return "64";
|
||||
#elif defined(OS_POSIX) && !defined(OS_ANDROID)
|
||||
#elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID)
|
||||
return base::Contains(BuildCpuInfo(), "64") ? "64" : "32";
|
||||
#else
|
||||
return std::string();
|
||||
@ -162,14 +162,14 @@ std::string GetLowEntropyCpuBitness() {
|
||||
std::string GetOSVersion(IncludeAndroidBuildNumber include_android_build_number,
|
||||
IncludeAndroidModel include_android_model) {
|
||||
std::string os_version;
|
||||
#if defined(OS_WIN) || defined(OS_MAC) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS)
|
||||
int32_t os_major_version = 0;
|
||||
int32_t os_minor_version = 0;
|
||||
int32_t os_bugfix_version = 0;
|
||||
base::SysInfo::OperatingSystemVersionNumbers(
|
||||
&os_major_version, &os_minor_version, &os_bugfix_version);
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
// A significant amount of web content breaks if the reported "Mac
|
||||
// OS X" major version number is greater than 10. Continue to report
|
||||
// this as 10_15_7, the last dot release for that macOS version.
|
||||
@ -182,22 +182,22 @@ std::string GetOSVersion(IncludeAndroidBuildNumber include_android_build_number,
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
std::string android_version_str = base::SysInfo::OperatingSystemVersion();
|
||||
std::string android_info_str =
|
||||
GetAndroidOSInfo(include_android_build_number, include_android_model);
|
||||
#endif
|
||||
|
||||
base::StringAppendF(&os_version,
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
"%d.%d", os_major_version, os_minor_version
|
||||
#elif defined(OS_MAC)
|
||||
#elif BUILDFLAG(IS_MAC)
|
||||
"%d_%d_%d", os_major_version, os_minor_version,
|
||||
os_bugfix_version
|
||||
#elif defined(OS_CHROMEOS)
|
||||
#elif BUILDFLAG(IS_CHROMEOS)
|
||||
"%d.%d.%d", os_major_version, os_minor_version,
|
||||
os_bugfix_version
|
||||
#elif defined(OS_ANDROID)
|
||||
#elif BUILDFLAG(IS_ANDROID)
|
||||
"%s%s", android_version_str.c_str(),
|
||||
android_info_str.c_str()
|
||||
#else
|
||||
@ -219,13 +219,13 @@ std::string BuildOSCpuInfoFromOSVersionAndCpuType(const std::string& os_version,
|
||||
const std::string& cpu_type) {
|
||||
std::string os_cpu;
|
||||
|
||||
#if !defined(OS_ANDROID) && defined(OS_POSIX) && !defined(OS_MAC)
|
||||
#if !BUILDFLAG(IS_ANDROID) && BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
// Should work on any Posix system.
|
||||
struct utsname unixinfo;
|
||||
uname(&unixinfo);
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
if (!cpu_type.empty())
|
||||
base::StringAppendF(&os_cpu, "Windows NT %s; %s", os_version.c_str(),
|
||||
cpu_type.c_str());
|
||||
@ -233,18 +233,18 @@ std::string BuildOSCpuInfoFromOSVersionAndCpuType(const std::string& os_version,
|
||||
base::StringAppendF(&os_cpu, "Windows NT %s", os_version.c_str());
|
||||
#else
|
||||
base::StringAppendF(&os_cpu,
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
"%s Mac OS X %s", cpu_type.c_str(), os_version.c_str()
|
||||
#elif defined(OS_CHROMEOS)
|
||||
#elif BUILDFLAG(IS_CHROMEOS)
|
||||
"CrOS "
|
||||
"%s %s",
|
||||
cpu_type.c_str(), // e.g. i686
|
||||
os_version.c_str()
|
||||
#elif defined(OS_ANDROID)
|
||||
#elif BUILDFLAG(IS_ANDROID)
|
||||
"Android %s", os_version.c_str()
|
||||
#elif defined(OS_FUCHSIA)
|
||||
#elif BUILDFLAG(IS_FUCHSIA)
|
||||
"Fuchsia"
|
||||
#elif defined(OS_POSIX)
|
||||
#elif BUILDFLAG(IS_POSIX)
|
||||
"%s %s",
|
||||
unixinfo.sysname, // e.g. Linux
|
||||
cpu_type.c_str() // e.g. i686
|
||||
@ -257,7 +257,7 @@ std::string BuildOSCpuInfoFromOSVersionAndCpuType(const std::string& os_version,
|
||||
|
||||
std::string GetReducedUserAgent(bool mobile, std::string major_version) {
|
||||
std::string user_agent;
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
std::string device_compat;
|
||||
// Note: The extra space after Mobile is meaningful here, to avoid
|
||||
// "MobileSafari", but unneeded for non-mobile Android devices.
|
||||
@ -285,7 +285,7 @@ std::string BuildUserAgentFromProduct(const std::string& product) {
|
||||
|
||||
std::string BuildModelInfo() {
|
||||
std::string model;
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
// Only send the model information if on the release build of Android,
|
||||
// matching user agent behaviour.
|
||||
if (base::SysInfo::GetAndroidBuildCodename() == "REL")
|
||||
@ -294,7 +294,7 @@ std::string BuildModelInfo() {
|
||||
return model;
|
||||
}
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
std::string BuildUserAgentFromProductAndExtraOSInfo(
|
||||
const std::string& product,
|
||||
const std::string& extra_os_info,
|
||||
@ -334,7 +334,7 @@ std::string GetAndroidOSInfo(
|
||||
|
||||
return android_info_str;
|
||||
}
|
||||
#endif // defined(OS_ANDROID)
|
||||
#endif // BUILDFLAG(IS_ANDROID)
|
||||
|
||||
std::string BuildUserAgentFromOSAndProduct(const std::string& os_info,
|
||||
const std::string& product) {
|
||||
|
@ -22,7 +22,7 @@ struct BuildOSCpuInfoTestCases {
|
||||
|
||||
TEST(UserAgentStringTest, BuildOSCpuInfoFromOSVersionAndCpuType) {
|
||||
const BuildOSCpuInfoTestCases test_cases[] = {
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// On Windows, it's possible to have an empty string for CPU type.
|
||||
{
|
||||
/*os_version=*/"10.0",
|
||||
@ -56,7 +56,7 @@ TEST(UserAgentStringTest, BuildOSCpuInfoFromOSVersionAndCpuType) {
|
||||
/*cpu_type=*/"CPU TYPE",
|
||||
/*expected_os_cpu_info=*/"Windows NT VERSION; CPU TYPE",
|
||||
},
|
||||
#elif defined(OS_MAC)
|
||||
#elif BUILDFLAG(IS_MAC)
|
||||
{
|
||||
/*os_version=*/"10_15_4",
|
||||
/*cpu_type=*/"Intel",
|
||||
@ -92,7 +92,7 @@ TEST(UserAgentStringTest, BuildOSCpuInfoFromOSVersionAndCpuType) {
|
||||
/*cpu_type=*/"CPU TYPE",
|
||||
/*expected_os_cpu_info=*/"CrOS CPU TYPE VERSION",
|
||||
},
|
||||
#elif defined(OS_ANDROID)
|
||||
#elif BUILDFLAG(IS_ANDROID)
|
||||
{
|
||||
/*os_version=*/"7.1.1",
|
||||
/*cpu_type=*/"UNUSED",
|
||||
@ -110,7 +110,7 @@ TEST(UserAgentStringTest, BuildOSCpuInfoFromOSVersionAndCpuType) {
|
||||
/*cpu_type=*/"CPU TYPE",
|
||||
/*expected_os_cpu_info=*/"Android VERSION",
|
||||
},
|
||||
#elif defined(OS_FUCHSIA)
|
||||
#elif BUILDFLAG(IS_FUCHSIA)
|
||||
{
|
||||
/*os_version=*/"VERSION",
|
||||
/*cpu_type=*/"CPU TYPE",
|
||||
@ -129,8 +129,8 @@ TEST(UserAgentStringTest, BuildOSCpuInfoFromOSVersionAndCpuType) {
|
||||
TEST(UserAgentStringTest, LowEntropyCpuArchitecture) {
|
||||
std::string arch = GetLowEntropyCpuArchitecture();
|
||||
|
||||
#if defined(OS_WIN) || defined(OS_MAC) || \
|
||||
(defined(OS_POSIX) && !defined(OS_ANDROID))
|
||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || \
|
||||
(BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID))
|
||||
EXPECT_TRUE("arm" == arch || "x86" == arch);
|
||||
#else
|
||||
EXPECT_EQ("", arch);
|
||||
|
Reference in New Issue
Block a user