Commit ab11af5e authored by Wez's avatar Wez Committed by Commit Bot

[Fuchsia] Clean up platform/OS/CPU portions of UserAgent.

- Fix UA string not to report Fuchsia as an X11 platform.
- Switch Fuchsia away from using the generic POSIX OS & CPU info logic,
  with the result that CPU architecture is no longer reported.

Bug: 936327
Change-Id: I691253d4f83457a68fcd5d2ce5e5efdf47834381
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1639741
Commit-Queue: Wez <wez@chromium.org>
Auto-Submit: Wez <wez@chromium.org>
Reviewed-by: default avatarThiemo Nagel <tnagel@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#666015}
parent f98488bf
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#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_MACOSX)) || defined(OS_FUCHSIA) #elif defined(OS_POSIX) && !defined(OS_MACOSX)
#include <sys/utsname.h> #include <sys/utsname.h>
#endif #endif
...@@ -30,17 +30,16 @@ const base::Feature kAndroidUserAgentStringContainsBuildId{ ...@@ -30,17 +30,16 @@ const base::Feature kAndroidUserAgentStringContainsBuildId{
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
std::string GetUserAgentPlatform() { std::string GetUserAgentPlatform() {
return #if defined(OS_WIN) || defined(OS_FUCHSIA)
#if defined(OS_WIN) return "";
"";
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
"Macintosh; "; return "Macintosh; ";
#elif defined(USE_X11) || defined(USE_OZONE) #elif defined(USE_X11) || defined(USE_OZONE)
"X11; "; // strange, but that's what Firefox uses return "X11; "; // strange, but that's what Firefox uses
#elif defined(OS_ANDROID) #elif defined(OS_ANDROID)
"Linux; "; return "Linux; ";
#elif defined(OS_POSIX) || defined(OS_FUCHSIA) #elif defined(OS_POSIX)
"Unknown; "; return "Unknown; ";
#endif #endif
} }
...@@ -86,7 +85,7 @@ std::string BuildOSCpuInfo(bool include_android_build_number) { ...@@ -86,7 +85,7 @@ std::string BuildOSCpuInfo(bool include_android_build_number) {
#elif defined(OS_ANDROID) #elif defined(OS_ANDROID)
std::string android_version_str = base::SysInfo::OperatingSystemVersion(); std::string android_version_str = base::SysInfo::OperatingSystemVersion();
std::string android_info_str = GetAndroidOSInfo(include_android_build_number); std::string android_info_str = GetAndroidOSInfo(include_android_build_number);
#elif (defined(OS_POSIX) && !defined(OS_MACOSX)) || defined(OS_FUCHSIA) #elif defined(OS_POSIX) && !defined(OS_MACOSX)
// Should work on any Posix system. // Should work on any Posix system.
struct utsname unixinfo; struct utsname unixinfo;
uname(&unixinfo); uname(&unixinfo);
...@@ -94,42 +93,36 @@ std::string BuildOSCpuInfo(bool include_android_build_number) { ...@@ -94,42 +93,36 @@ std::string BuildOSCpuInfo(bool include_android_build_number) {
std::string cputype; std::string cputype;
// special case for biarch systems // special case for biarch systems
if (strcmp(unixinfo.machine, "x86_64") == 0 && if (strcmp(unixinfo.machine, "x86_64") == 0 &&
sizeof(void*) == sizeof(int32_t)) { // NOLINT sizeof(void*) == sizeof(int32_t)) {
cputype.assign("i686 (x86_64)"); cputype.assign("i686 (x86_64)");
} else { } else {
cputype.assign(unixinfo.machine); cputype.assign(unixinfo.machine);
} }
#endif #endif
base::StringAppendF( base::StringAppendF(&os_cpu,
&os_cpu,
#if defined(OS_WIN) #if defined(OS_WIN)
"Windows NT %d.%d%s", "Windows NT %d.%d%s", os_major_version, os_minor_version,
os_major_version, architecture_token.c_str()
os_minor_version,
architecture_token.c_str()
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
"Intel Mac OS X %d_%d_%d", "Intel Mac OS X %d_%d_%d", os_major_version,
os_major_version, os_minor_version, os_bugfix_version
os_minor_version,
os_bugfix_version
#elif defined(OS_CHROMEOS) #elif defined(OS_CHROMEOS)
"CrOS " "CrOS "
"%s %d.%d.%d", "%s %d.%d.%d",
cputype.c_str(), // e.g. i686 cputype.c_str(), // e.g. i686
os_major_version, os_major_version, os_minor_version, os_bugfix_version
os_minor_version,
os_bugfix_version
#elif defined(OS_ANDROID) #elif defined(OS_ANDROID)
"Android %s%s", "Android %s%s", android_version_str.c_str(),
android_version_str.c_str(), android_info_str.c_str()
android_info_str.c_str() #elif defined(OS_FUCHSIA)
#elif defined(OS_POSIX) || defined(OS_FUCHSIA) "Fuchsia"
#elif defined(OS_POSIX)
"%s %s", "%s %s",
unixinfo.sysname, // e.g. Linux unixinfo.sysname, // e.g. Linux
cputype.c_str() // e.g. i686 cputype.c_str() // e.g. i686
#endif #endif
); // NOLINT );
return os_cpu; return os_cpu;
} }
......
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