blob: 5157c4a4e3a81c6790b4974e33977a4393f9cacf [file] [log] [blame]
[email protected]bcff05a2010-04-14 01:46:431// Copyright (c) 2010 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.
4
[email protected]1eeb5e02010-07-20 23:02:115#include "chrome/common/chrome_version_info.h"
[email protected]bcff05a2010-04-14 01:46:436
7#include "base/basictypes.h"
8#include "base/file_version_info.h"
[email protected]0211f57e2010-08-27 20:28:429#include "base/string_util.h"
[email protected]45446a52010-11-04 17:41:0010#include "base/thread_restrictions.h"
[email protected]bcff05a2010-04-14 01:46:4311#include "build/build_config.h"
12
[email protected]1eeb5e02010-07-20 23:02:1113namespace chrome {
[email protected]bcff05a2010-04-14 01:46:4314
[email protected]bcff05a2010-04-14 01:46:4315#if defined(OS_WIN) || defined(OS_MACOSX)
[email protected]0211f57e2010-08-27 20:28:4216// On Windows and Mac, we get the Chrome version info by querying
17// FileVersionInfo for the current module.
18
19VersionInfo::VersionInfo() {
[email protected]45446a52010-11-04 17:41:0020 // The current module is already loaded in memory, so this will be cheap.
21 base::ThreadRestrictions::ScopedAllowIO allow_io;
[email protected]0211f57e2010-08-27 20:28:4222 version_info_.reset(FileVersionInfo::CreateFileVersionInfoForCurrentModule());
[email protected]bcff05a2010-04-14 01:46:4323}
24
[email protected]0211f57e2010-08-27 20:28:4225VersionInfo::~VersionInfo() {
26}
27
28bool VersionInfo::is_valid() const {
29 return version_info_.get() != NULL;
30}
31
32std::string VersionInfo::Name() const {
33 if (!is_valid())
34 return std::string();
35 return WideToASCII(version_info_->product_name());
36}
37
38std::string VersionInfo::Version() const {
39 if (!is_valid())
40 return std::string();
41 return WideToASCII(version_info_->product_version());
42}
43
44std::string VersionInfo::LastChange() const {
45 if (!is_valid())
46 return std::string();
47 return WideToASCII(version_info_->last_change());
48}
49
50bool VersionInfo::IsOfficialBuild() const {
51 if (!is_valid())
52 return false;
53 return version_info_->is_official_build();
54}
55
56#elif defined(OS_POSIX)
57// We get chrome version information from chrome_version_info_posix.h,
58// a generated header.
59
60#include "chrome/common/chrome_version_info_posix.h"
61
62VersionInfo::VersionInfo() {
63}
64
65VersionInfo::~VersionInfo() {
66}
67
68bool VersionInfo::is_valid() const {
69 return true;
70}
71
72std::string VersionInfo::Name() const {
73 return PRODUCT_NAME;
74}
75
76std::string VersionInfo::Version() const {
77 return PRODUCT_VERSION;
78}
79
80std::string VersionInfo::LastChange() const {
81 return LAST_CHANGE;
82}
83
84bool VersionInfo::IsOfficialBuild() const {
85 return OFFICIAL_BUILD;
86}
87
88#endif
89
[email protected]1eeb5e02010-07-20 23:02:1190} // namespace chrome