OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/chrome_version_info.h" | 5 #include "chrome/common/chrome_version_info.h" |
6 | 6 |
7 #include "base/basictypes.h" | |
8 #include "base/profiler/scoped_tracker.h" | 7 #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" | 8 #include "build/build_config.h" |
12 #include "chrome/common/chrome_version_info_values.h" | |
13 #include "chrome/grit/chromium_strings.h" | 9 #include "chrome/grit/chromium_strings.h" |
14 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
15 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
16 | 12 |
17 namespace chrome { | 13 namespace chrome { |
18 | 14 |
19 std::string VersionInfo::ProductNameAndVersionForUserAgent() const { | |
20 return "Chrome/" + Version(); | |
21 } | |
22 | |
23 VersionInfo::VersionInfo() { | 15 VersionInfo::VersionInfo() { |
24 } | 16 } |
25 | 17 |
26 VersionInfo::~VersionInfo() { | 18 VersionInfo::~VersionInfo() { |
27 } | 19 } |
28 | 20 |
29 std::string VersionInfo::Name() const { | 21 // static |
30 return PRODUCT_NAME; | 22 std::string VersionInfo::ProductNameAndVersionForUserAgent() { |
| 23 return version_info::GetProductNameAndVersionForUserAgent(); |
31 } | 24 } |
32 | 25 |
33 std::string VersionInfo::Version() const { | 26 // static |
34 return PRODUCT_VERSION; | 27 std::string VersionInfo::Name() { |
| 28 return version_info::GetProductName(); |
35 } | 29 } |
36 | 30 |
37 std::string VersionInfo::LastChange() const { | 31 // static |
38 return LAST_CHANGE; | 32 std::string VersionInfo::Version() { |
| 33 return version_info::GetVersionNumber(); |
39 } | 34 } |
40 | 35 |
41 bool VersionInfo::IsOfficialBuild() const { | 36 // static |
42 return IS_OFFICIAL_BUILD; | 37 std::string VersionInfo::LastChange() { |
| 38 return version_info::GetLastChange(); |
43 } | 39 } |
44 | 40 |
45 std::string VersionInfo::CreateVersionString() const { | 41 // static |
| 42 bool VersionInfo::IsOfficialBuild() { |
| 43 return version_info::IsOfficialBuild(); |
| 44 } |
| 45 |
| 46 // static |
| 47 std::string VersionInfo::OSType() { |
| 48 return version_info::GetOSType(); |
| 49 } |
| 50 |
| 51 // static |
| 52 std::string VersionInfo::GetChannelString() { |
| 53 return version_info::GetChannelString(GetChannel()); |
| 54 } |
| 55 |
| 56 // static |
| 57 std::string VersionInfo::CreateVersionString() { |
46 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is | 58 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is |
47 // fixed. | 59 // fixed. |
48 tracked_objects::ScopedTracker tracking_profile( | 60 tracked_objects::ScopedTracker tracking_profile( |
49 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 61 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
50 "422460 VersionInfo::CreateVersionString")); | 62 "422460 VersionInfo::CreateVersionString")); |
51 | 63 |
52 std::string current_version; | 64 return version_info::GetVersionStringWithModifier(GetVersionStringModifier()); |
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; | |
67 } | |
68 | |
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 | |
95 } | |
96 | |
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; | |
115 } | |
116 return std::string(); | |
117 } | 65 } |
118 | 66 |
119 } // namespace chrome | 67 } // namespace chrome |
OLD | NEW |