OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2009 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 21 matching lines...) Expand all Loading... |
32 namespace WebCore { | 32 namespace WebCore { |
33 | 33 |
34 WindowsVersion windowsVersion(int* major, int* minor) | 34 WindowsVersion windowsVersion(int* major, int* minor) |
35 { | 35 { |
36 static bool initialized = false; | 36 static bool initialized = false; |
37 static WindowsVersion version; | 37 static WindowsVersion version; |
38 static int majorVersion, minorVersion; | 38 static int majorVersion, minorVersion; |
39 | 39 |
40 if (!initialized) { | 40 if (!initialized) { |
41 initialized = true; | 41 initialized = true; |
42 #if OS(WINCE) | |
43 OSVERSIONINFO versionInfo; | |
44 #else | |
45 OSVERSIONINFOEX versionInfo; | 42 OSVERSIONINFOEX versionInfo; |
46 #endif | |
47 ZeroMemory(&versionInfo, sizeof(versionInfo)); | 43 ZeroMemory(&versionInfo, sizeof(versionInfo)); |
48 versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); | 44 versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); |
49 GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&versionInfo)); | 45 GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&versionInfo)); |
50 majorVersion = versionInfo.dwMajorVersion; | 46 majorVersion = versionInfo.dwMajorVersion; |
51 minorVersion = versionInfo.dwMinorVersion; | 47 minorVersion = versionInfo.dwMinorVersion; |
52 | 48 |
53 #if OS(WINCE) | |
54 if (majorVersion >= 1 && majorVersion <= 7) | |
55 version = static_cast<WindowsVersion>(WindowsCE1 + (majorVersion - 1
)); | |
56 else | |
57 version = (majorVersion < 1) ? WindowsCE1 : WindowsCE7; | |
58 #else | |
59 if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32s) | 49 if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32s) |
60 version = Windows3_1; | 50 version = Windows3_1; |
61 else if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { | 51 else if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { |
62 if (!minorVersion) | 52 if (!minorVersion) |
63 version = Windows95; | 53 version = Windows95; |
64 else | 54 else |
65 version = (minorVersion == 10) ? Windows98 : WindowsME; | 55 version = (minorVersion == 10) ? Windows98 : WindowsME; |
66 } else { | 56 } else { |
67 if (majorVersion == 5) { | 57 if (majorVersion == 5) { |
68 if (!minorVersion) | 58 if (!minorVersion) |
69 version = Windows2000; | 59 version = Windows2000; |
70 else | 60 else |
71 version = (minorVersion == 1) ? WindowsXP : WindowsServer200
3; | 61 version = (minorVersion == 1) ? WindowsXP : WindowsServer200
3; |
72 } else if (majorVersion >= 6) { | 62 } else if (majorVersion >= 6) { |
73 if (versionInfo.wProductType == VER_NT_WORKSTATION) | 63 if (versionInfo.wProductType == VER_NT_WORKSTATION) |
74 version = (majorVersion == 6 && !minorVersion) ? WindowsVist
a : Windows7; | 64 version = (majorVersion == 6 && !minorVersion) ? WindowsVist
a : Windows7; |
75 else | 65 else |
76 version = WindowsServer2008; | 66 version = WindowsServer2008; |
77 } else | 67 } else |
78 version = (majorVersion == 4) ? WindowsNT4 : WindowsNT3; | 68 version = (majorVersion == 4) ? WindowsNT4 : WindowsNT3; |
79 } | 69 } |
80 #endif | |
81 } | 70 } |
82 | 71 |
83 if (major) | 72 if (major) |
84 *major = majorVersion; | 73 *major = majorVersion; |
85 if (minor) | 74 if (minor) |
86 *minor = minorVersion; | 75 *minor = minorVersion; |
87 return version; | 76 return version; |
88 } | 77 } |
89 | 78 |
90 static String osVersionForUAString() | 79 static String osVersionForUAString() |
(...skipping 16 matching lines...) Expand all Loading... |
107 case WindowsME: | 96 case WindowsME: |
108 return "Windows 98; Win 9x 4.90"; | 97 return "Windows 98; Win 9x 4.90"; |
109 case WindowsNT4: | 98 case WindowsNT4: |
110 return "WinNT4.0"; | 99 return "WinNT4.0"; |
111 } | 100 } |
112 | 101 |
113 const char* familyName = (version >= WindowsNT3) ? "Windows NT " : "Windows
CE "; | 102 const char* familyName = (version >= WindowsNT3) ? "Windows NT " : "Windows
CE "; |
114 return familyName + String::number(major) + '.' + String::number(minor); | 103 return familyName + String::number(major) + '.' + String::number(minor); |
115 } | 104 } |
116 | 105 |
117 #if !OS(WINCE) | |
118 static bool isWOW64() | 106 static bool isWOW64() |
119 { | 107 { |
120 static bool initialized = false; | 108 static bool initialized = false; |
121 static bool wow64 = false; | 109 static bool wow64 = false; |
122 | 110 |
123 if (!initialized) { | 111 if (!initialized) { |
124 initialized = true; | 112 initialized = true; |
125 HMODULE kernel32Module = GetModuleHandleA("kernel32.dll"); | 113 HMODULE kernel32Module = GetModuleHandleA("kernel32.dll"); |
126 if (!kernel32Module) | 114 if (!kernel32Module) |
127 return wow64; | 115 return wow64; |
(...skipping 23 matching lines...) Expand all Loading... |
151 if (getNativeSystemInfo) { | 139 if (getNativeSystemInfo) { |
152 SYSTEM_INFO systemInfo; | 140 SYSTEM_INFO systemInfo; |
153 ZeroMemory(&systemInfo, sizeof(systemInfo)); | 141 ZeroMemory(&systemInfo, sizeof(systemInfo)); |
154 getNativeSystemInfo(&systemInfo); | 142 getNativeSystemInfo(&systemInfo); |
155 architecture = systemInfo.wProcessorArchitecture; | 143 architecture = systemInfo.wProcessorArchitecture; |
156 } | 144 } |
157 } | 145 } |
158 | 146 |
159 return architecture; | 147 return architecture; |
160 } | 148 } |
161 #endif | |
162 | 149 |
163 static String architectureTokenForUAString() | 150 static String architectureTokenForUAString() |
164 { | 151 { |
165 #if !OS(WINCE) | |
166 if (isWOW64()) | 152 if (isWOW64()) |
167 return "; WOW64"; | 153 return "; WOW64"; |
168 if (processorArchitecture() == PROCESSOR_ARCHITECTURE_AMD64) | 154 if (processorArchitecture() == PROCESSOR_ARCHITECTURE_AMD64) |
169 return "; Win64; x64"; | 155 return "; Win64; x64"; |
170 if (processorArchitecture() == PROCESSOR_ARCHITECTURE_IA64) | 156 if (processorArchitecture() == PROCESSOR_ARCHITECTURE_IA64) |
171 return "; Win64; IA64"; | 157 return "; Win64; IA64"; |
172 #endif | |
173 return String(); | 158 return String(); |
174 } | 159 } |
175 | 160 |
176 String windowsVersionForUAString() | 161 String windowsVersionForUAString() |
177 { | 162 { |
178 return osVersionForUAString() + architectureTokenForUAString(); | 163 return osVersionForUAString() + architectureTokenForUAString(); |
179 } | 164 } |
180 | 165 |
181 } // namespace WebCore | 166 } // namespace WebCore |
OLD | NEW |