summaryrefslogtreecommitdiffstats
path: root/chrome/common/chrome_version_info.cc
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 20:28:42 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 20:28:42 +0000
commit0211f57eabdc1a3e34aee1e1629c26e93b803ded (patch)
tree3bcbab3506e5f3dbcbc99825529cc803d223b017 /chrome/common/chrome_version_info.cc
parent1f8322043d302eb0f6a050a21d2f0f9a8c1df71e (diff)
downloadchromium_src-0211f57eabdc1a3e34aee1e1629c26e93b803ded.zip
chromium_src-0211f57eabdc1a3e34aee1e1629c26e93b803ded.tar.gz
chromium_src-0211f57eabdc1a3e34aee1e1629c26e93b803ded.tar.bz2
Refactor version-getting info into a chrome::VersionInfo object.
I was trying to replace wstring usage in base::FileVersionInfo, but that class is rather Windows-specific with strange fields like "private_build()" where the value and encoding aren't clear. 95% of the users of FileVersionInfo actually just care about the current Chrome version, so we can provide a much simpler interface for them. We still use FileVersionInfo for retrieving information from e.g. plugin DLLs, but in those cases the usage is clearer. Review URL: http://codereview.chromium.org/3135028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57725 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/chrome_version_info.cc')
-rw-r--r--chrome/common/chrome_version_info.cc105
1 files changed, 70 insertions, 35 deletions
diff --git a/chrome/common/chrome_version_info.cc b/chrome/common/chrome_version_info.cc
index 1b1d479..a26f81f 100644
--- a/chrome/common/chrome_version_info.cc
+++ b/chrome/common/chrome_version_info.cc
@@ -6,47 +6,82 @@
#include "base/basictypes.h"
#include "base/file_version_info.h"
+#include "base/string_util.h"
#include "build/build_config.h"
-#if defined(OS_POSIX) && !defined(OS_MACOSX)
-#include "chrome/common/chrome_version_info_posix.h"
-
-// Posix files don't have per-file version information, so we get chrome
-// version information from chrome_version_info_posix.h, a generated header.
-class ChromeVersionInfoPosix : public FileVersionInfo {
- public:
- ChromeVersionInfoPosix() {}
-
- virtual std::wstring company_name() { return COMPANY_NAME; }
- virtual std::wstring company_short_name() { return COMPANY_SHORT_NAME; }
- virtual std::wstring product_name() { return PRODUCT_NAME; }
- virtual std::wstring product_short_name() { return PRODUCT_SHORT_NAME; }
- virtual std::wstring internal_name() { return INTERNAL_NAME; }
- virtual std::wstring product_version() { return PRODUCT_VERSION; }
- virtual std::wstring private_build() { return PRIVATE_BUILD; }
- virtual std::wstring special_build() { return SPECIAL_BUILD; }
- virtual std::wstring comments() { return COMMENTS; }
- virtual std::wstring original_filename() { return ORIGINAL_FILENAME; }
- virtual std::wstring file_description() { return FILE_DESCRIPTION; }
- virtual std::wstring file_version() { return FILE_VERSION; }
- virtual std::wstring legal_copyright() { return LEGAL_COPYRIGHT; }
- virtual std::wstring legal_trademarks() { return LEGAL_TRADEMARKS; }
- virtual std::wstring last_change() { return LAST_CHANGE; }
- virtual bool is_official_build() { return OFFICIAL_BUILD; }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ChromeVersionInfoPosix);
-};
-#endif
-
namespace chrome {
-FileVersionInfo* GetChromeVersionInfo() {
#if defined(OS_WIN) || defined(OS_MACOSX)
- return FileVersionInfo::CreateFileVersionInfoForCurrentModule();
+// On Windows and Mac, we get the Chrome version info by querying
+// FileVersionInfo for the current module.
+
+VersionInfo::VersionInfo() {
+ version_info_.reset(FileVersionInfo::CreateFileVersionInfoForCurrentModule());
+}
+
+VersionInfo::~VersionInfo() {
+}
+
+bool VersionInfo::is_valid() const {
+ return version_info_.get() != NULL;
+}
+
+std::string VersionInfo::Name() const {
+ if (!is_valid())
+ return std::string();
+ return WideToASCII(version_info_->product_name());
+}
+
+std::string VersionInfo::Version() const {
+ if (!is_valid())
+ return std::string();
+ return WideToASCII(version_info_->product_version());
+}
+
+std::string VersionInfo::LastChange() const {
+ if (!is_valid())
+ return std::string();
+ return WideToASCII(version_info_->last_change());
+}
+
+bool VersionInfo::IsOfficialBuild() const {
+ if (!is_valid())
+ return false;
+ return version_info_->is_official_build();
+}
+
#elif defined(OS_POSIX)
- return new ChromeVersionInfoPosix();
-#endif
+// We get chrome version information from chrome_version_info_posix.h,
+// a generated header.
+
+#include "chrome/common/chrome_version_info_posix.h"
+
+VersionInfo::VersionInfo() {
+}
+
+VersionInfo::~VersionInfo() {
+}
+
+bool VersionInfo::is_valid() const {
+ return true;
+}
+
+std::string VersionInfo::Name() const {
+ return PRODUCT_NAME;
+}
+
+std::string VersionInfo::Version() const {
+ return PRODUCT_VERSION;
+}
+
+std::string VersionInfo::LastChange() const {
+ return LAST_CHANGE;
}
+bool VersionInfo::IsOfficialBuild() const {
+ return OFFICIAL_BUILD;
+}
+
+#endif
+
} // namespace chrome