Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1753)

Unified Diff: Source/platform/win/SystemInfo.cpp

Issue 39693002: Introduce isWindowsVistaOrGreater() as replacement of windowsVersion() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-10-28T12:54:24 Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/win/SystemInfo.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/win/SystemInfo.cpp
diff --git a/Source/platform/win/SystemInfo.cpp b/Source/platform/win/SystemInfo.cpp
index 553f27e076591ccc24b19447836c0bb62848f456..ae198e3974e70051b28334364c6fe4d750709cd2 100644
--- a/Source/platform/win/SystemInfo.cpp
+++ b/Source/platform/win/SystemInfo.cpp
@@ -26,54 +26,38 @@
#include "config.h"
#include "platform/win/SystemInfo.h"
+#if _WIN32_WINNT_WINBLUE
+#include <versionhelpers.h>
+#endif
+
#include <windows.h>
namespace WebCore {
-WindowsVersion windowsVersion(int* major, int* minor)
+#ifndef _WIN32_WINNT_WINBLUE
+static bool IsWindowsVistaOrGreater()
+{
+ OSVERSIONINFOEXW osvi = { };
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ osvi.dwMajorVersion = HIBYTE(_WIN32_WINNT_VISTA);
+ osvi.dwMinorVersion = LOBYTE(_WIN32_WINNT_VISTA);
+ DWORDLONG conditoin = 0;
+ VER_SET_CONDITION(conditoin, VER_MAJORVERSION, VER_GREATER_EQUAL);
+ VER_SET_CONDITION(conditoin, VER_MINORVERSION, VER_GREATER_EQUAL);
+ return !!::VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION, conditoin);
+}
+#endif
+
+bool isWindowsVistaOrGreater()
{
static bool initialized = false;
- static WindowsVersion version;
- static int majorVersion, minorVersion;
+ static bool cachedIsWindowsVistaOrGreater;
if (!initialized) {
initialized = true;
- OSVERSIONINFOEX versionInfo;
- ZeroMemory(&versionInfo, sizeof(versionInfo));
- versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&versionInfo));
- majorVersion = versionInfo.dwMajorVersion;
- minorVersion = versionInfo.dwMinorVersion;
-
- 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;
- }
- }
+ cachedIsWindowsVistaOrGreater = IsWindowsVistaOrGreater();
}
-
- if (major)
- *major = majorVersion;
- if (minor)
- *minor = minorVersion;
- return version;
+ return cachedIsWindowsVistaOrGreater;
}
} // namespace WebCore
« no previous file with comments | « Source/platform/win/SystemInfo.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698