Commit 4ff232db authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Implement Sec-CH-UA-Arch for the Mac

Bug: 1110914
Change-Id: I5d6375da9a9e9855e5a8b568fcd9914e39fa94f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2382228Reviewed-by: default avatarAaron Tagliaboschi <aarontag@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803261}
parent 53478cae
...@@ -753,11 +753,11 @@ TEST(ChromeContentBrowserClientTest, GenerateBrandVersionList) { ...@@ -753,11 +753,11 @@ TEST(ChromeContentBrowserClientTest, GenerateBrandVersionList) {
TEST(ChromeContentBrowserClientTest, LowEntropyCpuArchitecture) { TEST(ChromeContentBrowserClientTest, LowEntropyCpuArchitecture) {
std::string arch = content::GetLowEntropyCpuArchitecture(); std::string arch = content::GetLowEntropyCpuArchitecture();
#if (!defined(OS_POSIX) && !defined(OS_WIN)) || defined(OS_MAC) || \ #if defined(OS_WIN) || defined(OS_MAC) || \
defined(OS_ANDROID) (defined(OS_POSIX) && !defined(OS_ANDROID))
EXPECT_EQ("", arch);
#elif (defined(OS_POSIX) && !defined(OS_MAC)) || defined(OS_WIN)
EXPECT_TRUE("arm" == arch || "x86" == arch); EXPECT_TRUE("arm" == arch || "x86" == arch);
#else
EXPECT_EQ("", arch);
#endif #endif
} }
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
#include "build/lacros_buildflags.h" #include "build/lacros_buildflags.h"
#include "build/util/webkit_version.h" #include "build/util/webkit_version.h"
#if defined(OS_MAC)
#include "base/mac/mac_util.h"
#endif
#if defined(OS_WIN) #if defined(OS_WIN)
#include "base/win/windows_version.h" #include "base/win/windows_version.h"
#elif defined(OS_POSIX) && !defined(OS_MAC) #elif defined(OS_POSIX) && !defined(OS_MAC)
...@@ -90,10 +94,27 @@ std::string BuildCpuInfo() { ...@@ -90,10 +94,27 @@ std::string BuildCpuInfo() {
return cpuinfo; return cpuinfo;
} }
// Return the CPU architecture in Linux or Windows and the empty string // Return the CPU architecture in Windows/Mac/POSIX and the empty string
// elsewhere. // elsewhere.
std::string GetLowEntropyCpuArchitecture() { std::string GetLowEntropyCpuArchitecture() {
#if !defined(OS_MAC) && !defined(OS_ANDROID) && defined(OS_POSIX) #if defined(OS_WIN)
base::win::OSInfo::WindowsArchitecture windows_architecture =
base::win::OSInfo::GetInstance()->GetArchitecture();
if (windows_architecture == base::win::OSInfo::ARM64_ARCHITECTURE) {
return "arm";
} else if ((windows_architecture == base::win::OSInfo::X86_ARCHITECTURE) ||
(windows_architecture == base::win::OSInfo::X64_ARCHITECTURE)) {
return "x86";
}
#elif defined(OS_MAC)
base::mac::CPUType cpu_type = base::mac::GetCPUType();
if (cpu_type == base::mac::CPUType::kIntel) {
return "x86";
} else if (cpu_type == base::mac::CPUType::kArm ||
cpu_type == base::mac::CPUType::kTranslatedIntel) {
return "arm";
}
#elif defined(OS_POSIX) && !defined(OS_ANDROID)
// This extra cpu_info_str variable is required to make sure the compiler // This extra cpu_info_str variable is required to make sure the compiler
// doesn't optimize the copy away and have the StringPiece point at the // doesn't optimize the copy away and have the StringPiece point at the
// internal std::string, resulting in a memory violation. // internal std::string, resulting in a memory violation.
...@@ -107,15 +128,6 @@ std::string GetLowEntropyCpuArchitecture() { ...@@ -107,15 +128,6 @@ std::string GetLowEntropyCpuArchitecture() {
base::StartsWith(cpu_info, "x86")) { base::StartsWith(cpu_info, "x86")) {
return "x86"; return "x86";
} }
#elif defined(OS_WIN)
base::win::OSInfo::WindowsArchitecture windows_architecture =
base::win::OSInfo::GetInstance()->GetArchitecture();
if (windows_architecture == base::win::OSInfo::ARM64_ARCHITECTURE) {
return "arm";
} else if ((windows_architecture == base::win::OSInfo::X86_ARCHITECTURE) ||
(windows_architecture == base::win::OSInfo::X64_ARCHITECTURE)) {
return "x86";
}
#endif #endif
return std::string(); return std::string();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment