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/file_version_info.h"
9 #include "base/profiler/scoped_tracker.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "base/threading/thread_restrictions.h"
12 #include "build/build_config.h"
13 #include "chrome/common/chrome_version_info_values.h"
14 #include "chrome/grit/chromium_strings.h"
15 #include "chrome/grit/generated_resources.h"
16 #include "ui/base/l10n/l10n_util.h"
20 std::string
VersionInfo::ProductNameAndVersionForUserAgent() const {
21 return "Chrome/" + Version();
24 VersionInfo::VersionInfo() {
27 VersionInfo::~VersionInfo() {
30 std::string
VersionInfo::Name() const {
34 std::string
VersionInfo::Version() const {
35 return PRODUCT_VERSION
;
38 std::string
VersionInfo::LastChange() const {
42 bool VersionInfo::IsOfficialBuild() const {
43 return IS_OFFICIAL_BUILD
;
46 std::string
VersionInfo::CreateVersionString() const {
47 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is
49 tracked_objects::ScopedTracker
tracking_profile(
50 FROM_HERE_WITH_EXPLICIT_FUNCTION(
51 "422460 VersionInfo::CreateVersionString"));
53 std::string current_version
;
54 current_version
+= Version();
55 #if !defined(GOOGLE_CHROME_BUILD)
56 current_version
+= " (";
57 current_version
+= l10n_util::GetStringUTF8(IDS_ABOUT_VERSION_UNOFFICIAL
);
58 current_version
+= " ";
59 current_version
+= LastChange();
60 current_version
+= " ";
61 current_version
+= OSType();
62 current_version
+= ")";
64 std::string modifier
= GetVersionStringModifier();
65 if (!modifier
.empty())
66 current_version
+= " " + modifier
;
67 return current_version
;
70 std::string
VersionInfo::OSType() const {
75 #elif defined(OS_MACOSX)
77 #elif defined(OS_CHROMEOS)
78 #if defined(GOOGLE_CHROME_BUILD)
83 #elif defined(OS_ANDROID)
85 #elif defined(OS_LINUX)
87 #elif defined(OS_FREEBSD)
89 #elif defined(OS_OPENBSD)
91 #elif defined(OS_SOLARIS)
99 std::string
VersionInfo::GetChannelString() {
100 switch (GetChannel()) {
101 case chrome::VersionInfo::CHANNEL_STABLE
:
104 case chrome::VersionInfo::CHANNEL_BETA
:
107 case chrome::VersionInfo::CHANNEL_DEV
:
110 case chrome::VersionInfo::CHANNEL_CANARY
:
113 case chrome::VersionInfo::CHANNEL_UNKNOWN
:
117 return std::string();
120 } // namespace chrome