Roll src/third_party/WebKit 9f7fb92:f103b33 (svn 202621:202622)
[chromium-blink-merge.git] / components / version_info / version_info.cc
blobde3f5802210711a56f1864b95beb7ed5f8865f7e
1 // Copyright 2015 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 "components/version_info/version_info.h"
7 #include "build/build_config.h"
8 #include "components/version_info/version_info_values.h"
9 #include "grit/components_strings.h"
10 #include "ui/base/l10n/l10n_util.h"
12 namespace version_info {
14 std::string GetProductNameAndVersionForUserAgent() {
15 return "Chrome/" + GetVersionNumber();
18 std::string GetProductName() {
19 return PRODUCT_NAME;
22 std::string GetVersionNumber() {
23 return PRODUCT_VERSION;
26 std::string GetLastChange() {
27 return LAST_CHANGE;
30 bool IsOfficialBuild() {
31 return IS_OFFICIAL_BUILD;
34 std::string GetOSType() {
35 #if defined(OS_WIN)
36 return "Windows";
37 #elif defined(OS_IOS)
38 return "iOS";
39 #elif defined(OS_MACOSX)
40 return "Mac OS X";
41 #elif defined(OS_CHROMEOS)
42 # if defined(GOOGLE_CHROME_BUILD)
43 return "Chrome OS";
44 # else
45 return "Chromium OS";
46 # endif
47 #elif defined(OS_ANDROID)
48 return "Android";
49 #elif defined(OS_LINUX)
50 return "Linux";
51 #elif defined(OS_FREEBSD)
52 return "FreeBSD";
53 #elif defined(OS_OPENBSD)
54 return "OpenBSD";
55 #elif defined(OS_SOLARIS)
56 return "Solaris";
57 #else
58 return "Unknown";
59 #endif
62 std::string GetChannelString(Channel channel) {
63 switch (channel) {
64 case Channel::STABLE:
65 return "stable";
66 break;
67 case Channel::BETA:
68 return "beta";
69 break;
70 case Channel::DEV:
71 return "dev";
72 break;
73 case Channel::CANARY:
74 return "canary";
75 break;
76 case Channel::UNKNOWN:
77 return "unknown";
78 break;
80 return std::string();
83 std::string GetVersionStringWithModifier(const std::string& modifier) {
84 std::string current_version;
85 current_version += GetVersionNumber();
86 #if !defined(GOOGLE_CHROME_BUILD)
87 current_version += " (";
88 current_version += l10n_util::GetStringUTF8(IDS_ABOUT_VERSION_UNOFFICIAL);
89 current_version += " ";
90 current_version += GetLastChange();
91 current_version += " ";
92 current_version += GetOSType();
93 current_version += ")";
94 #endif
95 if (!modifier.empty())
96 current_version += " " + modifier;
97 return current_version;
100 } // namespace version_info