Remove media files used with tough_video_cases in favor of uploading them to google...
[chromium-blink-merge.git] / chrome / common / chrome_version_info.cc
blob7671a3d4d1d9dbad93e0e7a7f12450becbdcc250
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/strings/utf_string_conversions.h"
10 #include "base/threading/thread_restrictions.h"
11 #include "build/build_config.h"
12 #include "grit/chromium_strings.h"
13 #include "grit/generated_resources.h"
14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/resource/resource_bundle.h"
17 namespace chrome {
19 std::string VersionInfo::ProductNameAndVersionForUserAgent() const {
20 if (!is_valid())
21 return std::string();
22 return "Chrome/" + Version();
25 #if defined(OS_WIN) || defined(OS_MACOSX)
26 // On Windows and Mac, we get the Chrome version info by querying
27 // FileVersionInfo for the current module.
29 VersionInfo::VersionInfo() {
30 // The current module is already loaded in memory, so this will be cheap.
31 base::ThreadRestrictions::ScopedAllowIO allow_io;
32 version_info_.reset(FileVersionInfo::CreateFileVersionInfoForCurrentModule());
35 VersionInfo::~VersionInfo() {
38 bool VersionInfo::is_valid() const {
39 return version_info_.get() != NULL;
42 std::string VersionInfo::Name() const {
43 if (!is_valid())
44 return std::string();
45 return UTF16ToUTF8(version_info_->product_name());
48 std::string VersionInfo::Version() const {
49 if (!is_valid())
50 return std::string();
51 return UTF16ToUTF8(version_info_->product_version());
54 std::string VersionInfo::LastChange() const {
55 if (!is_valid())
56 return std::string();
57 return UTF16ToUTF8(version_info_->last_change());
60 bool VersionInfo::IsOfficialBuild() const {
61 if (!is_valid())
62 return false;
63 return version_info_->is_official_build();
66 #elif defined(OS_POSIX)
67 // We get chrome version information from chrome_version_info_posix.h,
68 // a generated header.
70 #include "chrome/common/chrome_version_info_posix.h"
72 VersionInfo::VersionInfo() {
75 VersionInfo::~VersionInfo() {
78 bool VersionInfo::is_valid() const {
79 return true;
82 std::string VersionInfo::Name() const {
83 return PRODUCT_NAME;
86 std::string VersionInfo::Version() const {
87 return PRODUCT_VERSION;
90 std::string VersionInfo::LastChange() const {
91 return LAST_CHANGE;
94 bool VersionInfo::IsOfficialBuild() const {
95 return IS_OFFICIAL_BUILD;
98 #endif
100 std::string VersionInfo::CreateVersionString() const {
101 std::string current_version;
102 if (is_valid()) {
103 current_version += Version();
104 #if !defined(GOOGLE_CHROME_BUILD)
105 current_version += " (";
106 current_version += l10n_util::GetStringUTF8(IDS_ABOUT_VERSION_UNOFFICIAL);
107 current_version += " ";
108 current_version += LastChange();
109 current_version += " ";
110 current_version += OSType();
111 current_version += ")";
112 #endif
113 std::string modifier = GetVersionStringModifier();
114 if (!modifier.empty())
115 current_version += " " + modifier;
117 return current_version;
120 std::string VersionInfo::OSType() const {
121 #if defined(OS_WIN)
122 return "Windows";
123 #elif defined(OS_MACOSX)
124 return "Mac OS X";
125 #elif defined(OS_CHROMEOS)
126 #if defined(GOOGLE_CHROME_BUILD)
127 return "Chrome OS";
128 #else
129 return "Chromium OS";
130 #endif
131 #elif defined(OS_ANDROID)
132 return "Android";
133 #elif defined(OS_LINUX)
134 return "Linux";
135 #elif defined(OS_FREEBSD)
136 return "FreeBSD";
137 #elif defined(OS_OPENBSD)
138 return "OpenBSD";
139 #elif defined(OS_SOLARIS)
140 return "Solaris";
141 #else
142 return "Unknown";
143 #endif
146 } // namespace chrome