Pull request #13: AP9-2666 change Android userAgent to deskmode userAgent
Merge in AP/chromiumpatches from AP9-2666 to master * commit 'fae5e4a4645c1e863a638bf975d4174864f85253': AP9-2666 change Android userAgent to deskmode userAgent
This commit is contained in:
commit
c76fe1c1fc
2 changed files with 102 additions and 0 deletions
|
@ -167,3 +167,4 @@ Automated-domain-substitution.patch
|
|||
Turn-AdBlock-off-by-default.patch
|
||||
Force-tablet-mode.patch
|
||||
Set-default-page-url.patch
|
||||
change-Android-userAgent-to-deskmode-userAgent.patch
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
From b51c81df60e34bbd00f448b554a0f573ec934218 Mon Sep 17 00:00:00 2001
|
||||
From: "guangxi.chen" <gxchen@nd.com.cn>
|
||||
Date: Fri, 19 Nov 2021 02:01:39 +0000
|
||||
Subject: [PATCH] change Android userAgent to deskmode userAgent
|
||||
|
||||
---
|
||||
content/common/user_agent.cc | 33 +++++++++++----------------------
|
||||
1 file changed, 11 insertions(+), 22 deletions(-)
|
||||
|
||||
diff --git a/content/common/user_agent.cc b/content/common/user_agent.cc
|
||||
index 6d76b0ef5de5e..e6d3dfa27d831 100644
|
||||
--- a/content/common/user_agent.cc
|
||||
+++ b/content/common/user_agent.cc
|
||||
@@ -37,7 +37,7 @@ std::string GetUserAgentPlatform() {
|
||||
#elif defined(USE_X11) || defined(USE_OZONE)
|
||||
return "X11; "; // strange, but that's what Firefox uses
|
||||
#elif defined(OS_ANDROID)
|
||||
- return "Linux; ";
|
||||
+ return "X11; ";
|
||||
#elif defined(OS_FUCHSIA)
|
||||
// TODO(https://crbug.com/1225812): Determine what to report for Fuchsia,
|
||||
// considering both backwards compatibility and User-Agent Reduction.
|
||||
@@ -50,9 +50,7 @@ std::string GetUserAgentPlatform() {
|
||||
} // namespace
|
||||
|
||||
std::string GetUnifiedPlatform() {
|
||||
-#if defined(OS_ANDROID)
|
||||
- return frozen_user_agent_strings::kUnifiedPlatformAndroid;
|
||||
-#elif BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
return frozen_user_agent_strings::kUnifiedPlatformCrOS;
|
||||
#elif defined(OS_MAC)
|
||||
return frozen_user_agent_strings::kUnifiedPlatformMacOS;
|
||||
@@ -216,7 +214,7 @@ 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 defined(OS_POSIX) && !defined(OS_MAC)
|
||||
// Should work on any Posix system.
|
||||
struct utsname unixinfo;
|
||||
uname(&unixinfo);
|
||||
@@ -238,7 +236,9 @@ std::string BuildOSCpuInfoFromOSVersionAndCpuType(const std::string& os_version,
|
||||
cpu_type.c_str(), // e.g. i686
|
||||
os_version.c_str()
|
||||
#elif defined(OS_ANDROID)
|
||||
- "Android %s", os_version.c_str()
|
||||
+ "%s %s",
|
||||
+ unixinfo.sysname, // e.g. Linux
|
||||
+ cpu_type.c_str() // e.g. i686
|
||||
#elif defined(OS_FUCHSIA)
|
||||
"Fuchsia"
|
||||
#elif defined(OS_POSIX)
|
||||
@@ -254,20 +254,9 @@ 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)
|
||||
- std::string device_compat;
|
||||
- // Note: The extra space after Mobile is meaningful here, to avoid
|
||||
- // "MobileSafari", but unneeded for non-mobile Android devices.
|
||||
- device_compat = mobile ? "Mobile " : "";
|
||||
- user_agent = base::StringPrintf(frozen_user_agent_strings::kAndroid,
|
||||
- GetUnifiedPlatform().c_str(),
|
||||
- major_version.c_str(), device_compat.c_str());
|
||||
-#else
|
||||
user_agent =
|
||||
base::StringPrintf(frozen_user_agent_strings::kDesktop,
|
||||
GetUnifiedPlatform().c_str(), major_version.c_str());
|
||||
-#endif
|
||||
-
|
||||
return user_agent;
|
||||
}
|
||||
|
||||
@@ -292,10 +281,10 @@ std::string BuildUserAgentFromProductAndExtraOSInfo(
|
||||
const std::string& extra_os_info,
|
||||
IncludeAndroidBuildNumber include_android_build_number) {
|
||||
std::string os_info;
|
||||
- base::StrAppend(&os_info, {GetUserAgentPlatform(),
|
||||
- BuildOSCpuInfo(include_android_build_number,
|
||||
- IncludeAndroidModel::Include),
|
||||
- extra_os_info});
|
||||
+ base::StringAppendF(&os_info, "%s%s", GetUserAgentPlatform().c_str(),
|
||||
+ BuildOSCpuInfo(IncludeAndroidBuildNumber::Exclude,
|
||||
+ IncludeAndroidModel::Include)
|
||||
+ .c_str());
|
||||
return BuildUserAgentFromOSAndProduct(os_info, product);
|
||||
}
|
||||
|
||||
@@ -337,7 +326,7 @@ std::string BuildUserAgentFromOSAndProduct(const std::string& os_info,
|
||||
base::StringAppendF(&user_agent,
|
||||
"Mozilla/5.0 (%s) AppleWebKit/537.36 (KHTML, like Gecko) "
|
||||
"%s Safari/537.36",
|
||||
- os_info.c_str(), product.c_str());
|
||||
+ os_info.c_str(), "");
|
||||
return user_agent;
|
||||
}
|
||||
|
||||
--
|
||||
2.17.1
|
||||
|
Loading…
Add table
Reference in a new issue