Commit 6c119130 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Put code in an anonymous namespace inside content/common/user_agent.cc.

Not all code in the file needs to be visible to the outside. Also use
the appropriate naming style for functions.

Change-Id: I4f22df2932954b71ce65232a019cfcddd5fd408b
Reviewed-on: https://chromium-review.googlesource.com/c/1336521Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608215}
parent 9fba96a9
...@@ -22,11 +22,30 @@ ...@@ -22,11 +22,30 @@
namespace content { namespace content {
namespace {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
const base::Feature kAndroidUserAgentStringContainsBuildId{ const base::Feature kAndroidUserAgentStringContainsBuildId{
"AndroidUserAgentStringContainsBuildId", base::FEATURE_DISABLED_BY_DEFAULT}; "AndroidUserAgentStringContainsBuildId", base::FEATURE_DISABLED_BY_DEFAULT};
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
std::string GetUserAgentPlatform() {
return
#if defined(OS_WIN)
"";
#elif defined(OS_MACOSX)
"Macintosh; ";
#elif defined(USE_X11) || defined(USE_OZONE)
"X11; "; // strange, but that's what Firefox uses
#elif defined(OS_ANDROID)
"Linux; ";
#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
"Unknown; ";
#endif
}
} // namespace
std::string GetWebKitVersion() { std::string GetWebKitVersion() {
return base::StringPrintf("%d.%d (%s)", return base::StringPrintf("%d.%d (%s)",
WEBKIT_VERSION_MAJOR, WEBKIT_VERSION_MAJOR,
...@@ -115,24 +134,9 @@ std::string BuildOSCpuInfo(bool include_android_build_number) { ...@@ -115,24 +134,9 @@ std::string BuildOSCpuInfo(bool include_android_build_number) {
return os_cpu; return os_cpu;
} }
std::string getUserAgentPlatform() {
return
#if defined(OS_WIN)
"";
#elif defined(OS_MACOSX)
"Macintosh; ";
#elif defined(USE_X11) || defined(USE_OZONE)
"X11; "; // strange, but that's what Firefox uses
#elif defined(OS_ANDROID)
"Linux; ";
#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
"Unknown; ";
#endif
}
std::string BuildUserAgentFromProduct(const std::string& product) { std::string BuildUserAgentFromProduct(const std::string& product) {
std::string os_info; std::string os_info;
base::StringAppendF(&os_info, "%s%s", getUserAgentPlatform().c_str(), base::StringAppendF(&os_info, "%s%s", GetUserAgentPlatform().c_str(),
BuildOSCpuInfo(false).c_str()); BuildOSCpuInfo(false).c_str());
return BuildUserAgentFromOSAndProduct(os_info, product); return BuildUserAgentFromOSAndProduct(os_info, product);
} }
...@@ -143,7 +147,7 @@ std::string BuildUserAgentFromProductAndExtraOSInfo( ...@@ -143,7 +147,7 @@ std::string BuildUserAgentFromProductAndExtraOSInfo(
const std::string& extra_os_info, const std::string& extra_os_info,
bool include_android_build_number) { bool include_android_build_number) {
std::string os_info; std::string os_info;
base::StringAppendF(&os_info, "%s%s%s", getUserAgentPlatform().c_str(), base::StringAppendF(&os_info, "%s%s%s", GetUserAgentPlatform().c_str(),
BuildOSCpuInfo(include_android_build_number).c_str(), BuildOSCpuInfo(include_android_build_number).c_str(),
extra_os_info.c_str()); extra_os_info.c_str());
return BuildUserAgentFromOSAndProduct(os_info, product); return BuildUserAgentFromOSAndProduct(os_info, product);
......
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