Index: chrome/installer/gcapi/gcapi.cc |
=================================================================== |
--- chrome/installer/gcapi/gcapi.cc (revision 80528) |
+++ chrome/installer/gcapi/gcapi.cc (working copy) |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2011 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. |
@@ -8,11 +8,14 @@ |
#include <atlcom.h> |
#include <windows.h> |
#include <sddl.h> |
-#include <stdlib.h> |
+#define STRSAFE_NO_DEPRECATE |
#include <strsafe.h> |
#include <tlhelp32.h> |
+#include <cstdlib> |
+ |
#include "google_update_idl.h" |
+#include "base/win/windows_version.h" |
namespace { |
@@ -156,33 +159,10 @@ |
bool IsChromeInstalled(HKEY root_key) { |
wchar_t version[64]; |
size_t size = _countof(version); |
- if (ReadValueFromRegistry(root_key, kChromeRegClientsKey, kChromeRegVersion, |
- version, &size)) |
- return true; |
- return false; |
+ return ReadValueFromRegistry(root_key, kChromeRegClientsKey, |
+ kChromeRegVersion, version, &size); |
} |
-bool IsWinXPSp2OrLater(bool* is_vista_or_later) { |
- OSVERSIONINFOEX osviex = { sizeof(OSVERSIONINFOEX) }; |
- int r = ::GetVersionEx((LPOSVERSIONINFO)&osviex); |
- // If this failed we're on Win9X or a pre NT4SP6 OS. |
- if (!r) |
- return false; |
- |
- if (osviex.dwMajorVersion < 5) |
- return false; |
- |
- if (osviex.dwMajorVersion > 5) { |
- *is_vista_or_later = true; |
- return true; // way beyond Windows XP; |
- } |
- |
- if (osviex.dwMinorVersion >= 1 && osviex.wServicePackMajor >= 2) |
- return true; // Windows XP SP2 or better. |
- |
- return false; // Windows 2000, WinXP no Service Pack. |
-} |
- |
// Note this function should not be called on old Windows versions where these |
// Windows API are not available. We always invoke this function after checking |
// that current OS is Vista or later. |
@@ -230,9 +210,8 @@ |
bool IsRunningElevated() { |
// This method should be called only for Vista or later. |
- bool is_vista_or_later = false; |
- IsWinXPSp2OrLater(&is_vista_or_later); |
- if (!is_vista_or_later || !VerifyAdminGroup()) |
+ if ((base::win::GetVersion() < base::win::VERSION_VISTA) || |
+ !VerifyAdminGroup()) |
return false; |
HANDLE process_token; |
@@ -287,9 +266,11 @@ |
DWORD *reasons) { |
DWORD local_reasons = 0; |
- bool is_vista_or_later = false; |
+ base::win::Version version = base::win::GetVersion(); |
// System requirements? |
- if (!IsWinXPSp2OrLater(&is_vista_or_later)) |
+ if ((version < base::win::VERSION_XP) || |
+ ((version == base::win::VERSION_XP) && |
+ (base::win::OSInfo::GetInstance()->service_pack()[0] < 2))) |
local_reasons |= GCCC_ERROR_OSNOTSUPPORTED; |
if (IsChromeInstalled(HKEY_LOCAL_MACHINE)) |
@@ -300,7 +281,7 @@ |
if (!VerifyHKLMAccess(kChromeRegClientsKey)) { |
local_reasons |= GCCC_ERROR_ACCESSDENIED; |
- } else if (is_vista_or_later && !VerifyAdminGroup()) { |
+ } else if ((version >= base::win::VERSION_VISTA) && !VerifyAdminGroup()) { |
// For Vista or later check for elevation since even for admin user we could |
// be running in non-elevated mode. We require integrity level High. |
local_reasons |= GCCC_ERROR_INTEGRITYLEVEL; |