|
23 | 23 | #include <sddl.h>
|
24 | 24 | #include <shlguid.h>
|
25 | 25 | #include <shlobj.h>
|
26 |
| -#include <VersionHelpers.h> |
27 | 26 | #include <WinInet.h>
|
28 | 27 | #include "FileUtilities.h"
|
29 | 28 | #include "logging.h"
|
@@ -64,7 +63,7 @@ void BrowserFactory::Initialize(BrowserFactorySettings settings) {
|
64 | 63 | void BrowserFactory::ClearCache() {
|
65 | 64 | LOG(TRACE) << "Entering BrowserFactory::ClearCache";
|
66 | 65 | if (this->clear_cache_) {
|
67 |
| - if (::IsWindowsVistaOrGreater()) { |
| 66 | + if (IsWindowsVistaOrGreater()) { |
68 | 67 | LOG(DEBUG) << "Clearing cache with low mandatory integrity level as required on Windows Vista or later.";
|
69 | 68 | this->InvokeClearCacheUtility(true);
|
70 | 69 | }
|
@@ -635,7 +634,7 @@ IWebBrowser2* BrowserFactory::CreateBrowser() {
|
635 | 634 |
|
636 | 635 | IWebBrowser2* browser = NULL;
|
637 | 636 | DWORD context = CLSCTX_LOCAL_SERVER;
|
638 |
| - if (this->ie_major_version_ == 7 && ::IsWindowsVistaOrGreater()) { |
| 637 | + if (this->ie_major_version_ == 7 && IsWindowsVistaOrGreater()) { |
639 | 638 | // ONLY for IE 7 on Windows Vista. XP and below do not have Protected Mode;
|
640 | 639 | // Windows 7 shipped with IE8.
|
641 | 640 | context = context | CLSCTX_ENABLE_CLOAKING;
|
@@ -995,14 +994,14 @@ bool BrowserFactory::ProtectedModeSettingsAreValid() {
|
995 | 994 | bool settings_are_valid = true;
|
996 | 995 | LOG(DEBUG) << "Detected IE version: " << this->ie_major_version_
|
997 | 996 | << ", Windows version supports Protected Mode: "
|
998 |
| - << ::IsWindowsVistaOrGreater() ? "true" : "false"; |
| 997 | + << IsWindowsVistaOrGreater() ? "true" : "false"; |
999 | 998 | // Only need to check Protected Mode settings on IE 7 or higher
|
1000 | 999 | // and on Windows Vista or higher. Otherwise, Protected Mode
|
1001 | 1000 | // doesn't come into play, and are valid.
|
1002 | 1001 | // Documentation of registry settings can be found at the following
|
1003 | 1002 | // Microsoft KnowledgeBase article:
|
1004 | 1003 | // http://support.microsoft.com/kb/182569
|
1005 |
| - if (this->ie_major_version_ >= 7 && ::IsWindowsVistaOrGreater()) { |
| 1004 | + if (this->ie_major_version_ >= 7 && IsWindowsVistaOrGreater()) { |
1006 | 1005 | HKEY key_handle;
|
1007 | 1006 | if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_CURRENT_USER,
|
1008 | 1007 | IE_SECURITY_ZONES_REGISTRY_KEY,
|
@@ -1113,4 +1112,29 @@ int BrowserFactory::GetZoneProtectedModeSetting(const HKEY key_handle,
|
1113 | 1112 | return protected_mode_value;
|
1114 | 1113 | }
|
1115 | 1114 |
|
| 1115 | +bool BrowserFactory::IsWindowsVersionOrGreater(unsigned short major_version, |
| 1116 | + unsigned short minor_version, |
| 1117 | + unsigned short service_pack) { |
| 1118 | + OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0,{ 0 }, 0, 0 }; |
| 1119 | + DWORDLONG const dwlConditionMask = VerSetConditionMask( |
| 1120 | + VerSetConditionMask( |
| 1121 | + VerSetConditionMask( |
| 1122 | + 0, VER_MAJORVERSION, VER_GREATER_EQUAL), |
| 1123 | + VER_MINORVERSION, VER_GREATER_EQUAL), |
| 1124 | + VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); |
| 1125 | + |
| 1126 | + osvi.dwMajorVersion = major_version; |
| 1127 | + osvi.dwMinorVersion = minor_version; |
| 1128 | + osvi.wServicePackMajor = service_pack; |
| 1129 | + |
| 1130 | + return VerifyVersionInfoW(&osvi, |
| 1131 | + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, |
| 1132 | + dwlConditionMask) != FALSE; |
| 1133 | +} |
| 1134 | + |
| 1135 | +bool BrowserFactory::IsWindowsVistaOrGreater() { |
| 1136 | + return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0); |
| 1137 | +} |
| 1138 | + |
| 1139 | + |
1116 | 1140 | } // namespace webdriver
|
0 commit comments