OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef BASE_FILE_VERSION_INFO_H_ | 5 #ifndef BASE_FILE_VERSION_INFO_H_ |
6 #define BASE_FILE_VERSION_INFO_H_ | 6 #define BASE_FILE_VERSION_INFO_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #if defined(OS_WIN) | |
11 #include <windows.h> | |
12 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx | |
13 extern "C" IMAGE_DOS_HEADER __ImageBase; | |
14 #endif // OS_WIN | |
15 | |
16 #include <string> | 10 #include <string> |
17 | 11 |
18 #include "base/base_export.h" | 12 #include "base/base_export.h" |
19 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
20 | 14 |
21 namespace base { | 15 namespace base { |
22 class FilePath; | 16 class FilePath; |
23 } | 17 } |
24 | 18 |
25 // Provides an interface for accessing the version information for a file. This | 19 // Provides an interface for accessing the version information for a file. This |
26 // is the information you access when you select a file in the Windows Explorer, | 20 // is the information you access when you select a file in the Windows Explorer, |
27 // right-click select Properties, then click the Version tab, and on the Mac | 21 // right-click select Properties, then click the Version tab, and on the Mac |
28 // when you select a file in the Finder and do a Get Info. | 22 // when you select a file in the Finder and do a Get Info. |
29 // | 23 // |
30 // This list of properties is straight out of Win32's VerQueryValue | 24 // This list of properties is straight out of Win32's VerQueryValue |
31 // <http://msdn.microsoft.com/en-us/library/ms647464.aspx> and the Mac | 25 // <http://msdn.microsoft.com/en-us/library/ms647464.aspx> and the Mac |
32 // version returns values from the Info.plist as appropriate. TODO(avi): make | 26 // version returns values from the Info.plist as appropriate. TODO(avi): make |
33 // this a less-obvious Windows-ism. | 27 // this a less-obvious Windows-ism. |
34 | 28 |
35 class BASE_EXPORT FileVersionInfo { | 29 class BASE_EXPORT FileVersionInfo { |
36 public: | 30 public: |
37 virtual ~FileVersionInfo() {} | 31 virtual ~FileVersionInfo() {} |
38 #if defined(OS_WIN) || defined(OS_MACOSX) | 32 #if defined(OS_MACOSX) |
39 // Creates a FileVersionInfo for the specified path. Returns NULL if something | 33 // Creates a FileVersionInfo for the specified path. Returns NULL if something |
40 // goes wrong (typically the file does not exit or cannot be opened). The | 34 // goes wrong (typically the file does not exit or cannot be opened). The |
41 // returned object should be deleted when you are done with it. | 35 // returned object should be deleted when you are done with it. |
42 static FileVersionInfo* CreateFileVersionInfo( | 36 static FileVersionInfo* CreateFileVersionInfo( |
43 const base::FilePath& file_path); | 37 const base::FilePath& file_path); |
44 #endif // OS_WIN || OS_MACOSX | 38 #endif // OS_MACOSX |
45 | |
46 #if defined(OS_WIN) | |
47 // Creates a FileVersionInfo for the specified module. Returns NULL in case | |
48 // of error. The returned object should be deleted when you are done with it. | |
49 static FileVersionInfo* CreateFileVersionInfoForModule(HMODULE module); | |
50 | 39 |
51 // Creates a FileVersionInfo for the current module. Returns NULL in case | 40 // Creates a FileVersionInfo for the current module. Returns NULL in case |
52 // of error. The returned object should be deleted when you are done with it. | 41 // of error. The returned object should be deleted when you are done with it. |
53 // This function should be inlined so that the "current module" is evaluated | |
54 // correctly, instead of being the module that contains base. | |
55 __forceinline static FileVersionInfo* | |
56 CreateFileVersionInfoForCurrentModule() { | |
57 HMODULE module = reinterpret_cast<HMODULE>(&__ImageBase); | |
58 return CreateFileVersionInfoForModule(module); | |
59 } | |
60 #else | |
61 // Creates a FileVersionInfo for the current module. Returns NULL in case | |
62 // of error. The returned object should be deleted when you are done with it. | |
63 static FileVersionInfo* CreateFileVersionInfoForCurrentModule(); | 42 static FileVersionInfo* CreateFileVersionInfoForCurrentModule(); |
64 #endif // OS_WIN | |
65 | 43 |
66 // Accessors to the different version properties. | 44 // Accessors to the different version properties. |
67 // Returns an empty string if the property is not found. | 45 // Returns an empty string if the property is not found. |
68 virtual base::string16 company_name() = 0; | 46 virtual base::string16 company_name() = 0; |
69 virtual base::string16 company_short_name() = 0; | 47 virtual base::string16 company_short_name() = 0; |
70 virtual base::string16 product_name() = 0; | 48 virtual base::string16 product_name() = 0; |
71 virtual base::string16 product_short_name() = 0; | 49 virtual base::string16 product_short_name() = 0; |
72 virtual base::string16 internal_name() = 0; | 50 virtual base::string16 internal_name() = 0; |
73 virtual base::string16 product_version() = 0; | 51 virtual base::string16 product_version() = 0; |
74 virtual base::string16 private_build() = 0; | 52 virtual base::string16 private_build() = 0; |
75 virtual base::string16 special_build() = 0; | 53 virtual base::string16 special_build() = 0; |
76 virtual base::string16 comments() = 0; | 54 virtual base::string16 comments() = 0; |
77 virtual base::string16 original_filename() = 0; | 55 virtual base::string16 original_filename() = 0; |
78 virtual base::string16 file_description() = 0; | 56 virtual base::string16 file_description() = 0; |
79 virtual base::string16 file_version() = 0; | 57 virtual base::string16 file_version() = 0; |
80 virtual base::string16 legal_copyright() = 0; | 58 virtual base::string16 legal_copyright() = 0; |
81 virtual base::string16 legal_trademarks() = 0; | 59 virtual base::string16 legal_trademarks() = 0; |
82 virtual base::string16 last_change() = 0; | 60 virtual base::string16 last_change() = 0; |
83 virtual bool is_official_build() = 0; | 61 virtual bool is_official_build() = 0; |
84 }; | 62 }; |
85 | 63 |
86 #endif // BASE_FILE_VERSION_INFO_H_ | 64 #endif // BASE_FILE_VERSION_INFO_H_ |
OLD | NEW |