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

Unified Diff: chrome/installer/gcapi/gcapi.cc

Issue 6816024: Revert 80819 due to failed tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 8 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 | « chrome/browser/ui/views/about_chrome_view.cc ('k') | chrome/installer/setup/install_worker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/gcapi/gcapi.cc
===================================================================
--- chrome/installer/gcapi/gcapi.cc (revision 80823)
+++ chrome/installer/gcapi/gcapi.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 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,12 +8,10 @@
#include <atlcom.h>
#include <windows.h>
#include <sddl.h>
-#define STRSAFE_NO_DEPRECATE
+#include <stdlib.h>
#include <strsafe.h>
#include <tlhelp32.h>
-#include <cstdlib>
-
#include "google_update_idl.h"
namespace {
@@ -158,31 +156,31 @@
bool IsChromeInstalled(HKEY root_key) {
wchar_t version[64];
size_t size = _countof(version);
- return ReadValueFromRegistry(root_key, kChromeRegClientsKey,
- kChromeRegVersion, version, &size);
+ if (ReadValueFromRegistry(root_key, kChromeRegClientsKey, kChromeRegVersion,
+ version, &size))
+ return true;
+ return false;
}
-enum WindowsVersion {
- VERSION_BELOW_XP_SP2,
- VERSION_XP_SP2_UP_TO_VISTA, // "but not including"
- VERSION_VISTA_OR_HIGHER,
-};
-WindowsVersion GetWindowsVersion() {
- OSVERSIONINFOEX version_info = { sizeof version_info };
- GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info));
+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;
- // Windows Vista is version 6.0.
- if (version_info.dwMajorVersion >= 6)
- return VERSION_VISTA_OR_HIGHER;
+ if (osviex.dwMajorVersion < 5)
+ return false;
- // Windows XP is version 5.1. (5.2 is Windows Server 2003/XP Pro x64.)
- if ((version_info.dwMajorVersion < 5) || (version_info.dwMinorVersion < 1))
- return VERSION_BELOW_XP_SP2;
+ if (osviex.dwMajorVersion > 5) {
+ *is_vista_or_later = true;
+ return true; // way beyond Windows XP;
+ }
- // For XP itself, we only support SP2 and above.
- return ((version_info.dwMinorVersion > 1) ||
- (version_info.wServicePackMajor >= 2)) ?
- VERSION_XP_SP2_UP_TO_VISTA : VERSION_BELOW_XP_SP2;
+ 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
@@ -232,8 +230,9 @@
bool IsRunningElevated() {
// This method should be called only for Vista or later.
- if ((GetWindowsVersion() < VERSION_VISTA_OR_HIGHER) ||
- !VerifyAdminGroup())
+ bool is_vista_or_later = false;
+ IsWinXPSp2OrLater(&is_vista_or_later);
+ if (!is_vista_or_later || !VerifyAdminGroup())
return false;
HANDLE process_token;
@@ -288,9 +287,9 @@
DWORD *reasons) {
DWORD local_reasons = 0;
- WindowsVersion windows_version = GetWindowsVersion();
+ bool is_vista_or_later = false;
// System requirements?
- if (windows_version == VERSION_BELOW_XP_SP2)
+ if (!IsWinXPSp2OrLater(&is_vista_or_later))
local_reasons |= GCCC_ERROR_OSNOTSUPPORTED;
if (IsChromeInstalled(HKEY_LOCAL_MACHINE))
@@ -301,8 +300,7 @@
if (!VerifyHKLMAccess(kChromeRegClientsKey)) {
local_reasons |= GCCC_ERROR_ACCESSDENIED;
- } else if ((windows_version == VERSION_VISTA_OR_HIGHER) &&
- !VerifyAdminGroup()) {
+ } else if (is_vista_or_later && !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;
« no previous file with comments | « chrome/browser/ui/views/about_chrome_view.cc ('k') | chrome/installer/setup/install_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698