Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(613)

Side by Side Diff: chrome/common/chrome_version_info.cc

Issue 5815001: Fixed file_version_info so that it finds Mac values correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed logging to vlog Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/chrome_version_info.h" 5 #include "chrome/common/chrome_version_info.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/file_version_info.h" 8 #include "base/file_version_info.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/thread_restrictions.h" 10 #include "base/thread_restrictions.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "chrome/common/chrome_constants.h"
12 13
13 namespace chrome { 14 namespace chrome {
14 15
15 #if defined(OS_WIN) || defined(OS_MACOSX) 16 #if defined(OS_WIN) || defined(OS_MACOSX)
16 // On Windows and Mac, we get the Chrome version info by querying 17 // On Windows and Mac we get the Chrome version info by querying FileVersionInfo
17 // FileVersionInfo for the current module. 18 // for the current module if it is available, otherwise we fall back to coded
19 // values.
18 20
19 VersionInfo::VersionInfo() { 21 VersionInfo::VersionInfo() {
20 // The current module is already loaded in memory, so this will be cheap. 22 // The current module is already loaded in memory, so this will be cheap.
21 base::ThreadRestrictions::ScopedAllowIO allow_io; 23 base::ThreadRestrictions::ScopedAllowIO allow_io;
22 version_info_.reset(FileVersionInfo::CreateFileVersionInfoForCurrentModule()); 24 version_info_.reset(FileVersionInfo::CreateFileVersionInfoForCurrentModule());
23 } 25 }
24 26
25 VersionInfo::~VersionInfo() { 27 VersionInfo::~VersionInfo() {
26 } 28 }
27 29
28 bool VersionInfo::is_valid() const {
29 return version_info_.get() != NULL;
30 }
31
32 std::string VersionInfo::Name() const { 30 std::string VersionInfo::Name() const {
33 if (!is_valid()) 31 std::wstring name =
34 return std::string(); 32 version_info_.get() ? version_info_->product_name()
35 return WideToASCII(version_info_->product_name()); 33 : kBrowserProcessExecutableName;
34 return WideToASCII(name);
36 } 35 }
37 36
38 std::string VersionInfo::Version() const { 37 std::string VersionInfo::Version() const {
39 if (!is_valid()) 38 if (!version_info_.get())
40 return std::string(); 39 return kChromeVersion;
Erik does not do reviews 2010/12/14 19:16:32 I think you've lost me here. What are we trying t
41 return WideToASCII(version_info_->product_version()); 40 return WideToASCII(version_info_->product_version());
42 } 41 }
43 42
44 std::string VersionInfo::LastChange() const { 43 std::string VersionInfo::LastChange() const {
45 if (!is_valid()) 44 if (!version_info_.get())
46 return std::string(); 45 return "0";
47 return WideToASCII(version_info_->last_change()); 46 return WideToASCII(version_info_->last_change());
48 } 47 }
49 48
50 bool VersionInfo::IsOfficialBuild() const { 49 bool VersionInfo::IsOfficialBuild() const {
51 if (!is_valid()) 50 if (!version_info_.get())
52 return false; 51 return false;
53 return version_info_->is_official_build(); 52 return version_info_->is_official_build();
54 } 53 }
55 54
56 #elif defined(OS_POSIX) 55 #elif defined(OS_POSIX)
57 // We get chrome version information from chrome_version_info_posix.h, 56 // We get chrome version information from chrome_version_info_posix.h,
58 // a generated header. 57 // a generated header.
59 58
60 #include "chrome/common/chrome_version_info_posix.h" 59 #include "chrome/common/chrome_version_info_posix.h"
61 60
62 VersionInfo::VersionInfo() { 61 VersionInfo::VersionInfo() {
63 } 62 }
64 63
65 VersionInfo::~VersionInfo() { 64 VersionInfo::~VersionInfo() {
66 } 65 }
67 66
68 bool VersionInfo::is_valid() const {
69 return true;
70 }
71
72 std::string VersionInfo::Name() const { 67 std::string VersionInfo::Name() const {
73 return PRODUCT_NAME; 68 return PRODUCT_NAME;
74 } 69 }
75 70
76 std::string VersionInfo::Version() const { 71 std::string VersionInfo::Version() const {
77 return PRODUCT_VERSION; 72 return PRODUCT_VERSION;
78 } 73 }
79 74
80 std::string VersionInfo::LastChange() const { 75 std::string VersionInfo::LastChange() const {
81 return LAST_CHANGE; 76 return LAST_CHANGE;
82 } 77 }
83 78
84 bool VersionInfo::IsOfficialBuild() const { 79 bool VersionInfo::IsOfficialBuild() const {
85 return OFFICIAL_BUILD; 80 return OFFICIAL_BUILD;
86 } 81 }
87 82
88 #endif 83 #endif
89 84
90 } // namespace chrome 85 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698