diff options
author | Steve Block <steveblock@google.com> | 2011-05-25 19:08:45 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-06-08 13:51:31 +0100 |
commit | 2bde8e466a4451c7319e3a072d118917957d6554 (patch) | |
tree | 28f4a1b869a513e565c7760d0e6a06e7cf1fe95a /Source/WebCore/platform/win/SystemInfo.cpp | |
parent | 6939c99b71d9372d14a0c74a772108052e8c48c8 (diff) | |
download | external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.zip external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.gz external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.bz2 |
Merge WebKit at r82507: Initial merge by git
Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e
Diffstat (limited to 'Source/WebCore/platform/win/SystemInfo.cpp')
-rw-r--r-- | Source/WebCore/platform/win/SystemInfo.cpp | 149 |
1 files changed, 137 insertions, 12 deletions
diff --git a/Source/WebCore/platform/win/SystemInfo.cpp b/Source/WebCore/platform/win/SystemInfo.cpp index f2fe62b..878a6cc 100644 --- a/Source/WebCore/platform/win/SystemInfo.cpp +++ b/Source/WebCore/platform/win/SystemInfo.cpp @@ -27,30 +27,155 @@ #include "SystemInfo.h" #include <windows.h> +#include <wtf/text/StringConcatenate.h> namespace WebCore { -bool isRunningOnVistaOrLater() +WindowsVersion windowsVersion(int* major, int* minor) { + static bool initialized = false; + static WindowsVersion version; + static int majorVersion, minorVersion; + + if (!initialized) { + initialized = true; +#if OS(WINCE) + OSVERSIONINFO versionInfo; +#else + OSVERSIONINFOEX versionInfo; +#endif + ZeroMemory(&versionInfo, sizeof(versionInfo)); + versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); + GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&versionInfo)); + majorVersion = versionInfo.dwMajorVersion; + minorVersion = versionInfo.dwMinorVersion; + #if OS(WINCE) - return false; + if (majorVersion >= 1 && majorVersion <= 7) + version = static_cast<WindowsVersion>(WindowsCE1 + (majorVersion - 1)); + else + version = (majorVersion < 1) ? WindowsCE1 : WindowsCE7; #else - static bool isVistaOrLater; - static bool initialized; + if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32s) + version = Windows3_1; + else if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { + if (!minorVersion) + version = Windows95; + else + version = (minorVersion == 10) ? Windows98 : WindowsME; + } else { + if (majorVersion == 5) { + if (!minorVersion) + version = Windows2000; + else + version = (minorVersion == 1) ? WindowsXP : WindowsServer2003; + } else if (majorVersion >= 6) { + if (versionInfo.wProductType == VER_NT_WORKSTATION) + version = (majorVersion == 6 && !minorVersion) ? WindowsVista : Windows7; + else + version = WindowsServer2008; + } else + version = (majorVersion == 4) ? WindowsNT4 : WindowsNT3; + } +#endif + } - if (initialized) - return isVistaOrLater; + if (major) + *major = majorVersion; + if (minor) + *minor = minorVersion; + return version; +} + +static String osVersionForUAString() +{ + int major, minor; + WindowsVersion version = windowsVersion(&major, &minor); + switch (version) { + case WindowsCE1: + case WindowsCE2: + case WindowsCE3: + return "Windows CE"; + case WindowsCE4: + return "Windows CE .NET"; + case Windows3_1: + return "Windows 3.1"; + case Windows95: + return "Windows 95"; + case Windows98: + return "Windows 98"; + case WindowsME: + return "Windows 98; Win 9x 4.90"; + case WindowsNT4: + return "WinNT4.0"; + } - initialized = true; + const char* familyName = (version >= WindowsNT3) ? "Windows NT " : "Windows CE "; + return makeString(familyName, String::number(major), '.', String::number(minor)); +} - OSVERSIONINFOEX vi = {0}; - vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&vi)); +#if !OS(WINCE) +static bool isWOW64() +{ + static bool initialized = false; + static bool wow64 = false; - isVistaOrLater = vi.dwMajorVersion >= 6; + if (!initialized) { + initialized = true; + HMODULE kernel32Module = GetModuleHandleA("kernel32.dll"); + if (!kernel32Module) + return wow64; + typedef BOOL (WINAPI* IsWow64ProcessFunc)(HANDLE, PBOOL); + IsWow64ProcessFunc isWOW64Process = reinterpret_cast<IsWow64ProcessFunc>(GetProcAddress(kernel32Module, "IsWow64Process")); + if (isWOW64Process) { + BOOL result = FALSE; + wow64 = isWOW64Process(GetCurrentProcess(), &result) && result; + } + } - return isVistaOrLater; + return wow64; +} + +static WORD processorArchitecture() +{ + static bool initialized = false; + static WORD architecture = PROCESSOR_ARCHITECTURE_INTEL; + + if (!initialized) { + initialized = true; + HMODULE kernel32Module = GetModuleHandleA("kernel32.dll"); + if (!kernel32Module) + return architecture; + typedef VOID (WINAPI* GetNativeSystemInfoFunc)(LPSYSTEM_INFO); + GetNativeSystemInfoFunc getNativeSystemInfo = reinterpret_cast<GetNativeSystemInfoFunc>(GetProcAddress(kernel32Module, "GetNativeSystemInfo")); + if (getNativeSystemInfo) { + SYSTEM_INFO systemInfo; + ZeroMemory(&systemInfo, sizeof(systemInfo)); + getNativeSystemInfo(&systemInfo); + architecture = systemInfo.wProcessorArchitecture; + } + } + + return architecture; +} #endif + +static String architectureTokenForUAString() +{ +#if !OS(WINCE) + if (isWOW64()) + return "; WOW64"; + if (processorArchitecture() == PROCESSOR_ARCHITECTURE_AMD64) + return "; Win64; x64"; + if (processorArchitecture() == PROCESSOR_ARCHITECTURE_IA64) + return "; Win64; IA64"; +#endif + return String(); +} + +String windowsVersionForUAString() +{ + return makeString(osVersionForUAString(), architectureTokenForUAString()); } } // namespace WebCore |