Index: components/version_info/version_info.cc |
diff --git a/components/version_info/version_info.cc b/components/version_info/version_info.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..de3f5802210711a56f1864b95beb7ed5f8865f7e |
--- /dev/null |
+++ b/components/version_info/version_info.cc |
@@ -0,0 +1,100 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/version_info/version_info.h" |
+ |
+#include "build/build_config.h" |
+#include "components/version_info/version_info_values.h" |
+#include "grit/components_strings.h" |
+#include "ui/base/l10n/l10n_util.h" |
+ |
+namespace version_info { |
+ |
+std::string GetProductNameAndVersionForUserAgent() { |
+ return "Chrome/" + GetVersionNumber(); |
+} |
+ |
+std::string GetProductName() { |
+ return PRODUCT_NAME; |
+} |
+ |
+std::string GetVersionNumber() { |
+ return PRODUCT_VERSION; |
+} |
+ |
+std::string GetLastChange() { |
+ return LAST_CHANGE; |
+} |
+ |
+bool IsOfficialBuild() { |
+ return IS_OFFICIAL_BUILD; |
+} |
+ |
+std::string GetOSType() { |
+#if defined(OS_WIN) |
+ return "Windows"; |
+#elif defined(OS_IOS) |
+ return "iOS"; |
+#elif defined(OS_MACOSX) |
+ return "Mac OS X"; |
+#elif defined(OS_CHROMEOS) |
+# if defined(GOOGLE_CHROME_BUILD) |
+ return "Chrome OS"; |
+# else |
+ return "Chromium OS"; |
+# endif |
+#elif defined(OS_ANDROID) |
+ return "Android"; |
+#elif defined(OS_LINUX) |
+ return "Linux"; |
+#elif defined(OS_FREEBSD) |
+ return "FreeBSD"; |
+#elif defined(OS_OPENBSD) |
+ return "OpenBSD"; |
+#elif defined(OS_SOLARIS) |
+ return "Solaris"; |
+#else |
+ return "Unknown"; |
+#endif |
+} |
+ |
+std::string GetChannelString(Channel channel) { |
+ switch (channel) { |
+ case Channel::STABLE: |
+ return "stable"; |
+ break; |
+ case Channel::BETA: |
+ return "beta"; |
+ break; |
+ case Channel::DEV: |
+ return "dev"; |
+ break; |
+ case Channel::CANARY: |
+ return "canary"; |
+ break; |
+ case Channel::UNKNOWN: |
+ return "unknown"; |
+ break; |
+ } |
+ return std::string(); |
+} |
+ |
+std::string GetVersionStringWithModifier(const std::string& modifier) { |
+ std::string current_version; |
+ current_version += GetVersionNumber(); |
+#if !defined(GOOGLE_CHROME_BUILD) |
+ current_version += " ("; |
+ current_version += l10n_util::GetStringUTF8(IDS_ABOUT_VERSION_UNOFFICIAL); |
+ current_version += " "; |
+ current_version += GetLastChange(); |
+ current_version += " "; |
+ current_version += GetOSType(); |
+ current_version += ")"; |
+#endif |
+ if (!modifier.empty()) |
+ current_version += " " + modifier; |
+ return current_version; |
+} |
+ |
+} // namespace version_info |