diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-11 09:57:25 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-11 09:57:25 +0000 |
commit | efd2c3fbfa6413cdf042e5cb088bfe586085ae77 (patch) | |
tree | 371376c746ac2b28d3b607f6936f4d564d1e4feb /webkit | |
parent | 3f656b692188627413e41b49c593664225d758af (diff) | |
download | chromium_src-efd2c3fbfa6413cdf042e5cb088bfe586085ae77.zip chromium_src-efd2c3fbfa6413cdf042e5cb088bfe586085ae77.tar.gz chromium_src-efd2c3fbfa6413cdf042e5cb088bfe586085ae77.tar.bz2 |
Move user_agent code from webkit/ to content/.
BUG=265753, 338338, 237249
TEST=content_unittests
R=jam@chromium.org
TBR=darin
Review URL: https://codereview.chromium.org/186883002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256174 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/build/webkit_version.h.in | 9 | ||||
-rw-r--r-- | webkit/child/webkit_child.gyp | 1 | ||||
-rw-r--r-- | webkit/common/user_agent/user_agent_util.cc | 192 | ||||
-rw-r--r-- | webkit/common/user_agent/user_agent_util.h | 40 | ||||
-rw-r--r-- | webkit/common/user_agent/user_agent_util_ios.mm | 130 | ||||
-rw-r--r-- | webkit/common/user_agent/webkit_user_agent.gyp | 86 | ||||
-rw-r--r-- | webkit/common/user_agent/webkit_user_agent_export.h | 29 |
7 files changed, 0 insertions, 487 deletions
diff --git a/webkit/build/webkit_version.h.in b/webkit/build/webkit_version.h.in deleted file mode 100644 index 8d61e47..0000000 --- a/webkit/build/webkit_version.h.in +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source is governed by a BSD-style license that can be -// found in the LICENSE file. - -// webkit_version.h is generated from webkit_version.h.in. Edit the source! - -#define WEBKIT_VERSION_MAJOR 537 -#define WEBKIT_VERSION_MINOR 36 -#define WEBKIT_SVN_REVISION "@@LASTCHANGE@" diff --git a/webkit/child/webkit_child.gyp b/webkit/child/webkit_child.gyp index 4c289f5..d3dda2a 100644 --- a/webkit/child/webkit_child.gyp +++ b/webkit/child/webkit_child.gyp @@ -45,7 +45,6 @@ '<(DEPTH)/ui/ui.gyp:ui', '<(DEPTH)/url/url.gyp:url_lib', '<(DEPTH)/v8/tools/gyp/v8.gyp:v8', - '<(DEPTH)/webkit/common/user_agent/webkit_user_agent.gyp:user_agent', '<(DEPTH)/webkit/common/webkit_common.gyp:webkit_common', ], 'include_dirs': [ diff --git a/webkit/common/user_agent/user_agent_util.cc b/webkit/common/user_agent/user_agent_util.cc deleted file mode 100644 index 35e2016..0000000 --- a/webkit/common/user_agent/user_agent_util.cc +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright (c) 2012 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/common/user_agent/user_agent_util.h" - -#if defined(OS_POSIX) && !defined(OS_MACOSX) -#include <sys/utsname.h> -#endif - -#include "base/lazy_instance.h" -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" -#include "base/sys_info.h" - -#if defined(OS_WIN) -#include "base/win/windows_version.h" -#endif - -// Generated -#include "webkit_version.h" // NOLINT - -namespace webkit_glue { - -std::string GetWebKitVersion() { - return base::StringPrintf("%d.%d (%s)", - WEBKIT_VERSION_MAJOR, - WEBKIT_VERSION_MINOR, - WEBKIT_SVN_REVISION); -} - -std::string GetWebKitRevision() { - return WEBKIT_SVN_REVISION; -} - -#if defined(OS_ANDROID) -std::string GetAndroidDeviceName() { - return base::SysInfo::GetDeviceName(); -} -#endif - -std::string BuildOSCpuInfo() { - std::string os_cpu; - -#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; - base::SysInfo::OperatingSystemVersionNumbers(&os_major_version, - &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; - 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 - -#if defined(OS_WIN) - std::string architecture_token; - base::win::OSInfo* os_info = base::win::OSInfo::GetInstance(); - if (os_info->wow64_status() == base::win::OSInfo::WOW64_ENABLED) { - architecture_token = "; WOW64"; - } else { - base::win::OSInfo::WindowsArchitecture windows_architecture = - os_info->architecture(); - if (windows_architecture == base::win::OSInfo::X64_ARCHITECTURE) - architecture_token = "; Win64; x64"; - else if (windows_architecture == base::win::OSInfo::IA64_ARCHITECTURE) - architecture_token = "; Win64; IA64"; - } -#endif - -#if defined(OS_ANDROID) - 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; - - // Send information about the device. - bool semicolon_inserted = false; - std::string android_build_codename = base::SysInfo::GetAndroidBuildCodename(); - std::string android_device_name = GetAndroidDeviceName(); - 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) - "Windows NT %d.%d%s", - os_major_version, - os_minor_version, - architecture_token.c_str() -#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 -#elif defined(OS_ANDROID) - "Android %s%s", - android_version_str.c_str(), - android_info_str.c_str() -#else - "%s %s", - unixinfo.sysname, // e.g. Linux - cputype.c_str() // e.g. i686 -#endif - ); // NOLINT - - return os_cpu; -} - -int GetWebKitMajorVersion() { - return WEBKIT_VERSION_MAJOR; -} - -int GetWebKitMinorVersion() { - return WEBKIT_VERSION_MINOR; -} - -std::string BuildUserAgentFromProduct(const std::string& product) { - const char kUserAgentPlatform[] = -#if defined(OS_WIN) - ""; -#elif defined(OS_MACOSX) - "Macintosh; "; -#elif defined(USE_X11) - "X11; "; // strange, but that's what Firefox uses -#elif defined(OS_ANDROID) - "Linux; "; -#else - "Unknown; "; -#endif - - std::string os_info; - base::StringAppendF(&os_info, "%s%s", kUserAgentPlatform, - webkit_glue::BuildOSCpuInfo().c_str()); - return BuildUserAgentFromOSAndProduct(os_info, product); -} - -std::string BuildUserAgentFromOSAndProduct(const std::string& os_info, - const std::string& product) { - // Derived from Safari's UA string. - // This is done to expose our product name in a manner that is maximally - // compatible with Safari, we hope!! - std::string user_agent; - base::StringAppendF( - &user_agent, - "Mozilla/5.0 (%s) AppleWebKit/%d.%d (KHTML, like Gecko) %s Safari/%d.%d", - os_info.c_str(), - WEBKIT_VERSION_MAJOR, - WEBKIT_VERSION_MINOR, - product.c_str(), - WEBKIT_VERSION_MAJOR, - WEBKIT_VERSION_MINOR); - return user_agent; -} - -} // namespace webkit_glue diff --git a/webkit/common/user_agent/user_agent_util.h b/webkit/common/user_agent/user_agent_util.h deleted file mode 100644 index e23b809..0000000 --- a/webkit/common/user_agent/user_agent_util.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2012 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_COMMON_USER_AGENT_USER_AGENT_UTIL_H_ -#define WEBKIT_COMMON_USER_AGENT_USER_AGENT_UTIL_H_ - -#include <string> - -#include "base/basictypes.h" -#include "webkit/common/user_agent/webkit_user_agent_export.h" - -namespace webkit_glue { - -// Builds a User-agent compatible string that describes the OS and CPU type. -WEBKIT_USER_AGENT_EXPORT std::string BuildOSCpuInfo(); - -// Returns the WebKit version, in the form "major.minor (branch@revision)". -WEBKIT_USER_AGENT_EXPORT std::string GetWebKitVersion(); - -// The following 2 functions return the major and minor webkit versions. -WEBKIT_USER_AGENT_EXPORT int GetWebKitMajorVersion(); -WEBKIT_USER_AGENT_EXPORT int GetWebKitMinorVersion(); - -WEBKIT_USER_AGENT_EXPORT std::string GetWebKitRevision(); - -// Helper function to generate a full user agent string from a short -// product name. -WEBKIT_USER_AGENT_EXPORT std::string BuildUserAgentFromProduct( - const std::string& product); - -// Builds a full user agent string given a string describing the OS and a -// product name. -WEBKIT_USER_AGENT_EXPORT std::string BuildUserAgentFromOSAndProduct( - const std::string& os_info, - const std::string& product); - -} // namespace webkit_glue - -#endif // WEBKIT_COMMON_USER_AGENT_USER_AGENT_UTIL_H_ diff --git a/webkit/common/user_agent/user_agent_util_ios.mm b/webkit/common/user_agent/user_agent_util_ios.mm deleted file mode 100644 index 6a42c51..0000000 --- a/webkit/common/user_agent/user_agent_util_ios.mm +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2012 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/common/user_agent/user_agent_util.h" - -#import <UIKit/UIKit.h> - -#include <sys/sysctl.h> -#include <string> - -#include "base/mac/scoped_nsobject.h" -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" -#include "base/strings/sys_string_conversions.h" -#include "base/sys_info.h" - -namespace { - -struct UAVersions { - const char* safari_version_string; - const char* webkit_version_string; -}; - -struct OSVersionMap { - int32 major_os_version; - int32 minor_os_version; - UAVersions ua_versions; -}; - -const UAVersions& GetUAVersionsForCurrentOS() { - // The WebKit version can be extracted dynamically from UIWebView, but the - // Safari version can't be, so a lookup table is used instead (for both, since - // the reported versions should stay in sync). - static const OSVersionMap version_map[] = { - { 7, 0, { "9537.53", "537.51.1" } }, - // 6.1 has the same values as 6.0. - { 6, 0, { "8536.25", "536.26" } }, - }; - - 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); - - // Return the versions corresponding to the first (and thus highest) OS - // version less than or equal to the given OS version. - for (unsigned int i = 0; i < arraysize(version_map); ++i) { - if (os_major_version > version_map[i].major_os_version || - (os_major_version == version_map[i].major_os_version && - os_minor_version >= version_map[i].minor_os_version)) - return version_map[i].ua_versions; - } - NOTREACHED(); - return version_map[arraysize(version_map) - 1].ua_versions; -} - -} // namespace - -namespace webkit_glue { - -std::string BuildOSCpuInfo() { - 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 os_version; - if (os_bugfix_version == 0) { - base::StringAppendF(&os_version, - "%d_%d", - os_major_version, - os_minor_version); - } else { - base::StringAppendF(&os_version, - "%d_%d_%d", - os_major_version, - os_minor_version, - os_bugfix_version); - } - - // Remove the end of the platform name. For example "iPod touch" becomes - // "iPod". - std::string platform = base::SysNSStringToUTF8( - [[UIDevice currentDevice] model]); - size_t position = platform.find_first_of(" "); - if (position != std::string::npos) - platform = platform.substr(0, position); - - std::string os_cpu; - base::StringAppendF( - &os_cpu, - "%s; CPU %s %s like Mac OS X", - platform.c_str(), - (platform == "iPad") ? "OS" : "iPhone OS", - os_version.c_str()); - - return os_cpu; -} - -std::string BuildUserAgentFromProduct(const std::string& product) { - // Retrieve the kernel build number. - int mib[2] = {CTL_KERN, KERN_OSVERSION}; - unsigned int namelen = sizeof(mib) / sizeof(mib[0]); - size_t bufferSize = 0; - sysctl(mib, namelen, NULL, &bufferSize, NULL, 0); - char kernel_version[bufferSize]; - int result = sysctl(mib, namelen, kernel_version, &bufferSize, NULL, 0); - DCHECK(result == 0); - - UAVersions ua_versions = GetUAVersionsForCurrentOS(); - - std::string user_agent; - base::StringAppendF( - &user_agent, - "Mozilla/5.0 (%s) AppleWebKit/%s" - " (KHTML, like Gecko) %s Mobile/%s Safari/%s", - webkit_glue::BuildOSCpuInfo().c_str(), - ua_versions.webkit_version_string, - product.c_str(), - kernel_version, - ua_versions.safari_version_string); - - return user_agent; -} - -} // namespace webkit_glue diff --git a/webkit/common/user_agent/webkit_user_agent.gyp b/webkit/common/user_agent/webkit_user_agent.gyp deleted file mode 100644 index 3fbc5e0..0000000 --- a/webkit/common/user_agent/webkit_user_agent.gyp +++ /dev/null @@ -1,86 +0,0 @@ -# Copyright 2013 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. - -{ - 'targets': [ - { - 'target_name': 'user_agent', - 'type': '<(component)', - 'defines': [ - 'WEBKIT_USER_AGENT_IMPLEMENTATION', - ], - 'variables': { - 'chromium_code': 1, - }, - 'dependencies': [ - '<(DEPTH)/base/base.gyp:base', - '<(DEPTH)/base/base.gyp:base_i18n', - '<(DEPTH)/url/url.gyp:url_lib', - ], - 'sources': [ - 'user_agent_util.cc', - 'user_agent_util_ios.mm', - 'user_agent_util.h', - 'webkit_user_agent_export.h', - ], - 'conditions': [ - ['OS == "ios"', { - # iOS has different user-agent construction utilities, since the - # version strings is not derived from webkit_version, and follows - # a different format. - 'sources!': [ - 'user_agent_util.cc', - ], - }, { # OS != "ios" - 'dependencies': [ - 'webkit_version', - '<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', - ], - }], - ], - }, - ], - 'conditions': [ - ['OS != "ios"', { - 'targets': [ - { - 'target_name': 'webkit_version', - 'type': 'none', - 'actions': [ - { - 'action_name': 'webkit_version', - 'inputs': [ - '<(script)', - '<(lastchange)', - '<(template)', - ], - 'outputs': [ - '<(SHARED_INTERMEDIATE_DIR)/webkit_version.h', - ], - 'action': ['python', - '<(script)', - '-f', '<(lastchange)', - '<(template)', - '<@(_outputs)', - ], - 'variables': { - 'script': '<(DEPTH)/build/util/version.py', - 'lastchange': '<(DEPTH)/build/util/LASTCHANGE.blink', - 'template': '<(DEPTH)/webkit/build/webkit_version.h.in', - }, - }, - ], - 'direct_dependent_settings': { - 'include_dirs': [ - '<(SHARED_INTERMEDIATE_DIR)', - ], - }, - # Dependents may rely on files generated by this target or one of its - # own hard dependencies. - 'hard_dependency': 1, - }, - ], - }], - ], -} diff --git a/webkit/common/user_agent/webkit_user_agent_export.h b/webkit/common/user_agent/webkit_user_agent_export.h deleted file mode 100644 index 5f9598f..0000000 --- a/webkit/common/user_agent/webkit_user_agent_export.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2012 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_COMMON_USER_AGENT_WEBKIT_USER_AGENT_EXPORT_H_ -#define WEBKIT_COMMON_USER_AGENT_WEBKIT_USER_AGENT_EXPORT_H_ - -#if defined(COMPONENT_BUILD) -#if defined(WIN32) - -#if defined(WEBKIT_USER_AGENT_IMPLEMENTATION) -#define WEBKIT_USER_AGENT_EXPORT __declspec(dllexport) -#else -#define WEBKIT_USER_AGENT_EXPORT __declspec(dllimport) -#endif // defined(WEBKIT_USER_AGENT_IMPLEMENTATION) - -#else // defined(WIN32) -#if defined(WEBKIT_USER_AGENT_IMPLEMENTATION) -#define WEBKIT_USER_AGENT_EXPORT __attribute__((visibility("default"))) -#else -#define WEBKIT_USER_AGENT_EXPORT -#endif -#endif - -#else // defined(COMPONENT_BUILD) -#define WEBKIT_USER_AGENT_EXPORT -#endif - -#endif // WEBKIT_COMMON_USER_AGENT_WEBKIT_USER_AGENT_EXPORT_H_ |