michael@0: // Copyright (c) 2011 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #ifndef BASE_FILE_VERSION_INFO_H__ michael@0: #define BASE_FILE_VERSION_INFO_H__ michael@0: michael@0: #include "build/build_config.h" michael@0: michael@0: #if defined(OS_WIN) michael@0: #include michael@0: // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx michael@0: extern "C" IMAGE_DOS_HEADER __ImageBase; michael@0: #endif // OS_WIN michael@0: michael@0: #include michael@0: michael@0: #include "base/base_export.h" michael@0: #include "base/strings/string16.h" michael@0: michael@0: namespace base { michael@0: class FilePath; michael@0: } michael@0: michael@0: // Provides an interface for accessing the version information for a file. This michael@0: // is the information you access when you select a file in the Windows Explorer, michael@0: // right-click select Properties, then click the Version tab, and on the Mac michael@0: // when you select a file in the Finder and do a Get Info. michael@0: // michael@0: // This list of properties is straight out of Win32's VerQueryValue michael@0: // and the Mac michael@0: // version returns values from the Info.plist as appropriate. TODO(avi): make michael@0: // this a less-obvious Windows-ism. michael@0: michael@0: class FileVersionInfo { michael@0: public: michael@0: virtual ~FileVersionInfo() {} michael@0: #if defined(OS_WIN) || defined(OS_MACOSX) michael@0: // Creates a FileVersionInfo for the specified path. Returns NULL if something michael@0: // goes wrong (typically the file does not exit or cannot be opened). The michael@0: // returned object should be deleted when you are done with it. michael@0: BASE_EXPORT static FileVersionInfo* CreateFileVersionInfo( michael@0: const base::FilePath& file_path); michael@0: #endif // OS_WIN || OS_MACOSX michael@0: michael@0: #if defined(OS_WIN) michael@0: // Creates a FileVersionInfo for the specified module. Returns NULL in case michael@0: // of error. The returned object should be deleted when you are done with it. michael@0: BASE_EXPORT static FileVersionInfo* CreateFileVersionInfoForModule( michael@0: HMODULE module); michael@0: michael@0: // Creates a FileVersionInfo for the current module. Returns NULL in case michael@0: // of error. The returned object should be deleted when you are done with it. michael@0: // This function should be inlined so that the "current module" is evaluated michael@0: // correctly, instead of being the module that contains base. michael@0: __forceinline static FileVersionInfo* michael@0: CreateFileVersionInfoForCurrentModule() { michael@0: HMODULE module = reinterpret_cast(&__ImageBase); michael@0: return CreateFileVersionInfoForModule(module); michael@0: } michael@0: #else michael@0: // Creates a FileVersionInfo for the current module. Returns NULL in case michael@0: // of error. The returned object should be deleted when you are done with it. michael@0: BASE_EXPORT static FileVersionInfo* CreateFileVersionInfoForCurrentModule(); michael@0: #endif // OS_WIN michael@0: michael@0: // Accessors to the different version properties. michael@0: // Returns an empty string if the property is not found. michael@0: virtual string16 company_name() = 0; michael@0: virtual string16 company_short_name() = 0; michael@0: virtual string16 product_name() = 0; michael@0: virtual string16 product_short_name() = 0; michael@0: virtual string16 internal_name() = 0; michael@0: virtual string16 product_version() = 0; michael@0: virtual string16 private_build() = 0; michael@0: virtual string16 special_build() = 0; michael@0: virtual string16 comments() = 0; michael@0: virtual string16 original_filename() = 0; michael@0: virtual string16 file_description() = 0; michael@0: virtual string16 file_version() = 0; michael@0: virtual string16 legal_copyright() = 0; michael@0: virtual string16 legal_trademarks() = 0; michael@0: virtual string16 last_change() = 0; michael@0: virtual bool is_official_build() = 0; michael@0: }; michael@0: michael@0: #endif // BASE_FILE_VERSION_INFO_H__