Commit 15417f9f authored by Melissa Galonsky's avatar Melissa Galonsky Committed by Commit Bot

Remove the build id from the Chrome Android user agent for all non-Web View cases.

Per crbug.com/860229, removes the Android build number from the Android user agent, but creates a
Finch experiment that allows the change to be re-enabled.  Does not apply the change to Android
Web View as mandated by the Android Compatibility Definition Document.


Bug: 860229
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I57c24994958d840c80600356f12b2ce20c8a9f74
Reviewed-on: https://chromium-review.googlesource.com/1157225
Commit-Queue: Melissa Galonsky <mgalonsky@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Reviewed-by: default avatarNick Harper <nharper@chromium.org>
Reviewed-by: default avatarRyo Hashimoto <hashimoto@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582186}
parent 00f54c8b
...@@ -37,7 +37,8 @@ std::string GetUserAgent() { ...@@ -37,7 +37,8 @@ std::string GetUserAgent() {
switches::kUseMobileUserAgent)) { switches::kUseMobileUserAgent)) {
product += " Mobile"; product += " Mobile";
} }
return content::BuildUserAgentFromProductAndExtraOSInfo(product, "; wv"); return content::BuildUserAgentFromProductAndExtraOSInfo(
product, "; wv", true /* include_android_build_number */);
} }
void AwContentClient::AddAdditionalSchemes(Schemes* schemes) { void AwContentClient::AddAdditionalSchemes(Schemes* schemes) {
......
...@@ -101,7 +101,8 @@ std::string GetDriveUserAgent() { ...@@ -101,7 +101,8 @@ std::string GetDriveUserAgent() {
// This part is <client_name>/<version>. // This part is <client_name>/<version>.
const char kLibraryInfo[] = "chrome-cc/none"; const char kLibraryInfo[] = "chrome-cc/none";
const std::string os_cpu_info = content::BuildOSCpuInfo(); const std::string os_cpu_info =
content::BuildOSCpuInfo(false /* include_android_build_number */);
// Add "gzip" to receive compressed data from the server. // Add "gzip" to receive compressed data from the server.
// (see https://developers.google.com/drive/performance) // (see https://developers.google.com/drive/performance)
......
...@@ -49,7 +49,8 @@ network::mojom::NetworkContextParamsPtr CreateDefaultNetworkContextParams() { ...@@ -49,7 +49,8 @@ network::mojom::NetworkContextParamsPtr CreateDefaultNetworkContextParams() {
quic_user_agent_id.append( quic_user_agent_id.append(
version_info::GetProductNameAndVersionForUserAgent()); version_info::GetProductNameAndVersionForUserAgent());
quic_user_agent_id.push_back(' '); quic_user_agent_id.push_back(' ');
quic_user_agent_id.append(content::BuildOSCpuInfo()); quic_user_agent_id.append(
content::BuildOSCpuInfo(false /* include_android_build_number */));
network_context_params->quic_user_agent_id = quic_user_agent_id; network_context_params->quic_user_agent_id = quic_user_agent_id;
const base::CommandLine& command_line = const base::CommandLine& command_line =
......
...@@ -74,7 +74,7 @@ std::string GetUserAgent() { ...@@ -74,7 +74,7 @@ std::string GetUserAgent() {
BuildAndroidOsInfo().c_str() BuildAndroidOsInfo().c_str()
#else #else
"X11; ", "X11; ",
content::BuildOSCpuInfo().c_str() content::BuildOSCpuInfo(false /* include_android_build_number */).c_str()
#endif #endif
); );
return content::BuildUserAgentFromOSAndProduct(os_info, product) + return content::BuildUserAgentFromOSAndProduct(os_info, product) +
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <stdint.h> #include <stdint.h>
#include "base/feature_list.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
...@@ -21,6 +22,11 @@ ...@@ -21,6 +22,11 @@
namespace content { namespace content {
#if defined(OS_ANDROID)
const base::Feature kAndroidUserAgentStringContainsBuildId{
"AndroidUserAgentStringContainsBuildId", base::FEATURE_DISABLED_BY_DEFAULT};
#endif // defined(OS_ANDROID)
std::string GetWebKitVersion() { std::string GetWebKitVersion() {
return base::StringPrintf("%d.%d (%s)", return base::StringPrintf("%d.%d (%s)",
WEBKIT_VERSION_MAJOR, WEBKIT_VERSION_MAJOR,
...@@ -32,7 +38,7 @@ std::string GetWebKitRevision() { ...@@ -32,7 +38,7 @@ std::string GetWebKitRevision() {
return WEBKIT_SVN_REVISION; return WEBKIT_SVN_REVISION;
} }
std::string BuildOSCpuInfo() { std::string BuildOSCpuInfo(bool include_android_build_number) {
std::string os_cpu; std::string os_cpu;
#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) ||\ #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) ||\
...@@ -73,13 +79,17 @@ std::string BuildOSCpuInfo() { ...@@ -73,13 +79,17 @@ std::string BuildOSCpuInfo() {
} }
// Append the build ID. // Append the build ID.
std::string android_build_id = base::SysInfo::GetAndroidBuildID(); if (base::FeatureList::IsEnabled(kAndroidUserAgentStringContainsBuildId) ||
if (android_build_id.size() > 0) { include_android_build_number) {
if (!semicolon_inserted) { std::string android_build_id = base::SysInfo::GetAndroidBuildID();
android_info_str += ";"; if (android_build_id.size() > 0) {
if (!semicolon_inserted) {
android_info_str += ";";
}
android_info_str += " Build/" + android_build_id;
} }
android_info_str += " Build/" + android_build_id;
} }
#elif (defined(OS_POSIX) && !defined(OS_MACOSX)) || defined(OS_FUCHSIA) #elif (defined(OS_POSIX) && !defined(OS_MACOSX)) || defined(OS_FUCHSIA)
// Should work on any Posix system. // Should work on any Posix system.
struct utsname unixinfo; struct utsname unixinfo;
...@@ -145,26 +155,23 @@ std::string getUserAgentPlatform() { ...@@ -145,26 +155,23 @@ std::string getUserAgentPlatform() {
std::string BuildUserAgentFromProduct(const std::string& product) { std::string BuildUserAgentFromProduct(const std::string& product) {
std::string os_info; std::string os_info;
base::StringAppendF( base::StringAppendF(&os_info, "%s%s", getUserAgentPlatform().c_str(),
&os_info, BuildOSCpuInfo(false).c_str());
"%s%s",
getUserAgentPlatform().c_str(),
BuildOSCpuInfo().c_str());
return BuildUserAgentFromOSAndProduct(os_info, product); return BuildUserAgentFromOSAndProduct(os_info, product);
} }
#if defined(OS_ANDROID)
std::string BuildUserAgentFromProductAndExtraOSInfo( std::string BuildUserAgentFromProductAndExtraOSInfo(
const std::string& product, const std::string& product,
const std::string& extra_os_info) { const std::string& extra_os_info,
const bool include_android_build_number) {
std::string os_info; std::string os_info;
base::StringAppendF( base::StringAppendF(&os_info, "%s%s%s", getUserAgentPlatform().c_str(),
&os_info, BuildOSCpuInfo(include_android_build_number).c_str(),
"%s%s%s", extra_os_info.c_str());
getUserAgentPlatform().c_str(),
BuildOSCpuInfo().c_str(),
extra_os_info.c_str());
return BuildUserAgentFromOSAndProduct(os_info, product); return BuildUserAgentFromOSAndProduct(os_info, product);
} }
#endif
std::string BuildUserAgentFromOSAndProduct(const std::string& os_info, std::string BuildUserAgentFromOSAndProduct(const std::string& os_info,
const std::string& product) { const std::string& product) {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <string> #include <string>
#include "build/build_config.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
namespace content { namespace content {
...@@ -17,18 +18,24 @@ CONTENT_EXPORT std::string GetWebKitVersion(); ...@@ -17,18 +18,24 @@ CONTENT_EXPORT std::string GetWebKitVersion();
CONTENT_EXPORT std::string GetWebKitRevision(); CONTENT_EXPORT std::string GetWebKitRevision();
// Builds a User-agent compatible string that describes the OS and CPU type. // Builds a User-agent compatible string that describes the OS and CPU type.
CONTENT_EXPORT std::string BuildOSCpuInfo(); // On Android, the string will only include the build number if true is passed
// as an argument.
CONTENT_EXPORT std::string BuildOSCpuInfo(bool include_android_build_number);
// Helper function to generate a full user agent string from a short // Helper function to generate a full user agent string from a short
// product name. // product name.
CONTENT_EXPORT std::string BuildUserAgentFromProduct( CONTENT_EXPORT std::string BuildUserAgentFromProduct(
const std::string& product); const std::string& product);
#if defined(OS_ANDROID)
// Helper function to generate a full user agent string given a short // Helper function to generate a full user agent string given a short
// product name and some extra text to be added to the OS info. // product name and some extra text to be added to the OS info.
// This is currently only used for Android Web View.
CONTENT_EXPORT std::string BuildUserAgentFromProductAndExtraOSInfo( CONTENT_EXPORT std::string BuildUserAgentFromProductAndExtraOSInfo(
const std::string& product, const std::string& product,
const std::string& extra_os_info); const std::string& extra_os_info,
const bool include_android_build_number);
#endif
// Builds a full user agent string given a string describing the OS and a // Builds a full user agent string given a string describing the OS and a
// product name. // product name.
......
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