diff options
author | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 17:40:42 +0000 |
---|---|---|
committer | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 17:40:42 +0000 |
commit | 0bad9b1895f6f0264527a9986044d9d1ee9152b1 (patch) | |
tree | 22a7464cbac92e2ee86c71ffc44ef580b7637963 | |
parent | d201b200e947d18ede55706197c62dbaeace8d5f (diff) | |
download | chromium_src-0bad9b1895f6f0264527a9986044d9d1ee9152b1.zip chromium_src-0bad9b1895f6f0264527a9986044d9d1ee9152b1.tar.gz chromium_src-0bad9b1895f6f0264527a9986044d9d1ee9152b1.tar.bz2 |
Revert 57692 - 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/3214005
TBR=tommi@chromium.org
Review URL: http://codereview.chromium.org/3275001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57696 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/glue/user_agent.cc | 115 | ||||
-rw-r--r-- | webkit/glue/user_agent.h | 25 | ||||
-rw-r--r-- | webkit/glue/webkit_glue.cc | 96 | ||||
-rw-r--r-- | webkit/glue/webkit_glue.gypi | 43 |
4 files changed, 106 insertions, 173 deletions
diff --git a/webkit/glue/user_agent.cc b/webkit/glue/user_agent.cc deleted file mode 100644 index e77b84d..0000000 --- a/webkit/glue/user_agent.cc +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/glue/user_agent.h" - -#if defined(OS_POSIX) && !defined(OS_MACOSX) -#include <sys/utsname.h> -#endif - -#include "base/string_util.h" -#include "base/sys_info.h" - -// Generated -#include "webkit_version.h" // NOLINT - -namespace webkit_glue { - -// Forward declare GetProductVersionInfo. This is implemented in -// renderer_glue.cc as part of the renderer lib. -std::string GetProductVersion(); - -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)) { // NOLINT - 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 - ); // NOLINT - - return os_cpu; -} - -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); -} - -} // namespace webkit_glue - diff --git a/webkit/glue/user_agent.h b/webkit/glue/user_agent.h deleted file mode 100644 index 914c5e68..0000000 --- a/webkit/glue/user_agent.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_GLUE_USER_AGENT_H_ -#define WEBKIT_GLUE_USER_AGENT_H_ - -#include <string> - -#include "base/basictypes.h" - -namespace webkit_glue { - -// 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); - -// Builds a User-agent compatible string that describes the OS and CPU type. -std::string BuildOSCpuInfo(); - -} // namespace webkit_glue - -#endif // WEBKIT_GLUE_USER_AGENT_H_ - diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc index cc7c118..f6fadfe 100644 --- a/webkit/glue/webkit_glue.cc +++ b/webkit/glue/webkit_glue.cc @@ -41,7 +41,6 @@ #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 @@ -337,6 +336,101 @@ 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); } diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi index a23ed53..450a870 100644 --- a/webkit/glue/webkit_glue.gypi +++ b/webkit/glue/webkit_glue.gypi @@ -105,37 +105,6 @@ ], }, { - 'target_name': 'webkit_user_agent', - 'type': '<(library)', - 'msvs_guid': 'DB162DE1-7D56-4C4A-8A9F-80D396CD7AA8', - 'dependencies': [ - '<(DEPTH)/app/app.gyp:app_base', - '<(DEPTH)/base/base.gyp:base_i18n', - ], - 'actions': [ - { - 'action_name': 'webkit_version', - 'inputs': [ - '../build/webkit_version.py', - '<(webkit_src_dir)/WebCore/Configurations/Version.xcconfig', - ], - 'outputs': [ - '<(INTERMEDIATE_DIR)/webkit_version.h', - ], - 'action': ['python', '<@(_inputs)', '<(INTERMEDIATE_DIR)'], - }, - ], - 'include_dirs': [ - '<(INTERMEDIATE_DIR)', - ], - 'sources': [ - 'user_agent.cc', - 'user_agent.h', - ], - 'conditions': [ - ], - }, - { 'target_name': 'glue', 'type': '<(library)', 'msvs_guid': 'C66B126D-0ECE-4CA2-B6DC-FA780AFBBF09', @@ -152,9 +121,19 @@ '<(DEPTH)/third_party/ppapi/ppapi.gyp:ppapi_c', 'webkit_resources', 'webkit_strings', - 'webkit_user_agent', ], 'actions': [ + { + 'action_name': 'webkit_version', + 'inputs': [ + '../build/webkit_version.py', + '<(webkit_src_dir)/WebCore/Configurations/Version.xcconfig', + ], + 'outputs': [ + '<(INTERMEDIATE_DIR)/webkit_version.h', + ], + 'action': ['python', '<@(_inputs)', '<(INTERMEDIATE_DIR)'], + }, ], 'include_dirs': [ '<(INTERMEDIATE_DIR)', |