Chromium Code Reviews| Index: chromecast/common/cast_content_client.cc |
| diff --git a/chromecast/common/cast_content_client.cc b/chromecast/common/cast_content_client.cc |
| index e93b7d2a51bfe0387389992ccfded75bc297286a..a56328563290780f67b9454c7b0fe2baaf48b9a0 100644 |
| --- a/chromecast/common/cast_content_client.cc |
| +++ b/chromecast/common/cast_content_client.cc |
| @@ -4,6 +4,8 @@ |
| #include "chromecast/common/cast_content_client.h" |
| +#include "base/strings/stringprintf.h" |
| +#include "base/sys_info.h" |
| #include "chromecast/common/version.h" |
| #include "content/public/common/user_agent.h" |
| #include "ui/base/l10n/l10n_util.h" |
| @@ -12,9 +14,55 @@ |
| namespace chromecast { |
| namespace shell { |
| +namespace { |
| + |
| +#if defined(OS_ANDROID) |
| +std::string BuildAndroidOsInfo() { |
| + int32 os_major_version = 0; |
| + int32 os_minor_version = 0; |
| + int32 os_bugfix_version = 0; |
| + base::SysInfo::OperatingSystemVersionNumbers(&os_major_version, |
| + &os_minor_version, |
| + &os_bugfix_version); |
| + |
| + std::string android_version_str; |
| + base::StringAppendF( |
| + &android_version_str, "%d.%d", os_major_version, os_minor_version); |
| + if (os_bugfix_version != 0) |
| + base::StringAppendF(&android_version_str, ".%d", os_bugfix_version); |
| + |
| + std::string android_info_str; |
| + // Append the build ID. |
| + std::string android_build_id = base::SysInfo::GetAndroidBuildID(); |
| + if (android_build_id.size() > 0) |
| + android_info_str += "; Build/" + android_build_id; |
| + |
| + std::string os_info; |
| + base::StringAppendF( |
| + &os_info, |
| + "Android %s%s", |
| + android_version_str.c_str(), |
| + android_info_str.c_str()); |
| + return os_info; |
| +} |
| +#endif |
| + |
| +} // namespace |
| + |
| std::string GetUserAgent() { |
| std::string product = "Chrome/" PRODUCT_VERSION; |
| - return content::BuildUserAgentFromProduct(product) + |
| + std::string os_info; |
| + base::StringAppendF( |
| + &os_info, |
| + "%s%s", |
| + "Linux; ", |
|
lcwu1
2015/04/21 20:55:04
In the current user agent string, this part would
gunsch
2015/04/21 21:04:32
Thanks for catching. Updated to "X11" for non-Andr
|
| +#if defined(OS_ANDROID) |
| + BuildAndroidOsInfo().c_str() |
| +#else |
| + content::BuildOSCpuInfo().c_str() |
| +#endif |
| + ); |
| + return content::BuildUserAgentFromOSAndProduct(os_info, product) + |
| " CrKey/" CAST_BUILD_REVISION; |
| } |