[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 1 | // 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] | 1eeb5e0 | 2010-07-20 23:02:11 | [diff] [blame] | 5 | #include "chrome/common/chrome_version_info.h" |
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 6 | |
7 | #include "base/basictypes.h" | ||||
8 | #include "base/file_version_info.h" | ||||
[email protected] | 0211f57e | 2010-08-27 20:28:42 | [diff] [blame] | 9 | #include "base/string_util.h" |
[email protected] | 45446a5 | 2010-11-04 17:41:00 | [diff] [blame] | 10 | #include "base/thread_restrictions.h" |
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 11 | #include "build/build_config.h" |
12 | |||||
[email protected] | 1eeb5e0 | 2010-07-20 23:02:11 | [diff] [blame] | 13 | namespace chrome { |
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 14 | |
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 15 | #if defined(OS_WIN) || defined(OS_MACOSX) |
[email protected] | 0211f57e | 2010-08-27 20:28:42 | [diff] [blame] | 16 | // On Windows and Mac, we get the Chrome version info by querying |
17 | // FileVersionInfo for the current module. | ||||
18 | |||||
19 | VersionInfo::VersionInfo() { | ||||
[email protected] | 45446a5 | 2010-11-04 17:41:00 | [diff] [blame] | 20 | // The current module is already loaded in memory, so this will be cheap. |
21 | base::ThreadRestrictions::ScopedAllowIO allow_io; | ||||
[email protected] | 0211f57e | 2010-08-27 20:28:42 | [diff] [blame] | 22 | version_info_.reset(FileVersionInfo::CreateFileVersionInfoForCurrentModule()); |
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 23 | } |
24 | |||||
[email protected] | 0211f57e | 2010-08-27 20:28:42 | [diff] [blame] | 25 | VersionInfo::~VersionInfo() { |
26 | } | ||||
27 | |||||
28 | bool VersionInfo::is_valid() const { | ||||
29 | return version_info_.get() != NULL; | ||||
30 | } | ||||
31 | |||||
32 | std::string VersionInfo::Name() const { | ||||
33 | if (!is_valid()) | ||||
34 | return std::string(); | ||||
35 | return WideToASCII(version_info_->product_name()); | ||||
36 | } | ||||
37 | |||||
38 | std::string VersionInfo::Version() const { | ||||
39 | if (!is_valid()) | ||||
40 | return std::string(); | ||||
41 | return WideToASCII(version_info_->product_version()); | ||||
42 | } | ||||
43 | |||||
44 | std::string VersionInfo::LastChange() const { | ||||
45 | if (!is_valid()) | ||||
46 | return std::string(); | ||||
47 | return WideToASCII(version_info_->last_change()); | ||||
48 | } | ||||
49 | |||||
50 | bool 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 | |||||
62 | VersionInfo::VersionInfo() { | ||||
63 | } | ||||
64 | |||||
65 | VersionInfo::~VersionInfo() { | ||||
66 | } | ||||
67 | |||||
68 | bool VersionInfo::is_valid() const { | ||||
69 | return true; | ||||
70 | } | ||||
71 | |||||
72 | std::string VersionInfo::Name() const { | ||||
73 | return PRODUCT_NAME; | ||||
74 | } | ||||
75 | |||||
76 | std::string VersionInfo::Version() const { | ||||
77 | return PRODUCT_VERSION; | ||||
78 | } | ||||
79 | |||||
80 | std::string VersionInfo::LastChange() const { | ||||
81 | return LAST_CHANGE; | ||||
82 | } | ||||
83 | |||||
84 | bool VersionInfo::IsOfficialBuild() const { | ||||
85 | return OFFICIAL_BUILD; | ||||
86 | } | ||||
87 | |||||
88 | #endif | ||||
89 | |||||
[email protected] | 1eeb5e0 | 2010-07-20 23:02:11 | [diff] [blame] | 90 | } // namespace chrome |