summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/file_version_info_win.cc5
-rw-r--r--base/process_util_win.cc12
-rw-r--r--base/sys_info.h12
-rw-r--r--base/sys_info_chromeos.cc12
-rw-r--r--base/sys_info_mac.cc8
-rw-r--r--base/sys_info_win.cc41
-rw-r--r--base/win/windows_version.cc100
-rw-r--r--base/win/windows_version.h117
-rw-r--r--chrome/browser/bug_report_util.cc37
-rw-r--r--chrome/browser/diagnostics/recon_diagnostics.cc21
-rw-r--r--chrome/browser/importer/importer_unittest.cc2
-rw-r--r--chrome/browser/memory_details_win.cc12
-rw-r--r--chrome/browser/nacl_host/nacl_process_host.cc3
-rw-r--r--chrome/browser/ui/views/about_chrome_view.cc4
-rw-r--r--chrome/installer/gcapi/gcapi.cc64
-rw-r--r--chrome/installer/setup/install_worker.cc3
-rw-r--r--chrome/installer/util/google_chrome_distribution.cc12
-rw-r--r--chrome/installer/util/install_util.cc13
-rw-r--r--chrome/renderer/renderer_glue.cc4
-rw-r--r--chrome/test/out_of_proc_test_runner.cc12
-rw-r--r--media/tools/mfplayer/mf_playback_main.cc4
-rw-r--r--media/tools/mfplayer/mfplayer.cc2
-rw-r--r--sandbox/src/Wow64.cc3
-rw-r--r--sandbox/src/dep_test.cc30
-rw-r--r--sandbox/src/integrity_level_test.cc8
-rw-r--r--sandbox/src/interception.cc3
-rw-r--r--sandbox/src/job.cc12
-rw-r--r--sandbox/src/sandbox_utils.cc34
-rw-r--r--sandbox/src/service_resolver_unittest.cc3
-rw-r--r--sandbox/tests/common/controller.cc10
-rw-r--r--sandbox/tests/integration_tests/integration_tests.cc6
-rw-r--r--sandbox/tests/unit_tests/unit_tests.cc6
-rw-r--r--sandbox/tests/validation_tests/unit_tests.cc6
-rw-r--r--webkit/glue/user_agent.cc13
-rw-r--r--webkit/plugins/npapi/test/plugin_npobject_proxy_test.cc6
35 files changed, 302 insertions, 338 deletions
diff --git a/base/file_version_info_win.cc b/base/file_version_info_win.cc
index 953caa9..8c6820e 100644
--- a/base/file_version_info_win.cc
+++ b/base/file_version_info_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -12,9 +12,6 @@
#include "base/path_service.h"
#include "base/threading/thread_restrictions.h"
-// This has to be last.
-#include <strsafe.h>
-
FileVersionInfoWin::FileVersionInfoWin(void* data, int language, int code_page)
: language_(language), code_page_(code_page) {
base::ThreadRestrictions::AssertIOAllowed();
diff --git a/base/process_util_win.cc b/base/process_util_win.cc
index 8ade06e..a49b78c 100644
--- a/base/process_util_win.cc
+++ b/base/process_util_win.cc
@@ -17,6 +17,7 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram.h"
+#include "base/sys_info.h"
#include "base/win/scoped_handle.h"
#include "base/win/windows_version.h"
@@ -554,12 +555,11 @@ bool CleanupProcesses(const std::wstring& executable_name,
///////////////////////////////////////////////////////////////////////////////
// ProcesMetrics
-ProcessMetrics::ProcessMetrics(ProcessHandle process) : process_(process),
- last_time_(0),
- last_system_time_(0) {
- SYSTEM_INFO system_info;
- GetSystemInfo(&system_info);
- processor_count_ = system_info.dwNumberOfProcessors;
+ProcessMetrics::ProcessMetrics(ProcessHandle process)
+ : process_(process),
+ processor_count_(base::SysInfo::NumberOfProcessors()),
+ last_time_(0),
+ last_system_time_(0) {
}
// static
diff --git a/base/sys_info.h b/base/sys_info.h
index 1d2939e..863e068 100644
--- a/base/sys_info.h
+++ b/base/sys_info.h
@@ -41,9 +41,9 @@ class BASE_API SysInfo {
// Retrieves detailed numeric values for the OS version.
// TODO(port): Implement a Linux version of this method and enable the
// corresponding unit test.
- static void OperatingSystemVersionNumbers(int32 *major_version,
- int32 *minor_version,
- int32 *bugfix_version);
+ static void OperatingSystemVersionNumbers(int32* major_version,
+ int32* minor_version,
+ int32* bugfix_version);
// Returns the CPU architecture of the system. Exact return value may differ
// across platforms.
@@ -73,9 +73,9 @@ class BASE_API SysInfo {
// Parses /etc/lsb-release to get version information for Google Chrome OS.
// Declared here so it can be exposed for unit testing.
static void ParseLsbRelease(const std::string& lsb_release,
- int32 *major_version,
- int32 *minor_version,
- int32 *bugfix_version);
+ int32* major_version,
+ int32* minor_version,
+ int32* bugfix_version);
#endif
};
diff --git a/base/sys_info_chromeos.cc b/base/sys_info_chromeos.cc
index b15d71b..cd17c18 100644
--- a/base/sys_info_chromeos.cc
+++ b/base/sys_info_chromeos.cc
@@ -43,9 +43,9 @@ static base::LazyInstance<ChromeOSVersionNumbers>
g_chrome_os_version_numbers(base::LINKER_INITIALIZED);
// static
-void SysInfo::OperatingSystemVersionNumbers(int32 *major_version,
- int32 *minor_version,
- int32 *bugfix_version) {
+void SysInfo::OperatingSystemVersionNumbers(int32* major_version,
+ int32* minor_version,
+ int32* bugfix_version) {
if (!g_chrome_os_version_numbers.Get().parsed) {
// The other implementations of SysInfo don't block on the disk.
// See http://code.google.com/p/chromium/issues/detail?id=60394
@@ -75,9 +75,9 @@ std::string SysInfo::GetLinuxStandardBaseVersionKey() {
// static
void SysInfo::ParseLsbRelease(const std::string& lsb_release,
- int32 *major_version,
- int32 *minor_version,
- int32 *bugfix_version) {
+ int32* major_version,
+ int32* minor_version,
+ int32* bugfix_version) {
size_t version_key_index = std::string::npos;
for (int i = 0; kLinuxStandardBaseVersionKeys[i] != NULL; ++i) {
version_key_index = lsb_release.find(kLinuxStandardBaseVersionKeys[i]);
diff --git a/base/sys_info_mac.cc b/base/sys_info_mac.cc
index 79caf55..e668421 100644
--- a/base/sys_info_mac.cc
+++ b/base/sys_info_mac.cc
@@ -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.
@@ -14,9 +14,9 @@
namespace base {
// static
-void SysInfo::OperatingSystemVersionNumbers(int32 *major_version,
- int32 *minor_version,
- int32 *bugfix_version) {
+void SysInfo::OperatingSystemVersionNumbers(int32* major_version,
+ int32* minor_version,
+ int32* bugfix_version) {
Gestalt(gestaltSystemVersionMajor,
reinterpret_cast<SInt32*>(major_version));
Gestalt(gestaltSystemVersionMinor,
diff --git a/base/sys_info_win.cc b/base/sys_info_win.cc
index ce8376a..045d516 100644
--- a/base/sys_info_win.cc
+++ b/base/sys_info_win.cc
@@ -10,14 +10,13 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/stringprintf.h"
+#include "base/win/windows_version.h"
namespace base {
// static
int SysInfo::NumberOfProcessors() {
- SYSTEM_INFO info;
- GetSystemInfo(&info);
- return static_cast<int>(info.dwNumberOfProcessors);
+ return win::OSInfo::GetInstance()->processors();
}
// static
@@ -54,12 +53,17 @@ std::string SysInfo::OperatingSystemName() {
// static
std::string SysInfo::OperatingSystemVersion() {
- OSVERSIONINFO info = {0};
- info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&info);
-
- return base::StringPrintf("%lu.%lu",
- info.dwMajorVersion, info.dwMinorVersion);
+ win::OSInfo* os_info = win::OSInfo::GetInstance();
+ win::OSInfo::VersionNumber version_number = os_info->version_number();
+ std::string version(StringPrintf("%d.%d", version_number.major,
+ version_number.minor));
+ win::OSInfo::ServicePack service_pack = os_info->service_pack();
+ if (service_pack.major != 0) {
+ version += StringPrintf(" SP%d", service_pack.major);
+ if (service_pack.minor != 0)
+ version += StringPrintf(".%d", service_pack.minor);
+ }
+ return version;
}
// TODO: Implement OperatingSystemVersionComplete, which would include
@@ -88,21 +92,16 @@ int SysInfo::DisplayCount() {
// static
size_t SysInfo::VMAllocationGranularity() {
- SYSTEM_INFO sysinfo;
- GetSystemInfo(&sysinfo);
-
- return sysinfo.dwAllocationGranularity;
+ return win::OSInfo::GetInstance()->allocation_granularity();
}
// static
-void SysInfo::OperatingSystemVersionNumbers(int32 *major_version,
- int32 *minor_version,
- int32 *bugfix_version) {
- OSVERSIONINFO info = {0};
- info.dwOSVersionInfoSize = sizeof(info);
- GetVersionEx(&info);
- *major_version = info.dwMajorVersion;
- *minor_version = info.dwMinorVersion;
+void SysInfo::OperatingSystemVersionNumbers(int32* major_version,
+ int32* minor_version,
+ int32* bugfix_version) {
+ win::OSInfo* os_info = win::OSInfo::GetInstance();
+ *major_version = os_info->version_number().major;
+ *minor_version = os_info->version_number().minor;
*bugfix_version = 0;
}
diff --git a/base/win/windows_version.cc b/base/win/windows_version.cc
index d53148d..8dc2d93 100644
--- a/base/win/windows_version.cc
+++ b/base/win/windows_version.cc
@@ -11,81 +11,49 @@
namespace base {
namespace win {
-Version GetVersion() {
- static bool checked_version = false;
- static Version win_version = VERSION_PRE_2000;
- if (!checked_version) {
- OSVERSIONINFOEX version_info;
- version_info.dwOSVersionInfoSize = sizeof version_info;
- GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info));
- if (version_info.dwMajorVersion == 5) {
- switch (version_info.dwMinorVersion) {
- case 0:
- win_version = VERSION_2000;
- break;
- case 1:
- win_version = VERSION_XP;
- break;
- case 2:
- default:
- win_version = VERSION_SERVER_2003;
- break;
- }
- } else if (version_info.dwMajorVersion == 6) {
- if (version_info.wProductType != VER_NT_WORKSTATION) {
- // 2008 is 6.0, and 2008 R2 is 6.1.
- win_version = VERSION_2008;
- } else {
- if (version_info.dwMinorVersion == 0) {
- win_version = VERSION_VISTA;
- } else {
- win_version = VERSION_WIN7;
- }
- }
- } else if (version_info.dwMajorVersion > 6) {
- win_version = VERSION_WIN7;
- }
- checked_version = true;
- }
- return win_version;
+// static
+OSInfo* OSInfo::GetInstance() {
+ return Singleton<OSInfo>::get();
}
-void GetServicePackLevel(int* major, int* minor) {
- DCHECK(major && minor);
- static bool checked_version = false;
- static int service_pack_major = -1;
- static int service_pack_minor = -1;
- if (!checked_version) {
- OSVERSIONINFOEX version_info = {0};
- version_info.dwOSVersionInfoSize = sizeof(version_info);
- GetVersionEx(reinterpret_cast<OSVERSIONINFOW*>(&version_info));
- service_pack_major = version_info.wServicePackMajor;
- service_pack_minor = version_info.wServicePackMinor;
- checked_version = true;
+OSInfo::OSInfo()
+ : version_(VERSION_PRE_XP),
+ architecture_(OTHER_ARCHITECTURE),
+ wow64_status_(GetWOW64StatusForProcess(GetCurrentProcess())) {
+ OSVERSIONINFOEX version_info = { sizeof version_info };
+ GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info));
+ version_number_.major = version_info.dwMajorVersion;
+ version_number_.minor = version_info.dwMinorVersion;
+ version_number_.build = version_info.dwBuildNumber;
+ if ((version_number_.major == 5) && (version_number_.minor > 0)) {
+ version_ = (version_number_.minor == 1) ? VERSION_XP : VERSION_SERVER_2003;
+ } else if (version_number_.major == 6) {
+ if (version_info.wProductType == VER_NT_WORKSTATION)
+ version_ = (version_number_.minor == 0) ? VERSION_VISTA : VERSION_WIN7;
+ else
+ version_ = VERSION_SERVER_2008;
+ } else if (version_number_.major > 6) {
+ version_ = VERSION_WIN7;
}
+ service_pack_.major = version_info.wServicePackMajor;
+ service_pack_.minor = version_info.wServicePackMinor;
- *major = service_pack_major;
- *minor = service_pack_minor;
-}
-
-WindowsArchitecture GetWindowsArchitecture() {
- SYSTEM_INFO system_info;
+ SYSTEM_INFO system_info = { 0 };
GetNativeSystemInfo(&system_info);
switch (system_info.wProcessorArchitecture) {
- case PROCESSOR_ARCHITECTURE_INTEL: return X86_ARCHITECTURE;
- case PROCESSOR_ARCHITECTURE_AMD64: return X64_ARCHITECTURE;
- case PROCESSOR_ARCHITECTURE_IA64: return IA64_ARCHITECTURE;
- default: return OTHER_ARCHITECTURE;
+ case PROCESSOR_ARCHITECTURE_INTEL: architecture_ = X86_ARCHITECTURE; break;
+ case PROCESSOR_ARCHITECTURE_AMD64: architecture_ = X64_ARCHITECTURE; break;
+ case PROCESSOR_ARCHITECTURE_IA64: architecture_ = IA64_ARCHITECTURE; break;
}
+ processors_ = system_info.dwNumberOfProcessors;
+ allocation_granularity_ = system_info.dwAllocationGranularity;
}
-WOW64Status GetWOW64Status() {
- static WOW64Status wow64_status =
- GetWOW64StatusForProcess(GetCurrentProcess());
- return wow64_status;
+OSInfo::~OSInfo() {
}
-WOW64Status GetWOW64StatusForProcess(HANDLE process_handle) {
+// static
+OSInfo::WOW64Status OSInfo::GetWOW64StatusForProcess(HANDLE process_handle) {
typedef BOOL (WINAPI* IsWow64ProcessFunc)(HANDLE, PBOOL);
IsWow64ProcessFunc is_wow64_process = reinterpret_cast<IsWow64ProcessFunc>(
GetProcAddress(GetModuleHandle(L"kernel32.dll"), "IsWow64Process"));
@@ -97,5 +65,9 @@ WOW64Status GetWOW64StatusForProcess(HANDLE process_handle) {
return is_wow64 ? WOW64_ENABLED : WOW64_DISABLED;
}
+Version GetVersion() {
+ return OSInfo::GetInstance()->version();
+}
+
} // namespace win
} // namespace base
diff --git a/base/win/windows_version.h b/base/win/windows_version.h
index 1d4b9bf..96f3792 100644
--- a/base/win/windows_version.h
+++ b/base/win/windows_version.h
@@ -7,61 +7,98 @@
#pragma once
#include "base/base_api.h"
+#include "base/memory/singleton.h"
typedef void* HANDLE;
namespace base {
namespace win {
+// The running version of Windows. This is declared outside OSInfo for
+// syntactic sugar reasons; see the declaration of GetVersion() below.
// NOTE: Keep these in order so callers can do things like
-// "if (GetWinVersion() > WINVERSION_2000) ...". It's OK to change the values,
-// though.
+// "if (base::win::GetVersion() >= base::win::VERSION_VISTA) ...".
enum Version {
- VERSION_PRE_2000 = 0, // Not supported
- VERSION_2000 = 1, // Not supported
- VERSION_XP = 2,
- VERSION_SERVER_2003 = 3, // Also includes Windows XP Professional x64 edition
- VERSION_VISTA = 4,
- VERSION_2008 = 5,
- VERSION_WIN7 = 6,
+ VERSION_PRE_XP = 0, // Not supported.
+ VERSION_XP,
+ VERSION_SERVER_2003, // Also includes Windows XP Professional x64.
+ VERSION_VISTA,
+ VERSION_SERVER_2008,
+ VERSION_WIN7,
};
-// Returns the running version of Windows.
-BASE_API Version GetVersion();
+// A Singleton that can be used to query various pieces of information about the
+// OS and process state.
+class BASE_API OSInfo {
+ public:
+ struct VersionNumber {
+ int major;
+ int minor;
+ int build;
+ };
-// Returns the major and minor version of the service pack installed.
-BASE_API void GetServicePackLevel(int* major, int* minor);
+ struct ServicePack {
+ int major;
+ int minor;
+ };
-enum WindowsArchitecture {
- X86_ARCHITECTURE,
- X64_ARCHITECTURE,
- IA64_ARCHITECTURE,
- OTHER_ARCHITECTURE,
-};
+ // The processor architecture this copy of Windows natively uses. For
+ // example, given an x64-capable processor, we have three possibilities:
+ // 32-bit Chrome running on 32-bit Windows: X86_ARCHITECTURE
+ // 32-bit Chrome running on 64-bit Windows via WOW64: X64_ARCHITECTURE
+ // 64-bit Chrome running on 64-bit Windows: X64_ARCHITECTURE
+ enum WindowsArchitecture {
+ X86_ARCHITECTURE,
+ X64_ARCHITECTURE,
+ IA64_ARCHITECTURE,
+ OTHER_ARCHITECTURE,
+ };
-// Returns the processor architecture this copy of Windows natively uses.
-// For example, given an x64-capable processor, we have three possibilities:
-// 32-bit Chrome running on 32-bit Windows: X86_ARCHITECTURE
-// 32-bit Chrome running on 64-bit Windows via WOW64: X64_ARCHITECTURE
-// 64-bit Chrome running on 64-bit Windows: X64_ARCHITECTURE
-BASE_API WindowsArchitecture GetWindowsArchitecture();
-
-enum WOW64Status {
- WOW64_DISABLED,
- WOW64_ENABLED,
- WOW64_UNKNOWN,
-};
+ // Whether a process is running under WOW64 (the wrapper that allows 32-bit
+ // processes to run on 64-bit versions of Windows). This will return
+ // WOW64_DISABLED for both "32-bit Chrome on 32-bit Windows" and "64-bit
+ // Chrome on 64-bit Windows". WOW64_UNKNOWN means "an error occurred", e.g.
+ // the process does not have sufficient access rights to determine this.
+ enum WOW64Status {
+ WOW64_DISABLED,
+ WOW64_ENABLED,
+ WOW64_UNKNOWN,
+ };
+
+ static OSInfo* GetInstance();
+
+ Version version() const { return version_; }
+ // The next two functions return arrays of values, [major, minor(, build)].
+ VersionNumber version_number() const { return version_number_; }
+ ServicePack service_pack() const { return service_pack_; }
+ WindowsArchitecture architecture() const { return architecture_; }
+ int processors() const { return processors_; }
+ size_t allocation_granularity() const { return allocation_granularity_; }
+ WOW64Status wow64_status() const { return wow64_status_; }
-// Returns whether this process is running under WOW64 (the wrapper that allows
-// 32-bit processes to run on 64-bit versions of Windows). This will return
-// WOW64_DISABLED for both "32-bit Chrome on 32-bit Windows" and "64-bit Chrome
-// on 64-bit Windows". WOW64_UNKNOWN means "an error occurred", e.g. the
-// process does not have sufficient access rights to determine this.
-BASE_API WOW64Status GetWOW64Status();
+ // Like wow64_status(), but for the supplied handle instead of the current
+ // process. This doesn't touch member state, so you can bypass the singleton.
+ static WOW64Status GetWOW64StatusForProcess(HANDLE process_handle);
-// Like GetWOW64Status(), but for the supplied handle instead of the current
-// process.
-BASE_API WOW64Status GetWOW64StatusForProcess(HANDLE process_handle);
+ private:
+ OSInfo();
+ ~OSInfo();
+
+ Version version_;
+ VersionNumber version_number_;
+ ServicePack service_pack_;
+ WindowsArchitecture architecture_;
+ int processors_;
+ size_t allocation_granularity_;
+ WOW64Status wow64_status_;
+
+ friend struct DefaultSingletonTraits<OSInfo>;
+ DISALLOW_COPY_AND_ASSIGN(OSInfo);
+};
+
+// Because this is by far the most commonly-requested value from the above
+// singleton, we add a global-scope accessor here as syntactic sugar.
+BASE_API Version GetVersion();
} // namespace win
} // namespace base
diff --git a/chrome/browser/bug_report_util.cc b/chrome/browser/bug_report_util.cc
index 8ba0e2c..ebb8e24 100644
--- a/chrome/browser/bug_report_util.cc
+++ b/chrome/browser/bug_report_util.cc
@@ -13,6 +13,7 @@
#include "base/memory/singleton.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
+#include "base/win/windows_version.h"
#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/safe_browsing_util.h"
@@ -135,19 +136,19 @@ void BugReportUtil::PostCleanup::OnURLFetchComplete(
// Process the error for debug output
if (response_code == kHttpPostFailNoConnection) {
- error_stream << "No connection to server.";
+ error_stream << "No connection to server.";
} else if ((response_code > kHttpPostFailClientError) &&
- (response_code < kHttpPostFailServerError)) {
- error_stream << "Client error: HTTP response code " << response_code;
+ (response_code < kHttpPostFailServerError)) {
+ error_stream << "Client error: HTTP response code " << response_code;
} else if (response_code > kHttpPostFailServerError) {
- error_stream << "Server error: HTTP response code " << response_code;
+ error_stream << "Server error: HTTP response code " << response_code;
} else {
- error_stream << "Unknown error: HTTP response code " << response_code;
+ error_stream << "Unknown error: HTTP response code " << response_code;
}
}
- LOG(WARNING) << "FEEDBACK: Submission to feedback server (" << url <<
- ") status: " << error_stream.str() << std::endl;
+ LOG(WARNING) << "FEEDBACK: Submission to feedback server (" << url
+ << ") status: " << error_stream.str();
// Delete the URLFetcher.
delete source;
@@ -156,21 +157,15 @@ void BugReportUtil::PostCleanup::OnURLFetchComplete(
}
// static
-void BugReportUtil::SetOSVersion(std::string *os_version) {
+void BugReportUtil::SetOSVersion(std::string* os_version) {
#if defined(OS_WIN)
- OSVERSIONINFO osvi;
- ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-
- if (GetVersionEx(&osvi)) {
- *os_version = StringPrintf("%d.%d.%d %S",
- osvi.dwMajorVersion,
- osvi.dwMinorVersion,
- osvi.dwBuildNumber,
- osvi.szCSDVersion);
- } else {
- *os_version = "unknown";
- }
+ base::win::OSInfo* os_info = base::win::OSInfo::GetInstance();
+ base::win::OSInfo::VersionNumber version_number = os_info->version_number();
+ *os_version = StringPrintf("%d.%d.%d", version_number.major,
+ version_number.minor, version_number.build);
+ int service_pack = os_info->service_pack().major;
+ if (service_pack > 0)
+ os_version->append(StringPrintf("Service Pack %d", service_pack));
#elif defined(OS_MACOSX)
int32 major;
int32 minor;
diff --git a/chrome/browser/diagnostics/recon_diagnostics.cc b/chrome/browser/diagnostics/recon_diagnostics.cc
index 86666f6..4ff348e 100644
--- a/chrome/browser/diagnostics/recon_diagnostics.cc
+++ b/chrome/browser/diagnostics/recon_diagnostics.cc
@@ -47,27 +47,20 @@ class OperatingSystemTest : public DiagnosticTest {
virtual int GetId() { return 0; }
virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) {
- int version = 0;
- int major = 0;
- int minor = 0;
#if defined(OS_WIN)
- version = base::win::GetVersion();
- if (version < base::win::VERSION_XP) {
- RecordFailure(ASCIIToUTF16("Windows 2000 or earlier"));
- return false;
- }
- base::win::GetServicePackLevel(&major, &minor);
- if ((version == base::win::VERSION_XP) && (major < 2)) {
- RecordFailure(ASCIIToUTF16("XP Service Pack 1 or earlier"));
+ base::win::Version version = base::win::GetVersion();
+ if ((version < base::win::VERSION_XP) ||
+ ((version == base::win::VERSION_XP) &&
+ (base::win::OSInfo::GetInstance()->service_pack().major < 2))) {
+ RecordFailure(ASCIIToUTF16("Must have Windows XP SP2 or later"));
return false;
}
#else
// TODO(port): define the OS criteria for Linux and Mac.
#endif // defined(OS_WIN)
- RecordSuccess(ASCIIToUTF16(StringPrintf("%s %s (%d [%d:%d])",
+ RecordSuccess(ASCIIToUTF16(StringPrintf("%s %s",
base::SysInfo::OperatingSystemName().c_str(),
- base::SysInfo::OperatingSystemVersion().c_str(),
- version, major, minor)));
+ base::SysInfo::OperatingSystemVersion().c_str())));
return true;
}
diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc
index b0ac166..9fe3e12 100644
--- a/chrome/browser/importer/importer_unittest.cc
+++ b/chrome/browser/importer/importer_unittest.cc
@@ -205,7 +205,7 @@ class TestObserver : public ProfileWriter,
EXPECT_EQ(arraysize(kIEBookmarks), bookmark_count_);
EXPECT_EQ(1, history_count_);
#if 0 // This part of the test is disabled. See bug #2466
- if (base::win::GetVersion() < base::win::VERSION_VISTA)
+ if (base::win::GetVersion() >= base::win::VERSION_VISTA)
EXPECT_EQ(0, password_count_);
else
EXPECT_EQ(1, password_count_);
diff --git a/chrome/browser/memory_details_win.cc b/chrome/browser/memory_details_win.cc
index c954a8e..576c74c 100644
--- a/chrome/browser/memory_details_win.cc
+++ b/chrome/browser/memory_details_win.cc
@@ -72,8 +72,8 @@ void MemoryDetails::CollectProcessData(
for (unsigned int index = 0; index < process_data_.size(); index++)
process_data_[index].processes.clear();
- base::win::WindowsArchitecture windows_architecture =
- base::win::GetWindowsArchitecture();
+ base::win::OSInfo::WindowsArchitecture windows_architecture =
+ base::win::OSInfo::GetInstance()->architecture();
base::win::ScopedHandle snapshot(
::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0));
@@ -93,10 +93,10 @@ void MemoryDetails::CollectProcessData(
if (!process_handle.Get())
continue;
bool is_64bit_process =
- ((windows_architecture == base::win::X64_ARCHITECTURE) ||
- (windows_architecture == base::win::IA64_ARCHITECTURE)) &&
- (base::win::GetWOW64StatusForProcess(process_handle) ==
- base::win::WOW64_DISABLED);
+ ((windows_architecture == base::win::OSInfo::X64_ARCHITECTURE) ||
+ (windows_architecture == base::win::OSInfo::IA64_ARCHITECTURE)) &&
+ (base::win::OSInfo::GetWOW64StatusForProcess(process_handle) ==
+ base::win::OSInfo::WOW64_DISABLED);
for (unsigned int index2 = 0; index2 < process_data_.size(); index2++) {
if (_wcsicmp(process_data_[index2].process_name.c_str(),
process_entry.szExeFile) != 0)
diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc
index 528e380..d23b51c 100644
--- a/chrome/browser/nacl_host/nacl_process_host.cc
+++ b/chrome/browser/nacl_host/nacl_process_host.cc
@@ -56,7 +56,8 @@ NaClProcessHost::NaClProcessHost(const std::wstring& url)
running_on_wow64_(false) {
set_name(url);
#if defined(OS_WIN)
- running_on_wow64_ = (base::win::GetWOW64Status() == base::win::WOW64_ENABLED);
+ running_on_wow64_ = (base::win::OSInfo::GetInstance()->wow64_status() ==
+ base::win::OSInfo::WOW64_ENABLED);
#endif
}
diff --git a/chrome/browser/ui/views/about_chrome_view.cc b/chrome/browser/ui/views/about_chrome_view.cc
index 70505fb..93faa2a 100644
--- a/chrome/browser/ui/views/about_chrome_view.cc
+++ b/chrome/browser/ui/views/about_chrome_view.cc
@@ -532,10 +532,8 @@ void AboutChromeView::ViewHierarchyChanged(bool is_add,
// on-demand updates. Silent updates (in the background) should still
// work as before - enabling UAC or installing the latest service pack
// for Vista is another option.
- int service_pack_major = 0, service_pack_minor = 0;
- base::win::GetServicePackLevel(&service_pack_major, &service_pack_minor);
if (!(base::win::GetVersion() == base::win::VERSION_VISTA &&
- (service_pack_major == 0) &&
+ (base::win::OSInfo::GetInstance()->service_pack().major == 0) &&
!base::win::UserAccountControlIsEnabled())) {
UpdateStatus(UPGRADE_CHECK_STARTED, GOOGLE_UPDATE_NO_ERROR);
// CheckForUpdate(false, ...) means don't upgrade yet.
diff --git a/chrome/installer/gcapi/gcapi.cc b/chrome/installer/gcapi/gcapi.cc
index 5ba9251..dc38bbe 100644
--- a/chrome/installer/gcapi/gcapi.cc
+++ b/chrome/installer/gcapi/gcapi.cc
@@ -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,10 +8,12 @@
#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"
namespace {
@@ -156,31 +158,31 @@ bool ReadValueFromRegistry(HKEY root_key, const wchar_t *sub_key,
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.
+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));
+
+ // Windows Vista is version 6.0.
+ if (version_info.dwMajorVersion >= 6)
+ return VERSION_VISTA_OR_HIGHER;
+
+ // 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;
+
+ // 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;
}
// Note this function should not be called on old Windows versions where these
@@ -230,9 +232,8 @@ bool VerifyHKLMAccess(const wchar_t* sub_key) {
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 ((GetWindowsVersion() < VERSION_VISTA_OR_HIGHER) ||
+ !VerifyAdminGroup())
return false;
HANDLE process_token;
@@ -287,9 +288,9 @@ DLLEXPORT BOOL __stdcall GoogleChromeCompatibilityCheck(BOOL set_flag,
DWORD *reasons) {
DWORD local_reasons = 0;
- bool is_vista_or_later = false;
+ WindowsVersion windows_version = GetWindowsVersion();
// System requirements?
- if (!IsWinXPSp2OrLater(&is_vista_or_later))
+ if (windows_version == VERSION_BELOW_XP_SP2)
local_reasons |= GCCC_ERROR_OSNOTSUPPORTED;
if (IsChromeInstalled(HKEY_LOCAL_MACHINE))
@@ -300,7 +301,8 @@ DLLEXPORT BOOL __stdcall GoogleChromeCompatibilityCheck(BOOL set_flag,
if (!VerifyHKLMAccess(kChromeRegClientsKey)) {
local_reasons |= GCCC_ERROR_ACCESSDENIED;
- } else if (is_vista_or_later && !VerifyAdminGroup()) {
+ } else if ((windows_version == VERSION_VISTA_OR_HIGHER) &&
+ !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;
diff --git a/chrome/installer/setup/install_worker.cc b/chrome/installer/setup/install_worker.cc
index 8b11835..7bdc9e5 100644
--- a/chrome/installer/setup/install_worker.cc
+++ b/chrome/installer/setup/install_worker.cc
@@ -512,7 +512,8 @@ void AddInstallWorkItems(const InstallationState& original_state,
// Extra executable for 64 bit systems.
// NOTE: We check for "not disabled" so that if the API call fails, we play it
// safe and copy the executable anyway.
- if (base::win::GetWOW64Status() != base::win::WOW64_DISABLED) {
+ if (base::win::OSInfo::GetInstance()->wow64_status() !=
+ base::win::OSInfo::WOW64_DISABLED) {
install_list->AddMoveTreeWorkItem(
src_path.Append(installer::kWowHelperExe).value(),
target_path.Append(installer::kWowHelperExe).value(),
diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc
index c2ee5eb..89dd58a 100644
--- a/chrome/installer/util/google_chrome_distribution.cc
+++ b/chrome/installer/util/google_chrome_distribution.cc
@@ -326,14 +326,10 @@ void GoogleChromeDistribution::DoPostUninstallOperations(
// need to escape the string before using it in a URL.
const std::wstring kVersionParam = L"crversion";
const std::wstring kOSParam = L"os";
- std::wstring os_version = L"na";
- OSVERSIONINFO version_info;
- version_info.dwOSVersionInfoSize = sizeof(version_info);
- if (GetVersionEx(&version_info)) {
- os_version = StringPrintf(L"%d.%d.%d", version_info.dwMajorVersion,
- version_info.dwMinorVersion,
- version_info.dwBuildNumber);
- }
+ base::win::OSInfo::VersionNumber version_number =
+ base::win::OSInfo::GetInstance()->version_number();
+ std::wstring os_version = StringPrintf(L"%d.%d.%d", version_number.major,
+ version_number.minor, version_number.build);
FilePath iexplore;
if (!PathService::Get(base::DIR_PROGRAM_FILES, &iexplore))
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc
index 999d84a..d1110de 100644
--- a/chrome/installer/util/install_util.cc
+++ b/chrome/installer/util/install_util.cc
@@ -19,6 +19,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/string_util.h"
+#include "base/sys_info.h"
#include "base/values.h"
#include "base/version.h"
#include "base/win/registry.h"
@@ -136,15 +137,13 @@ Version* InstallUtil::GetChromeVersion(BrowserDistribution* dist,
}
bool InstallUtil::IsOSSupported() {
- int major, minor;
- base::win::Version version = base::win::GetVersion();
- base::win::GetServicePackLevel(&major, &minor);
-
// We do not support Win2K or older, or XP without service pack 2.
- VLOG(1) << "Windows Version: " << version
- << ", Service Pack: " << major << "." << minor;
+ VLOG(1) << base::SysInfo::OperatingSystemName() << ' '
+ << base::SysInfo::OperatingSystemVersion();
+ base::win::Version version = base::win::GetVersion();
return (version > base::win::VERSION_XP) ||
- (version == base::win::VERSION_XP && major >= 2);
+ ((version == base::win::VERSION_XP) &&
+ (base::win::OSInfo::GetInstance()->service_pack().major >= 2));
}
void InstallUtil::WriteInstallerResult(bool system_install,
diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc
index 3e40ea3..84a7ff8 100644
--- a/chrome/renderer/renderer_glue.cc
+++ b/chrome/renderer/renderer_glue.cc
@@ -43,9 +43,7 @@
#include "native_client/src/trusted/plugin/nacl_entry_points.h"
#endif
-#if defined(OS_WIN)
-#include <strsafe.h> // note: per msdn docs, this must *follow* other includes
-#elif defined(OS_LINUX)
+#if defined(OS_LINUX)
#include "content/renderer/renderer_sandbox_support_linux.h"
#endif
diff --git a/chrome/test/out_of_proc_test_runner.cc b/chrome/test/out_of_proc_test_runner.cc
index 6e4bc3b..5d23954 100644
--- a/chrome/test/out_of_proc_test_runner.cc
+++ b/chrome/test/out_of_proc_test_runner.cc
@@ -579,6 +579,18 @@ int main(int argc, char** argv) {
return ChromeTestSuite(argc, argv).Run();
}
+ // The exit manager is in charge of calling the dtors of singleton objects.
+ // On Windows, the call to ChromeMain() below will construct one for the
+ // chrome.dll module, but that global is not shared with this module, so if
+ // chrome.dll calls back out to this module and the called code uses a
+ // singleton, we'll need this. On other platforms, ChromeMain() isn't called
+ // at all below, so this is the lone exit manager for any code after this
+ // point.
+ // NOTE: We can't init this atop main() because ChromeTestSuite, as a subclass
+ // of TestSuite, creates one. So we wait until after the Run() call above to
+ // create the manager for the code path that _doesn't_ use ChromeTestSuite.
+ base::AtExitManager exit_manager;
+
#if defined(OS_WIN)
if (command_line->HasSwitch(switches::kProcessType)) {
// This is a child process, call ChromeMain.
diff --git a/media/tools/mfplayer/mf_playback_main.cc b/media/tools/mfplayer/mf_playback_main.cc
index 3ae8164..3ce897c 100644
--- a/media/tools/mfplayer/mf_playback_main.cc
+++ b/media/tools/mfplayer/mf_playback_main.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 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.
@@ -6,7 +6,9 @@
#include "media/tools/mfplayer/mfplayer.h"
#include <mfapi.h>
+#define STRSAFE_NO_DEPRECATE
#include <strsafe.h>
+
#include <cassert>
namespace mfplayer {
diff --git a/media/tools/mfplayer/mfplayer.cc b/media/tools/mfplayer/mfplayer.cc
index 79894ee..7ef51e1 100644
--- a/media/tools/mfplayer/mfplayer.cc
+++ b/media/tools/mfplayer/mfplayer.cc
@@ -7,9 +7,9 @@
#include <mfapi.h>
#include <mferror.h>
#include <shlwapi.h>
-#include <strsafe.h>
#include <cassert>
+#include <cstdio>
template <class T>
static void SafeRelease(T** pptr) {
diff --git a/sandbox/src/Wow64.cc b/sandbox/src/Wow64.cc
index 9284fe8..60c63fd 100644
--- a/sandbox/src/Wow64.cc
+++ b/sandbox/src/Wow64.cc
@@ -88,7 +88,8 @@ Wow64::~Wow64() {
// bit version of ntdll is loaded, we'll remove the interception and return to
// our caller.
bool Wow64::WaitForNtdll() {
- if (base::win::GetWOW64Status() != base::win::WOW64_ENABLED)
+ if (base::win::OSInfo::GetInstance()->wow64_status() !=
+ base::win::OSInfo::WOW64_ENABLED)
return true;
const size_t page_size = 4096;
diff --git a/sandbox/src/dep_test.cc b/sandbox/src/dep_test.cc
index 7d57c6e..91d4e67 100644
--- a/sandbox/src/dep_test.cc
+++ b/sandbox/src/dep_test.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -12,32 +12,6 @@ namespace sandbox {
namespace {
-class DepTest : public testing::Test {
- public:
- static bool IsTestCaseDisabled() {
- OSVERSIONINFOEX version_info;
- version_info.dwOSVersionInfoSize = sizeof version_info;
- GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info));
-
- // Windows 2000 doesn't support DEP at all.
- if (version_info.dwMajorVersion == 5 && version_info.dwMinorVersion == 0)
- return true;
-
- // Windows XP Service Pack 0 and 1 don't support DEP at all.
- if (version_info.dwMajorVersion == 5 && version_info.dwMinorVersion == 1
- && version_info.wServicePackMajor < 2)
- return true;
-
- // Bug 1212371 Vista SP0 DEP support is half-baked. Nobody seem to have
- // noticed!
- if (version_info.dwMajorVersion == 6 &&
- version_info.wServicePackMajor == 0)
- return true;
-
- return false;
- }
-};
-
BYTE kReturnCode[] = {
// ret
0xC3,
@@ -167,7 +141,7 @@ SBOX_TESTS_COMMAND int CheckDepLevel(int argc, wchar_t **argv) {
} // namespace
// This test is disabled. See bug 1275842
-TEST_F(DepTest, DISABLED_TestDepDisable) {
+TEST(DepTest, DISABLED_TestDepDisable) {
TestRunner runner(JOB_UNPROTECTED, USER_INTERACTIVE, USER_INTERACTIVE);
runner.SetTimeout(INFINITE);
diff --git a/sandbox/src/integrity_level_test.cc b/sandbox/src/integrity_level_test.cc
index cdc8da7..c6e0b64 100644
--- a/sandbox/src/integrity_level_test.cc
+++ b/sandbox/src/integrity_level_test.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 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.
@@ -45,7 +45,7 @@ SBOX_TESTS_COMMAND int CheckIntegrityLevel(int argc, wchar_t **argv) {
}
TEST(IntegrityLevelTest, TestLowILReal) {
- if (base::win::VERSION_VISTA != base::win::GetVersion())
+ if (base::win::GetVersion() != base::win::VERSION_VISTA)
return;
TestRunner runner(JOB_LOCKDOWN, USER_INTERACTIVE, USER_INTERACTIVE);
@@ -61,7 +61,7 @@ TEST(IntegrityLevelTest, TestLowILReal) {
}
TEST(DelayedIntegrityLevelTest, TestLowILDelayed) {
- if (base::win::VERSION_VISTA != base::win::GetVersion())
+ if (base::win::GetVersion() != base::win::VERSION_VISTA)
return;
TestRunner runner(JOB_LOCKDOWN, USER_INTERACTIVE, USER_INTERACTIVE);
@@ -77,7 +77,7 @@ TEST(DelayedIntegrityLevelTest, TestLowILDelayed) {
}
TEST(IntegrityLevelTest, TestNoILChange) {
- if (base::win::VERSION_VISTA != base::win::GetVersion())
+ if (base::win::GetVersion() != base::win::VERSION_VISTA)
return;
TestRunner runner(JOB_LOCKDOWN, USER_INTERACTIVE, USER_INTERACTIVE);
diff --git a/sandbox/src/interception.cc b/sandbox/src/interception.cc
index 577d079..b66fddd 100644
--- a/sandbox/src/interception.cc
+++ b/sandbox/src/interception.cc
@@ -438,7 +438,8 @@ bool InterceptionManager::PatchClientFunctions(DllInterceptionData* thunks,
#endif
ServiceResolverThunk* thunk;
- if (base::win::GetWOW64Status() == base::win::WOW64_ENABLED)
+ if (base::win::OSInfo::GetInstance()->wow64_status() ==
+ base::win::OSInfo::WOW64_ENABLED)
thunk = new Wow64ResolverThunk(child_->Process(), relaxed_);
else if (!IsXPSP2OrLater())
thunk = new Win2kResolverThunk(child_->Process(), relaxed_);
diff --git a/sandbox/src/job.cc b/sandbox/src/job.cc
index e0dca68..8ed3a77 100644
--- a/sandbox/src/job.cc
+++ b/sandbox/src/job.cc
@@ -1,8 +1,10 @@
-// Copyright (c) 2006-2008 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.
#include "sandbox/src/job.h"
+
+#include "base/win/windows_version.h"
#include "sandbox/src/restricted_token.h"
namespace sandbox {
@@ -49,17 +51,11 @@ DWORD Job::Init(JobLevel security_level, wchar_t *job_name,
jbur.UIRestrictionsClass |= JOB_OBJECT_UILIMIT_EXITWINDOWS;
}
case JOB_UNPROTECTED: {
- OSVERSIONINFO version_info = {0};
- version_info.dwOSVersionInfoSize = sizeof(version_info);
- GetVersionEx(&version_info);
-
// The JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE flag is not supported on
// Windows 2000. We need a mechanism on Windows 2000 to ensure
// that processes in the job are terminated when the job is closed
- if ((5 == version_info.dwMajorVersion) &&
- (0 == version_info.dwMinorVersion)) {
+ if (base::win::GetVersion() == base::win::VERSION_PRE_XP)
break;
- }
jeli.BasicLimitInformation.LimitFlags |=
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
diff --git a/sandbox/src/sandbox_utils.cc b/sandbox/src/sandbox_utils.cc
index 9554514..b93434c 100644
--- a/sandbox/src/sandbox_utils.cc
+++ b/sandbox/src/sandbox_utils.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -7,6 +7,7 @@
#include <windows.h>
#include "base/logging.h"
+#include "base/win/windows_version.h"
#include "sandbox/src/internal_types.h"
#include "sandbox/src/nt_internals.h"
@@ -56,33 +57,10 @@ bool GetModuleHandleHelper(DWORD flags, const wchar_t* module_name,
}
bool IsXPSP2OrLater() {
- OSVERSIONINFOEX version = {0};
- version.dwOSVersionInfoSize = sizeof(version);
- if (!::GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version))) {
- NOTREACHED();
- return false;
- }
-
- // Vista or later
- if (version.dwMajorVersion > 5)
- return true;
-
- // 2k, xp or 2003
- if (version.dwMajorVersion == 5) {
- // 2003
- if (version.dwMinorVersion > 1)
- return true;
-
- // 2000
- if (version.dwMinorVersion == 0)
- return false;
-
- // Windows Xp Sp2 or later
- if (version.wServicePackMajor >= 2)
- return true;
- }
-
- return false;
+ base::win::Version version = base::win::GetVersion();
+ return (version > base::win::VERSION_XP) ||
+ ((version == base::win::VERSION_XP) &&
+ (base::win::OSInfo::GetInstance()->service_pack().major >= 2));
}
void InitObjectAttribs(const std::wstring& name, ULONG attributes, HANDLE root,
diff --git a/sandbox/src/service_resolver_unittest.cc b/sandbox/src/service_resolver_unittest.cc
index f5e29f3..36ad1d0f 100644
--- a/sandbox/src/service_resolver_unittest.cc
+++ b/sandbox/src/service_resolver_unittest.cc
@@ -120,7 +120,8 @@ NTSTATUS PatchNtdllWithResolver(const char* function, bool relaxed,
}
sandbox::ServiceResolverThunk* GetTestResolver(bool relaxed) {
- if (base::win::GetWOW64Status() == base::win::WOW64_ENABLED)
+ if (base::win::OSInfo::GetInstance()->wow64_status() ==
+ base::win::OSInfo::WOW64_ENABLED)
return new Wow64ResolverTest(relaxed);
if (!sandbox::IsXPSP2OrLater())
return new Win2kResolverTest(relaxed);
diff --git a/sandbox/tests/common/controller.cc b/sandbox/tests/common/controller.cc
index 7efd374..b618069 100644
--- a/sandbox/tests/common/controller.cc
+++ b/sandbox/tests/common/controller.cc
@@ -55,9 +55,10 @@ std::wstring MakePathToSysWow64(const wchar_t* name, bool is_obj_man_path) {
namespace sandbox {
std::wstring MakePathToSys(const wchar_t* name, bool is_obj_man_path) {
- if (base::win::GetWOW64Status() == base::win::WOW64_ENABLED)
- return MakePathToSysWow64(name, is_obj_man_path);
- return MakePathToSys32(name, is_obj_man_path);
+ return (base::win::OSInfo::GetInstance()->wow64_status() ==
+ base::win::OSInfo::WOW64_ENABLED) ?
+ MakePathToSysWow64(name, is_obj_man_path) :
+ MakePathToSys32(name, is_obj_man_path);
}
BrokerServices* GetBroker() {
@@ -138,7 +139,8 @@ bool TestRunner::AddRuleSys32(TargetPolicy::Semantics semantics,
if (!AddRule(TargetPolicy::SUBSYS_FILES, semantics, win32_path.c_str()))
return false;
- if (base::win::GetWOW64Status() != base::win::WOW64_ENABLED)
+ if (base::win::OSInfo::GetInstance()->wow64_status() !=
+ base::win::OSInfo::WOW64_ENABLED)
return true;
win32_path = MakePathToSysWow64(pattern, false);
diff --git a/sandbox/tests/integration_tests/integration_tests.cc b/sandbox/tests/integration_tests/integration_tests.cc
index f7cbd15..5330ae9 100644
--- a/sandbox/tests/integration_tests/integration_tests.cc
+++ b/sandbox/tests/integration_tests/integration_tests.cc
@@ -1,11 +1,15 @@
-// Copyright (c) 2006-2008 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.
+#include "base/at_exit.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "sandbox/tests/common/controller.h"
int wmain(int argc, wchar_t **argv) {
+ // The exit manager is in charge of calling the dtors of singleton objects.
+ base::AtExitManager exit_manager;
+
if (argc >= 2) {
if (0 == _wcsicmp(argv[1], L"-child"))
// This instance is a child, not the test.
diff --git a/sandbox/tests/unit_tests/unit_tests.cc b/sandbox/tests/unit_tests/unit_tests.cc
index 521be42..1614612 100644
--- a/sandbox/tests/unit_tests/unit_tests.cc
+++ b/sandbox/tests/unit_tests/unit_tests.cc
@@ -1,10 +1,14 @@
-// Copyright (c) 2006-2008 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.
+#include "base/at_exit.h"
#include "testing/gtest/include/gtest/gtest.h"
int wmain(int argc, wchar_t **argv) {
+ // The exit manager is in charge of calling the dtors of singleton objects.
+ base::AtExitManager exit_manager;
+
if (argc >= 2) {
if (0 == _wcsicmp(argv[1], L"-child"))
// This instance is a child, not the test.
diff --git a/sandbox/tests/validation_tests/unit_tests.cc b/sandbox/tests/validation_tests/unit_tests.cc
index 4cd36ce..c5bc5cd 100644
--- a/sandbox/tests/validation_tests/unit_tests.cc
+++ b/sandbox/tests/validation_tests/unit_tests.cc
@@ -1,11 +1,15 @@
-// Copyright (c) 2006-2008 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.
+#include "base/at_exit.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "sandbox/tests/common/controller.h"
int wmain(int argc, wchar_t **argv) {
+ // The exit manager is in charge of calling the dtors of singleton objects.
+ base::AtExitManager exit_manager;
+
if (argc >= 2) {
if (0 == _wcsicmp(argv[1], L"-child"))
return sandbox::DispatchCall(argc, argv);
diff --git a/webkit/glue/user_agent.cc b/webkit/glue/user_agent.cc
index c8d8b24..f92bc9a 100644
--- a/webkit/glue/user_agent.cc
+++ b/webkit/glue/user_agent.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 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.
@@ -64,14 +64,15 @@ std::string BuildOSCpuInfo() {
#if defined(OS_WIN)
std::string architecture_token;
- if (base::win::GetWOW64Status() == base::win::WOW64_ENABLED) {
+ base::win::OSInfo* os_info = base::win::OSInfo::GetInstance();
+ if (os_info->wow64_status() == base::win::OSInfo::WOW64_ENABLED) {
architecture_token = "; WOW64";
} else {
- base::win::WindowsArchitecture windows_architecture =
- base::win::GetWindowsArchitecture();
- if (windows_architecture == base::win::X64_ARCHITECTURE)
+ base::win::OSInfo::WindowsArchitecture windows_architecture =
+ os_info->architecture();
+ if (windows_architecture == base::win::OSInfo::X64_ARCHITECTURE)
architecture_token = "; Win64; x64";
- else if (windows_architecture == base::win::IA64_ARCHITECTURE)
+ else if (windows_architecture == base::win::OSInfo::IA64_ARCHITECTURE)
architecture_token = "; Win64; IA64";
}
#endif
diff --git a/webkit/plugins/npapi/test/plugin_npobject_proxy_test.cc b/webkit/plugins/npapi/test/plugin_npobject_proxy_test.cc
index c9cd27f..2c28089 100644
--- a/webkit/plugins/npapi/test/plugin_npobject_proxy_test.cc
+++ b/webkit/plugins/npapi/test/plugin_npobject_proxy_test.cc
@@ -1,14 +1,10 @@
-// Copyright (c) 2010 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.
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#if defined(OS_WIN)
-#define STRSAFE_NO_DEPRECATE
-#include <strsafe.h>
-#endif
#include "webkit/plugins/npapi/test/plugin_npobject_proxy_test.h"
namespace NPAPIClient {