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