1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
base / version_info / version_info.h [blame]
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_VERSION_INFO_VERSION_INFO_H_
#define BASE_VERSION_INFO_VERSION_INFO_H_
#include <string>
#include <string_view>
#include "base/sanitizer_buildflags.h"
#include "base/version_info/channel.h"
#include "base/version_info/version_info_values.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
namespace base {
class Version;
}
namespace version_info {
// Returns the product name, e.g. "Chromium" or "Google Chrome".
constexpr std::string_view GetProductName() {
return PRODUCT_NAME;
}
// Returns the version number, e.g. "6.0.490.1".
constexpr std::string_view GetVersionNumber() {
return PRODUCT_VERSION;
}
// Returns the major component (aka the milestone) of the version as an int,
// e.g. 6 when the version is "6.0.490.1".
int GetMajorVersionNumberAsInt();
// Like GetMajorVersionNumberAsInt(), but returns a string.
std::string GetMajorVersionNumber();
// Returns the result of GetVersionNumber() as a base::Version.
const base::Version& GetVersion();
// Returns a version control specific identifier of this release.
constexpr std::string_view GetLastChange() {
return LAST_CHANGE;
}
// Returns whether this is an "official" release of the current version, i.e.
// whether knowing GetVersionNumber() is enough to completely determine what
// GetLastChange() is.
constexpr bool IsOfficialBuild() {
return IS_OFFICIAL_BUILD;
}
// Returns the OS type, e.g. "Windows", "Linux", "FreeBSD", ...
constexpr std::string_view GetOSType() {
#if BUILDFLAG(IS_WIN)
return "Windows";
#elif BUILDFLAG(IS_IOS)
return "iOS";
#elif BUILDFLAG(IS_MAC)
return "Mac OS X";
#elif BUILDFLAG(IS_CHROMEOS)
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
return "ChromeOS";
#else
return "ChromiumOS";
#endif
#elif BUILDFLAG(IS_ANDROID)
return "Android";
#elif BUILDFLAG(IS_LINUX)
return "Linux";
#elif BUILDFLAG(IS_FREEBSD)
return "FreeBSD";
#elif BUILDFLAG(IS_OPENBSD)
return "OpenBSD";
#elif BUILDFLAG(IS_SOLARIS)
return "Solaris";
#elif BUILDFLAG(IS_FUCHSIA)
return "Fuchsia";
#else
return "Unknown";
#endif
}
// Returns a list of sanitizers enabled in this build.
constexpr std::string_view GetSanitizerList() {
return ""
#if defined(ADDRESS_SANITIZER)
"address "
#endif
#if BUILDFLAG(IS_HWASAN)
"hwaddress "
#endif
#if defined(LEAK_SANITIZER)
"leak "
#endif
#if defined(MEMORY_SANITIZER)
"memory "
#endif
#if defined(THREAD_SANITIZER)
"thread "
#endif
#if defined(UNDEFINED_SANITIZER)
"undefined "
#endif
;
}
} // namespace version_info
#endif // BASE_VERSION_INFO_VERSION_INFO_H_