Index: webkit/glue/user_agent.cc |
diff --git a/webkit/glue/user_agent.cc b/webkit/glue/user_agent.cc |
index 516504081f136db4e1551c71f4a3237b020e373e..24ac6719c15a38ad03c4dee5330515cf0edb26c2 100644 |
--- a/webkit/glue/user_agent.cc |
+++ b/webkit/glue/user_agent.cc |
@@ -20,14 +20,6 @@ |
// Generated |
#include "webkit_version.h" // NOLINT |
-#if defined(OS_ANDROID) |
-namespace { |
- |
-base::LazyInstance<std::string>::Leaky g_os_info = LAZY_INSTANCE_INITIALIZER; |
- |
-} // namespace |
-#endif |
- |
namespace webkit_glue { |
std::string GetWebKitVersion() { |
@@ -103,7 +95,7 @@ std::string BuildOSCpuInfo() { |
os_bugfix_version |
#elif defined(OS_ANDROID) |
"Android %s", |
- g_os_info.Get().c_str() |
+ BuildOSCpuInfoForAndroid().c_str() |
#else |
"%s %s", |
unixinfo.sysname, // e.g. Linux |
@@ -114,6 +106,54 @@ std::string BuildOSCpuInfo() { |
return os_cpu; |
} |
+std::string BuildOSCpuInfoForAndroid() { |
jar (doing other things)
2012/08/15 23:35:17
Who would ever call this, if not in android? ...
gone
2012/08/16 00:29:31
It's supposed to be used for spoofing the UA in a
|
+ int32 version_major = base::SysInfo::kDefaultAndroidMajorVersion; |
+ int32 version_minor = base::SysInfo::kDefaultAndroidMinorVersion; |
+ int32 version_bugfix = base::SysInfo::kDefaultAndroidBugfixVersion; |
+ std::string android_build_codename; |
+ std::string android_build_id; |
+ std::string android_device_name; |
+#if defined(OS_ANDROID) |
+ base::SysInfo::OperatingSystemVersionNumbers(&version_major, &version_minor, |
+ &version_bugfix); |
+ android_build_codename = base::SysInfo::GetAndroidBuildCodename(); |
+ android_build_id = base::SysInfo::GetAndroidBuildID(); |
+ android_device_name = base::SysInfo::GetDeviceName(); |
+#endif |
+ |
+ bool semicolon_inserted = false; |
+ std::string android_info_str; |
+ |
+ // Append information about the OS version. |
+ if (version_bugfix == 0) { |
+ base::StringAppendF(&android_info_str, "%d.%d", version_major, |
+ version_minor); |
+ } else { |
+ base::StringAppendF(&android_info_str, "%d.%d.%d", version_major, |
+ version_minor, version_bugfix); |
+ } |
+ |
+ // Append information about the device. |
+ if ("REL" == android_build_codename && android_device_name.size() > 0) { |
+ if (!semicolon_inserted) { |
jar (doing other things)
2012/08/15 23:35:17
Logic for this seems confused.
semicolon_inserted
gone
2012/08/16 00:29:31
Good catch, moved it downward.
|
+ android_info_str += ";"; |
+ semicolon_inserted = true; |
+ } |
+ android_info_str += " " + android_device_name; |
+ } |
+ |
+ // Append the build ID. |
+ if (android_build_id.size() > 0) { |
+ if (!semicolon_inserted) { |
+ android_info_str += ";"; |
+ semicolon_inserted = true; |
jar (doing other things)
2012/08/15 23:35:17
Why are you setting this variable, given that you
gone
2012/08/16 00:29:31
Done.
|
+ } |
+ android_info_str += " Build/" + android_build_id; |
+ } |
+ |
+ return android_info_str; |
+} |
+ |
int GetWebKitMajorVersion() { |
return WEBKIT_VERSION_MAJOR; |
} |
@@ -156,10 +196,4 @@ std::string BuildUserAgentFromProduct(const std::string& product) { |
return user_agent; |
} |
-#if defined(OS_ANDROID) |
-void SetUserAgentOSInfo(const std::string& os_info) { |
- g_os_info.Get() = os_info; |
-} |
-#endif |
- |
} // namespace webkit_glue |