No dual_mode on Win10+ shortcuts.
[chromium-blink-merge.git] / chrome / common / chrome_version_info.cc
blob996da1bca68f37768537dedbcdb67c4e18a7411e
1 // Copyright (c) 2012 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 #include "chrome/common/chrome_version_info.h"
7 #include "base/basictypes.h"
8 #include "base/profiler/scoped_tracker.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "base/threading/thread_restrictions.h"
11 #include "build/build_config.h"
12 #include "chrome/common/chrome_version_info_values.h"
13 #include "chrome/grit/chromium_strings.h"
14 #include "chrome/grit/generated_resources.h"
15 #include "ui/base/l10n/l10n_util.h"
17 namespace chrome {
19 std::string VersionInfo::ProductNameAndVersionForUserAgent() const {
20 return "Chrome/" + Version();
23 VersionInfo::VersionInfo() {
26 VersionInfo::~VersionInfo() {
29 std::string VersionInfo::Name() const {
30 return PRODUCT_NAME;
33 std::string VersionInfo::Version() const {
34 return PRODUCT_VERSION;
37 std::string VersionInfo::LastChange() const {
38 return LAST_CHANGE;
41 bool VersionInfo::IsOfficialBuild() const {
42 return IS_OFFICIAL_BUILD;
45 std::string VersionInfo::CreateVersionString() const {
46 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is
47 // fixed.
48 tracked_objects::ScopedTracker tracking_profile(
49 FROM_HERE_WITH_EXPLICIT_FUNCTION(
50 "422460 VersionInfo::CreateVersionString"));
52 std::string current_version;
53 current_version += Version();
54 #if !defined(GOOGLE_CHROME_BUILD)
55 current_version += " (";
56 current_version += l10n_util::GetStringUTF8(IDS_ABOUT_VERSION_UNOFFICIAL);
57 current_version += " ";
58 current_version += LastChange();
59 current_version += " ";
60 current_version += OSType();
61 current_version += ")";
62 #endif
63 std::string modifier = GetVersionStringModifier();
64 if (!modifier.empty())
65 current_version += " " + modifier;
66 return current_version;
69 std::string VersionInfo::OSType() const {
70 #if defined(OS_WIN)
71 return "Windows";
72 #elif defined(OS_IOS)
73 return "iOS";
74 #elif defined(OS_MACOSX)
75 return "Mac OS X";
76 #elif defined(OS_CHROMEOS)
77 #if defined(GOOGLE_CHROME_BUILD)
78 return "Chrome OS";
79 #else
80 return "Chromium OS";
81 #endif
82 #elif defined(OS_ANDROID)
83 return "Android";
84 #elif defined(OS_LINUX)
85 return "Linux";
86 #elif defined(OS_FREEBSD)
87 return "FreeBSD";
88 #elif defined(OS_OPENBSD)
89 return "OpenBSD";
90 #elif defined(OS_SOLARIS)
91 return "Solaris";
92 #else
93 return "Unknown";
94 #endif
97 // static
98 std::string VersionInfo::GetChannelString() {
99 switch (GetChannel()) {
100 case chrome::VersionInfo::CHANNEL_STABLE:
101 return "stable";
102 break;
103 case chrome::VersionInfo::CHANNEL_BETA:
104 return "beta";
105 break;
106 case chrome::VersionInfo::CHANNEL_DEV:
107 return "dev";
108 break;
109 case chrome::VersionInfo::CHANNEL_CANARY:
110 return "canary";
111 break;
112 case chrome::VersionInfo::CHANNEL_UNKNOWN:
113 return "unknown";
114 break;
116 return std::string();
119 } // namespace chrome