summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webkit_glue.cc
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 19:28:25 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 19:28:25 +0000
commit420286748888437c755272ffe98fd27a16099194 (patch)
tree45431e2ca0d52bf46c57f305d1d69660db29e9a1 /webkit/glue/webkit_glue.cc
parent8ec81aa69cbd7595508448afe9a0b2cee6e0d321 (diff)
downloadchromium_src-420286748888437c755272ffe98fd27a16099194.zip
chromium_src-420286748888437c755272ffe98fd27a16099194.tar.gz
chromium_src-420286748888437c755272ffe98fd27a16099194.tar.bz2
Second attempt at landing http://codereview.chromium.org/3214005
Factoring BuildUserAgent out to a separate lib for GCF can use it. TEST=There should be no functional change. If anything breaks it should be the build. BUG=50788 Review URL: http://codereview.chromium.org/3225003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57717 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webkit_glue.cc')
-rw-r--r--webkit/glue/webkit_glue.cc102
1 files changed, 1 insertions, 101 deletions
diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc
index f6fadfe..e525be9 100644
--- a/webkit/glue/webkit_glue.cc
+++ b/webkit/glue/webkit_glue.cc
@@ -41,10 +41,9 @@
#include "third_party/WebKit/WebKit/chromium/public/win/WebInputEventFactory.h"
#endif
#include "webkit/glue/glue_serialize.h"
+#include "webkit/glue/user_agent.h"
#include "v8/include/v8.h"
-#include "webkit_version.h" // Generated
-
using WebKit::WebCanvas;
using WebKit::WebData;
using WebKit::WebElement;
@@ -313,10 +312,6 @@ WebString FilePathToWebString(const FilePath& file_path) {
return FilePathStringToWebString(file_path.value());
}
-std::string GetWebKitVersion() {
- return StringPrintf("%d.%d", WEBKIT_VERSION_MAJOR, WEBKIT_VERSION_MINOR);
-}
-
namespace {
struct UserAgentState {
@@ -336,101 +331,6 @@ struct UserAgentState {
Singleton<UserAgentState> g_user_agent;
-std::string BuildOSCpuInfo() {
- std::string os_cpu;
-
-#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
- 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);
-#endif
-#if defined(OS_POSIX) && !defined(OS_MACOSX)
- // Should work on any Posix system.
- struct utsname unixinfo;
- uname(&unixinfo);
-
- std::string cputype;
- // special case for biarch systems
- if (strcmp(unixinfo.machine, "x86_64") == 0 &&
- sizeof(void*) == sizeof(int32)) {
- cputype.assign("i686 (x86_64)");
- } else {
- cputype.assign(unixinfo.machine);
- }
-#endif
-
- StringAppendF(
- &os_cpu,
-#if defined(OS_WIN)
- "Windows NT %d.%d",
- os_major_version,
- os_minor_version
-#elif defined(OS_MACOSX)
- "Intel Mac OS X %d_%d_%d",
- os_major_version,
- os_minor_version,
- os_bugfix_version
-#elif defined(OS_CHROMEOS)
- "CrOS %s %d.%d.%d",
- cputype.c_str(), // e.g. i686
- os_major_version,
- os_minor_version,
- os_bugfix_version
-#else
- "%s %s",
- unixinfo.sysname, // e.g. Linux
- cputype.c_str() // e.g. i686
-#endif
- );
-
- return os_cpu;
-}
-
-// Construct the User-Agent header, filling in |result|.
-// The other parameters are workarounds for broken websites:
-// - If mimic_windows is true, produce a fake Windows Chrome string.
-void BuildUserAgent(bool mimic_windows, std::string* result) {
- const char kUserAgentPlatform[] =
-#if defined(OS_WIN)
- "Windows";
-#elif defined(OS_MACOSX)
- "Macintosh";
-#elif defined(USE_X11)
- "X11"; // strange, but that's what Firefox uses
-#else
- "?";
-#endif
-
- const char kUserAgentSecurity = 'U'; // "US" strength encryption
-
- // TODO(port): figure out correct locale
- const char kUserAgentLocale[] = "en-US";
-
- // Get the product name and version, and replace Safari's Version/X string
- // with it. This is done to expose our product name in a manner that is
- // maximally compatible with Safari, we hope!!
- std::string product = GetProductVersion();
-
- // Derived from Safari's UA string.
- StringAppendF(
- result,
- "Mozilla/5.0 (%s; %c; %s; %s) AppleWebKit/%d.%d"
- " (KHTML, like Gecko) %s Safari/%d.%d",
- mimic_windows ? "Windows" : kUserAgentPlatform,
- kUserAgentSecurity,
- ((mimic_windows ? "Windows " : "") + BuildOSCpuInfo()).c_str(),
- kUserAgentLocale,
- WEBKIT_VERSION_MAJOR,
- WEBKIT_VERSION_MINOR,
- product.c_str(),
- WEBKIT_VERSION_MAJOR,
- WEBKIT_VERSION_MINOR
- );
-}
-
void SetUserAgentToDefault() {
BuildUserAgent(false, &g_user_agent->user_agent);
}