Roll src/third_party/skia 4cd6713:0edd965
[chromium-blink-merge.git] / chrome / common / chrome_version_info.cc
blob134327990ef333863fb93389d0ffb1ccb4ef5262
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"
18 namespace chrome {
20 std::string VersionInfo::ProductNameAndVersionForUserAgent() const {
21 return "Chrome/" + Version();
24 VersionInfo::VersionInfo() {
27 VersionInfo::~VersionInfo() {
30 std::string VersionInfo::Name() const {
31 return PRODUCT_NAME;
34 std::string VersionInfo::Version() const {
35 return PRODUCT_VERSION;
38 std::string VersionInfo::LastChange() const {
39 return LAST_CHANGE;
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
48 // fixed.
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 += ")";
63 #endif
64 std::string modifier = GetVersionStringModifier();
65 if (!modifier.empty())
66 current_version += " " + modifier;
67 return current_version;
70 std::string VersionInfo::OSType() const {
71 #if defined(OS_WIN)
72 return "Windows";
73 #elif defined(OS_IOS)
74 return "iOS";
75 #elif defined(OS_MACOSX)
76 return "Mac OS X";
77 #elif defined(OS_CHROMEOS)
78 #if defined(GOOGLE_CHROME_BUILD)
79 return "Chrome OS";
80 #else
81 return "Chromium OS";
82 #endif
83 #elif defined(OS_ANDROID)
84 return "Android";
85 #elif defined(OS_LINUX)
86 return "Linux";
87 #elif defined(OS_FREEBSD)
88 return "FreeBSD";
89 #elif defined(OS_OPENBSD)
90 return "OpenBSD";
91 #elif defined(OS_SOLARIS)
92 return "Solaris";
93 #else
94 return "Unknown";
95 #endif
98 // static
99 std::string VersionInfo::GetChannelString() {
100 switch (GetChannel()) {
101 case chrome::VersionInfo::CHANNEL_STABLE:
102 return "stable";
103 break;
104 case chrome::VersionInfo::CHANNEL_BETA:
105 return "beta";
106 break;
107 case chrome::VersionInfo::CHANNEL_DEV:
108 return "dev";
109 break;
110 case chrome::VersionInfo::CHANNEL_CANARY:
111 return "canary";
112 break;
113 case chrome::VersionInfo::CHANNEL_UNKNOWN:
114 return "unknown";
115 break;
117 return std::string();
120 } // namespace chrome