158 lines
5.2 KiB
Diff
158 lines
5.2 KiB
Diff
From: csagan5 <32685696+csagan5@users.noreply.github.com>
|
|
Date: Wed, 21 Mar 2018 14:15:28 +0100
|
|
Subject: User Agent: anonymize
|
|
|
|
Use a fixed device name and Chrome product version with the goal of not
|
|
disclosing the specific build of Bromite.
|
|
---
|
|
components/version_info/version_info.cc | 13 +++++-
|
|
content/common/user_agent.cc | 72 ++++++++++++++++++++-------------
|
|
2 files changed, 57 insertions(+), 28 deletions(-)
|
|
|
|
diff --git a/components/version_info/version_info.cc b/components/version_info/version_info.cc
|
|
--- a/components/version_info/version_info.cc
|
|
+++ b/components/version_info/version_info.cc
|
|
@@ -7,13 +7,24 @@
|
|
#include "base/logging.h"
|
|
#include "base/no_destructor.h"
|
|
#include "base/version.h"
|
|
+#include "base/sys_info.h"
|
|
#include "build/build_config.h"
|
|
#include "components/version_info/version_info_values.h"
|
|
|
|
namespace version_info {
|
|
|
|
std::string GetProductNameAndVersionForUserAgent() {
|
|
- return "Chrome/" + GetVersionNumber();
|
|
+ int32_t major, minor, bugfix;
|
|
+ base::SysInfo::OperatingSystemVersionNumbers(&major,
|
|
+ &minor,
|
|
+ &bugfix);
|
|
+ switch (major) {
|
|
+ case 4:
|
|
+ return "Chrome/69.0.3497.100";
|
|
+ }
|
|
+
|
|
+ // version 5 and above
|
|
+ return "Chrome/70.0.3538.80";
|
|
}
|
|
|
|
std::string GetProductName() {
|
|
diff --git a/content/common/user_agent.cc b/content/common/user_agent.cc
|
|
--- a/content/common/user_agent.cc
|
|
+++ b/content/common/user_agent.cc
|
|
@@ -22,11 +22,6 @@
|
|
|
|
namespace content {
|
|
|
|
-#if defined(OS_ANDROID)
|
|
-const base::Feature kAndroidUserAgentStringContainsBuildId{
|
|
- "AndroidUserAgentStringContainsBuildId", base::FEATURE_DISABLED_BY_DEFAULT};
|
|
-#endif // defined(OS_ANDROID)
|
|
-
|
|
std::string GetWebKitVersion() {
|
|
return base::StringPrintf("%d.%d (%s)",
|
|
WEBKIT_VERSION_MAJOR,
|
|
@@ -66,7 +61,32 @@ std::string BuildOSCpuInfo(bool include_android_build_number) {
|
|
}
|
|
#elif defined(OS_ANDROID)
|
|
std::string android_version_str = base::SysInfo::OperatingSystemVersion();
|
|
- std::string android_info_str = GetAndroidOSInfo(include_android_build_number);
|
|
+ std::string android_info_str;
|
|
+
|
|
+ // Send information about the device and build ID.
|
|
+ // Use a common device/build ID based on Android major version.
|
|
+ switch (os_major_version) {
|
|
+ default: // version 9 and above
|
|
+ android_info_str = "ONEPLUS A6000";
|
|
+ break;
|
|
+ case 8:
|
|
+ android_info_str = "FIG-LX3";
|
|
+ break;
|
|
+ case 7:
|
|
+ android_info_str = "SM-G610M";
|
|
+ break;
|
|
+ case 6:
|
|
+ android_info_str = "SM-J700M";
|
|
+ break;
|
|
+ case 5:
|
|
+ android_info_str = "XT1033";
|
|
+ break;
|
|
+ case 4:
|
|
+ android_info_str = "ZTE Blade C370 Build/KOT49H";
|
|
+ break;
|
|
+ }
|
|
+
|
|
+ android_info_str = " " + android_info_str;
|
|
#elif (defined(OS_POSIX) && !defined(OS_MACOSX)) || defined(OS_FUCHSIA)
|
|
// Should work on any Posix system.
|
|
struct utsname unixinfo;
|
|
@@ -102,7 +122,7 @@ std::string BuildOSCpuInfo(bool include_android_build_number) {
|
|
os_minor_version,
|
|
os_bugfix_version
|
|
#elif defined(OS_ANDROID)
|
|
- "Android %s%s",
|
|
+ "Android %s;%s",
|
|
android_version_str.c_str(),
|
|
android_info_str.c_str()
|
|
#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
|
|
@@ -137,18 +157,6 @@ std::string BuildUserAgentFromProduct(const std::string& product) {
|
|
return BuildUserAgentFromOSAndProduct(os_info, product);
|
|
}
|
|
|
|
-#if defined(OS_ANDROID)
|
|
-std::string BuildUserAgentFromProductAndExtraOSInfo(
|
|
- const std::string& product,
|
|
- const std::string& extra_os_info,
|
|
- bool include_android_build_number) {
|
|
- std::string os_info;
|
|
- base::StringAppendF(&os_info, "%s%s%s", getUserAgentPlatform().c_str(),
|
|
- BuildOSCpuInfo(include_android_build_number).c_str(),
|
|
- extra_os_info.c_str());
|
|
- return BuildUserAgentFromOSAndProduct(os_info, product);
|
|
-}
|
|
-
|
|
std::string GetAndroidOSInfo(bool include_android_build_number) {
|
|
std::string android_info_str;
|
|
|
|
@@ -162,18 +170,28 @@ std::string GetAndroidOSInfo(bool include_android_build_number) {
|
|
}
|
|
|
|
// Append the build ID.
|
|
- if (base::FeatureList::IsEnabled(kAndroidUserAgentStringContainsBuildId) ||
|
|
- include_android_build_number) {
|
|
- std::string android_build_id = base::SysInfo::GetAndroidBuildID();
|
|
- if (!android_build_id.empty()) {
|
|
- if (!semicolon_inserted)
|
|
- android_info_str += ";";
|
|
- android_info_str += " Build/" + android_build_id;
|
|
- }
|
|
+ std::string android_build_id = base::SysInfo::GetAndroidBuildID();
|
|
+ if (!android_build_id.empty()) {
|
|
+ if (!semicolon_inserted)
|
|
+ android_info_str += ";";
|
|
+ android_info_str += " Build/" + android_build_id;
|
|
}
|
|
|
|
return android_info_str;
|
|
}
|
|
+
|
|
+#if defined(OS_ANDROID)
|
|
+std::string BuildUserAgentFromProductAndExtraOSInfo(
|
|
+ const std::string& product,
|
|
+ const std::string& extra_os_info,
|
|
+ bool include_android_build_number) {
|
|
+ std::string os_info;
|
|
+ base::StringAppendF(&os_info, "%s%s%s", getUserAgentPlatform().c_str(),
|
|
+ BuildOSCpuInfo(include_android_build_number).c_str(),
|
|
+ extra_os_info.c_str());
|
|
+ return BuildUserAgentFromOSAndProduct(os_info, product);
|
|
+}
|
|
+
|
|
#endif // defined(OS_ANDROID)
|
|
|
|
std::string BuildUserAgentFromOSAndProduct(const std::string& os_info,
|
|
--
|
|
2.11.0
|
|
|