Enable password generation only if sync for passwords is enabled.
[chromium-blink-merge.git] / base / win / windows_version.h
blob1061b47a97383fb40b0e79e9a1ead6dc86f2ea85
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_WIN_WINDOWS_VERSION_H_
6 #define BASE_WIN_WINDOWS_VERSION_H_
7 #pragma once
9 #include "base/base_export.h"
10 #include "base/basictypes.h"
12 typedef void* HANDLE;
14 namespace base {
15 namespace win {
17 // The running version of Windows. This is declared outside OSInfo for
18 // syntactic sugar reasons; see the declaration of GetVersion() below.
19 // NOTE: Keep these in order so callers can do things like
20 // "if (base::win::GetVersion() >= base::win::VERSION_VISTA) ...".
21 enum Version {
22 VERSION_PRE_XP = 0, // Not supported.
23 VERSION_XP,
24 VERSION_SERVER_2003, // Also includes Windows XP Professional x64.
25 VERSION_VISTA,
26 VERSION_SERVER_2008,
27 VERSION_WIN7,
28 VERSION_WIN8,
29 VERSION_WIN_LAST, // Indicates error condition.
32 // A singleton that can be used to query various pieces of information about the
33 // OS and process state. Note that this doesn't use the base Singleton class, so
34 // it can be used without an AtExitManager.
35 class BASE_EXPORT OSInfo {
36 public:
37 struct VersionNumber {
38 int major;
39 int minor;
40 int build;
43 struct ServicePack {
44 int major;
45 int minor;
48 // The processor architecture this copy of Windows natively uses. For
49 // example, given an x64-capable processor, we have three possibilities:
50 // 32-bit Chrome running on 32-bit Windows: X86_ARCHITECTURE
51 // 32-bit Chrome running on 64-bit Windows via WOW64: X64_ARCHITECTURE
52 // 64-bit Chrome running on 64-bit Windows: X64_ARCHITECTURE
53 enum WindowsArchitecture {
54 X86_ARCHITECTURE,
55 X64_ARCHITECTURE,
56 IA64_ARCHITECTURE,
57 OTHER_ARCHITECTURE,
60 // Whether a process is running under WOW64 (the wrapper that allows 32-bit
61 // processes to run on 64-bit versions of Windows). This will return
62 // WOW64_DISABLED for both "32-bit Chrome on 32-bit Windows" and "64-bit
63 // Chrome on 64-bit Windows". WOW64_UNKNOWN means "an error occurred", e.g.
64 // the process does not have sufficient access rights to determine this.
65 enum WOW64Status {
66 WOW64_DISABLED,
67 WOW64_ENABLED,
68 WOW64_UNKNOWN,
71 static OSInfo* GetInstance();
73 Version version() const { return version_; }
74 // The next two functions return arrays of values, [major, minor(, build)].
75 VersionNumber version_number() const { return version_number_; }
76 ServicePack service_pack() const { return service_pack_; }
77 WindowsArchitecture architecture() const { return architecture_; }
78 int processors() const { return processors_; }
79 size_t allocation_granularity() const { return allocation_granularity_; }
80 WOW64Status wow64_status() const { return wow64_status_; }
82 // Like wow64_status(), but for the supplied handle instead of the current
83 // process. This doesn't touch member state, so you can bypass the singleton.
84 static WOW64Status GetWOW64StatusForProcess(HANDLE process_handle);
86 private:
87 OSInfo();
88 ~OSInfo();
90 Version version_;
91 VersionNumber version_number_;
92 ServicePack service_pack_;
93 WindowsArchitecture architecture_;
94 int processors_;
95 size_t allocation_granularity_;
96 WOW64Status wow64_status_;
98 DISALLOW_COPY_AND_ASSIGN(OSInfo);
101 // Because this is by far the most commonly-requested value from the above
102 // singleton, we add a global-scope accessor here as syntactic sugar.
103 BASE_EXPORT Version GetVersion();
105 } // namespace win
106 } // namespace base
108 #endif // BASE_WIN_WINDOWS_VERSION_H_