[email protected] | 90509cb | 2011-03-25 18:46:38 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 4 | |
| 5 | #ifndef BASE_FILE_VERSION_INFO_H__ |
| 6 | #define BASE_FILE_VERSION_INFO_H__ |
| 7 | |
[email protected] | 70910be | 2011-04-22 23:55:45 | [diff] [blame] | 8 | #include "build/build_config.h" |
| 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 | |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 16 | #include <string> |
| 17 | |
[email protected] | 0bea725 | 2011-08-05 15:34:00 | [diff] [blame] | 18 | #include "base/base_export.h" |
[email protected] | 251cd6e5 | 2013-06-11 13:36:37 | [diff] [blame] | 19 | #include "base/strings/string16.h" |
[email protected] | 72c93c70 | 2008-08-05 20:00:26 | [diff] [blame] | 20 | |
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 21 | namespace base { |
[email protected] | f539333 | 2009-06-03 15:01:29 | [diff] [blame] | 22 | class FilePath; |
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 23 | } |
[email protected] | f539333 | 2009-06-03 15:01:29 | [diff] [blame] | 24 | |
[email protected] | 4f260d0 | 2010-12-23 18:35:42 | [diff] [blame] | 25 | // 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, |
| 27 | // 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. |
| 29 | // |
| 30 | // This list of properties is straight out of Win32's VerQueryValue |
| 31 | // <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 |
| 33 | // this a less-obvious Windows-ism. |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 34 | |
mgiuca | 8137fc2 | 2015-05-07 02:20:31 | [diff] [blame^] | 35 | class BASE_EXPORT FileVersionInfo { |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 36 | public: |
[email protected] | e462cf5 | 2010-05-21 23:00:17 | [diff] [blame] | 37 | virtual ~FileVersionInfo() {} |
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 38 | #if defined(OS_WIN) || defined(OS_MACOSX) |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 39 | // 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 |
| 41 | // returned object should be deleted when you are done with it. |
mgiuca | 8137fc2 | 2015-05-07 02:20:31 | [diff] [blame^] | 42 | static FileVersionInfo* CreateFileVersionInfo( |
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 43 | const base::FilePath& file_path); |
[email protected] | 7c1e303 | 2010-12-20 18:40:42 | [diff] [blame] | 44 | #endif // OS_WIN || OS_MACOSX |
| 45 | |
[email protected] | 70910be | 2011-04-22 23:55:45 | [diff] [blame] | 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. |
mgiuca | 8137fc2 | 2015-05-07 02:20:31 | [diff] [blame^] | 49 | static FileVersionInfo* CreateFileVersionInfoForModule(HMODULE module); |
[email protected] | 70910be | 2011-04-22 23:55:45 | [diff] [blame] | 50 | |
[email protected] | 1265917f | 2008-08-12 17:33:52 | [diff] [blame] | 51 | // Creates a FileVersionInfo for the current module. Returns NULL in case |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 52 | // of error. The returned object should be deleted when you are done with it. |
[email protected] | 70910be | 2011-04-22 23:55:45 | [diff] [blame] | 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. |
mgiuca | 8137fc2 | 2015-05-07 02:20:31 | [diff] [blame^] | 63 | static FileVersionInfo* CreateFileVersionInfoForCurrentModule(); |
[email protected] | 70910be | 2011-04-22 23:55:45 | [diff] [blame] | 64 | #endif // OS_WIN |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 65 | |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 66 | // Accessors to the different version properties. |
| 67 | // Returns an empty string if the property is not found. |
[email protected] | 476dafb | 2013-12-03 00:39:26 | [diff] [blame] | 68 | virtual base::string16 company_name() = 0; |
| 69 | virtual base::string16 company_short_name() = 0; |
| 70 | virtual base::string16 product_name() = 0; |
| 71 | virtual base::string16 product_short_name() = 0; |
| 72 | virtual base::string16 internal_name() = 0; |
| 73 | virtual base::string16 product_version() = 0; |
| 74 | virtual base::string16 private_build() = 0; |
| 75 | virtual base::string16 special_build() = 0; |
| 76 | virtual base::string16 comments() = 0; |
| 77 | virtual base::string16 original_filename() = 0; |
| 78 | virtual base::string16 file_description() = 0; |
| 79 | virtual base::string16 file_version() = 0; |
| 80 | virtual base::string16 legal_copyright() = 0; |
| 81 | virtual base::string16 legal_trademarks() = 0; |
| 82 | virtual base::string16 last_change() = 0; |
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 83 | virtual bool is_official_build() = 0; |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | #endif // BASE_FILE_VERSION_INFO_H__ |