| 6 | #define BASE_FILE_VERSION_INFO_H_ |
| 7 |
| 8 | #include <memory> |
| 9 | #include <string> |
| 10 |
| 11 | #include "build/build_config.h" |
| 12 | #include "base/base_export.h" |
| 13 | #include "base/strings/string16.h" |
| 14 |
| 15 | #if defined(OS_WIN) |
| 16 | #include <windows.h> |
| 17 | #endif |
| 18 |
| 19 | namespace base { |
| 20 | class FilePath; |
| 21 | } |
| 22 |
| 23 | // Provides an interface for accessing the version information for a file. This |
| 24 | // is the information you access when you select a file in the Windows Explorer, |
| 25 | // right-click select Properties, then click the Version tab, and on the Mac |
| 26 | // when you select a file in the Finder and do a Get Info. |
| 27 | // |
| 28 | // This list of properties is straight out of Win32's VerQueryValue |
| 29 | // <http://msdn.microsoft.com/en-us/library/ms647464.aspx> and the Mac |
| 30 | // version returns values from the Info.plist as appropriate. TODO(avi): make |
| 31 | // this a less-obvious Windows-ism. |
| 32 |
| 33 | class BASE_EXPORT FileVersionInfo { |
| 34 | public: |
| 35 | virtual ~FileVersionInfo() {} |
| 36 | #if defined(OS_WIN) || defined(OS_MACOSX) |
| 37 | // Creates a FileVersionInfo for the specified path. Returns nullptr if |
| 38 | // something goes wrong (typically the file does not exit or cannot be |
| 39 | // opened). |
| 40 | static std::unique_ptr<FileVersionInfo> CreateFileVersionInfo( |
| 41 | const base::FilePath& file_path); |
| 42 | #endif // OS_WIN || OS_MACOSX |
| 43 |
| 44 | #if defined(OS_WIN) |
| 45 | // Creates a FileVersionInfo for the specified module. Returns nullptr in |
| 46 | // case of error. |
| 47 | static std::unique_ptr<FileVersionInfo> CreateFileVersionInfoForModule( |
| 48 | HMODULE module); |
| 49 | #else |
| 50 | // Creates a FileVersionInfo for the current module. Returns nullptr in case |
| 51 | // of error. |
| 52 | static std::unique_ptr<FileVersionInfo> |
| 53 | CreateFileVersionInfoForCurrentModule(); |
| 54 | #endif // OS_WIN |
| 55 |
| 56 | // Accessors to the different version properties. |
| 57 | // Returns an empty string if the property is not found. |
| 58 | virtual base::string16 company_name() = 0; |
| 59 | virtual base::string16 company_short_name() = 0; |
| 60 | virtual base::string16 product_name() = 0; |
| 61 | virtual base::string16 product_short_name() = 0; |
| 62 | virtual base::string16 internal_name() = 0; |
| 63 | virtual base::string16 product_version() = 0; |
| 64 | virtual base::string16 special_build() = 0; |
| 65 | virtual base::string16 original_filename() = 0; |
| 66 | virtual base::string16 file_description() = 0; |
| 67 | virtual base::string16 file_version() = 0; |
| 68 | }; |
| 69 |
| 70 | #endif // BASE_FILE_VERSION_INFO_H_ |
| 71 |