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..4772fdd5c06eb181678ca70c9ff9f16be58628b5 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,56 @@ |
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", |
+#if defined(OS_ANDROID) |
+ "Linux; ", |
+ BuildAndroidOsInfo().c_str() |
+#else |
+ "X11; ", |
+ content::BuildOSCpuInfo().c_str() |
+#endif |
+ ); |
+ return content::BuildUserAgentFromOSAndProduct(os_info, product) + |
" CrKey/" CAST_BUILD_REVISION; |
} |