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