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"
19 std::string
VersionInfo::ProductNameAndVersionForUserAgent() const {
20 return "Chrome/" + Version();
23 VersionInfo::VersionInfo() {
26 VersionInfo::~VersionInfo() {
29 std::string
VersionInfo::Name() const {
33 std::string
VersionInfo::Version() const {
34 return PRODUCT_VERSION
;
37 std::string
VersionInfo::LastChange() const {
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
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
+= ")";
63 std::string modifier
= GetVersionStringModifier();
64 if (!modifier
.empty())
65 current_version
+= " " + modifier
;
66 return current_version
;
69 std::string
VersionInfo::OSType() const {
74 #elif defined(OS_MACOSX)
76 #elif defined(OS_CHROMEOS)
77 #if defined(GOOGLE_CHROME_BUILD)
82 #elif defined(OS_ANDROID)
84 #elif defined(OS_LINUX)
86 #elif defined(OS_FREEBSD)
88 #elif defined(OS_OPENBSD)
90 #elif defined(OS_SOLARIS)
98 std::string
VersionInfo::GetChannelString() {
99 switch (GetChannel()) {
100 case chrome::VersionInfo::CHANNEL_STABLE
:
103 case chrome::VersionInfo::CHANNEL_BETA
:
106 case chrome::VersionInfo::CHANNEL_DEV
:
109 case chrome::VersionInfo::CHANNEL_CANARY
:
112 case chrome::VersionInfo::CHANNEL_UNKNOWN
:
116 return std::string();
119 } // namespace chrome