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