summaryrefslogtreecommitdiffstats
path: root/base/sys_info_win.cc
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-29 22:18:01 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-29 22:18:01 +0000
commit05f9b688e319fcb092be0e06f7b72d39dd3113b3 (patch)
tree6d24be7f9b788bbebbff6b2349e51dec49034ce6 /base/sys_info_win.cc
parent86ec30d6710923cf1c193eb88b1e6251f831e0ef (diff)
downloadchromium_src-05f9b688e319fcb092be0e06f7b72d39dd3113b3.zip
chromium_src-05f9b688e319fcb092be0e06f7b72d39dd3113b3.tar.gz
chromium_src-05f9b688e319fcb092be0e06f7b72d39dd3113b3.tar.bz2
Refactoring for portability:
- Move chrome/common/env_util to base/sys_info - Move chrome/common/rand_util to base/rand_util (new), simplify its public interface, and fix its implementation Patch by Paweł Hajdan, Jr. <phajdan.jr@gmail.com> http://codereview.chromium.org/4079 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2697 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/sys_info_win.cc')
-rw-r--r--base/sys_info_win.cc56
1 files changed, 56 insertions, 0 deletions
diff --git a/base/sys_info_win.cc b/base/sys_info_win.cc
index 2d3c203..4d52c4a 100644
--- a/base/sys_info_win.cc
+++ b/base/sys_info_win.cc
@@ -7,6 +7,8 @@
#include <windows.h>
#include "base/logging.h"
+#include "base/scoped_ptr.h"
+#include "base/string_util.h"
namespace base {
@@ -44,4 +46,58 @@ int64 SysInfo::AmountOfFreeDiskSpace(const std::wstring& path) {
return rv;
}
+// static
+bool SysInfo::HasEnvVar(const wchar_t* var) {
+ return GetEnvironmentVariable(var, NULL, 0) != 0;
+}
+
+// static
+std::wstring SysInfo::GetEnvVar(const wchar_t* var) {
+ DWORD value_length = GetEnvironmentVariable(var, NULL, 0);
+ if (value_length == 0) {
+ return L"";
+ }
+ scoped_array<wchar_t> value(new wchar_t[value_length]);
+ GetEnvironmentVariable(var, value.get(), value_length);
+ return std::wstring(value.get());
+}
+
+// static
+std::string SysInfo::OperatingSystemName() {
+ return "Windows NT";
+}
+
+// static
+std::string SysInfo::OperatingSystemVersion() {
+ OSVERSIONINFO info = {0};
+ info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&info);
+
+ return StringPrintf("%lu.%lu", info.dwMajorVersion, info.dwMinorVersion);
+}
+
+// TODO: Implement OperatingSystemVersionComplete, which would include
+// patchlevel/service pack number. See chrome/browser/views/bug_report_view.cc,
+// BugReportView::SetOSVersion.
+
+// static
+std::string SysInfo::CPUArchitecture() {
+ // TODO: Make this vary when we support any other architectures.
+ return "x86";
+}
+
+// static
+void SysInfo::GetPrimaryDisplayDimensions(int* width, int* height) {
+ if (width)
+ *width = GetSystemMetrics(SM_CXSCREEN);
+
+ if (height)
+ *height = GetSystemMetrics(SM_CYSCREEN);
+}
+
+// static
+int SysInfo::DisplayCount() {
+ return GetSystemMetrics(SM_CMONITORS);
+}
+
} // namespace base