Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1126)

Unified Diff: chromecast/common/cast_content_client.cc

Issue 1067593007: Chromecast: removes ATV product information from UA string. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Linux --> X11 for non-Android case Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698