diff options
author | dfalcantara@chromium.org <dfalcantara@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-21 23:55:52 +0000 |
---|---|---|
committer | dfalcantara@chromium.org <dfalcantara@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-21 23:55:52 +0000 |
commit | abef4b33bc3d484621e28a70c141e6ca8ce7aa1e (patch) | |
tree | d495c173007c3ecb45efe288f072bd23d26537a1 /webkit | |
parent | b7c8d6c560adc7cddfcf23ad73e3c4378ef65ea4 (diff) | |
download | chromium_src-abef4b33bc3d484621e28a70c141e6ca8ce7aa1e.zip chromium_src-abef4b33bc3d484621e28a70c141e6ca8ce7aa1e.tar.gz chromium_src-abef4b33bc3d484621e28a70c141e6ca8ce7aa1e.tar.bz2 |
Move Android user agent generation to native code
Gets rid of a pathway that forced us to set the user agent
from the Java side, replacing it with one that's entirely
native. Functions have been added to base to allow accessing
information about the device and Android build, while the
user agent generation code was moved to the webkit_glue
namespace.
BUG=131312
Review URL: https://chromiumcodereview.appspot.com/10832235
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152675 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/user_agent.cc | 47 | ||||
-rw-r--r-- | webkit/glue/user_agent.h | 7 |
2 files changed, 30 insertions, 24 deletions
diff --git a/webkit/glue/user_agent.cc b/webkit/glue/user_agent.cc index 5165040..bfd1ff4 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() { @@ -44,7 +36,8 @@ std::string GetWebKitRevision() { std::string BuildOSCpuInfo() { std::string os_cpu; -#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) +#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) ||\ + defined(OS_ANDROID) int32 os_major_version = 0; int32 os_minor_version = 0; int32 os_bugfix_version = 0; @@ -52,6 +45,7 @@ std::string BuildOSCpuInfo() { &os_minor_version, &os_bugfix_version); #endif + #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) // Should work on any Posix system. struct utsname unixinfo; @@ -82,6 +76,28 @@ std::string BuildOSCpuInfo() { } #endif +#if defined(OS_ANDROID) + std::string android_info_str; + + // Send information about the device. + bool semicolon_inserted = false; + std::string android_build_codename = base::SysInfo::GetAndroidBuildCodename(); + std::string android_device_name = base::SysInfo::GetDeviceName(); + if ("REL" == android_build_codename && android_device_name.size() > 0) { + android_info_str += "; " + android_device_name; + semicolon_inserted = true; + } + + // Append the build ID. + std::string android_build_id = base::SysInfo::GetAndroidBuildID(); + if (android_build_id.size() > 0) { + if (!semicolon_inserted) { + android_info_str += ";"; + } + android_info_str += " Build/" + android_build_id; + } +#endif + base::StringAppendF( &os_cpu, #if defined(OS_WIN) @@ -102,8 +118,11 @@ std::string BuildOSCpuInfo() { os_minor_version, os_bugfix_version #elif defined(OS_ANDROID) - "Android %s", - g_os_info.Get().c_str() + "Android %d.%d.%d%s", + os_major_version, + os_minor_version, + os_bugfix_version, + android_info_str.c_str() #else "%s %s", unixinfo.sysname, // e.g. Linux @@ -156,10 +175,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 diff --git a/webkit/glue/user_agent.h b/webkit/glue/user_agent.h index 60f6e53..5d2594a 100644 --- a/webkit/glue/user_agent.h +++ b/webkit/glue/user_agent.h @@ -21,13 +21,6 @@ std::string GetWebKitVersion(); int GetWebKitMajorVersion(); int GetWebKitMinorVersion(); -#if defined(OS_ANDROID) -// Sets the OS component of the user agent (e.g. "4.0.4; Galaxy Nexus -// BUILD/IMM76K") -// TODO(yfriedman): Remove this ASAP (http://crbug.com/131312) -void SetUserAgentOSInfo(const std::string& os_info); -#endif - // Helper function to generate a full user agent string from a short // product name. std::string BuildUserAgentFromProduct(const std::string& product); |