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_WIN_H_ | 5 #ifndef BASE_FILE_VERSION_INFO_WIN_H_ |
6 #define BASE_FILE_VERSION_INFO_WIN_H_ | 6 #define BASE_FILE_VERSION_INFO_WIN_H_ |
7 | 7 |
| 8 #include <windows.h> |
| 9 |
| 10 #include <stdint.h> |
| 11 |
8 #include <memory> | 12 #include <memory> |
9 #include <string> | 13 #include <string> |
| 14 #include <vector> |
10 | 15 |
11 #include "base/base_export.h" | 16 #include "base/base_export.h" |
12 #include "base/file_version_info.h" | 17 #include "base/file_version_info.h" |
13 #include "base/macros.h" | 18 #include "base/macros.h" |
14 #include "base/memory/free_deleter.h" | |
15 | 19 |
16 struct tagVS_FIXEDFILEINFO; | 20 struct tagVS_FIXEDFILEINFO; |
17 typedef tagVS_FIXEDFILEINFO VS_FIXEDFILEINFO; | 21 typedef tagVS_FIXEDFILEINFO VS_FIXEDFILEINFO; |
18 | 22 |
19 class BASE_EXPORT FileVersionInfoWin : public FileVersionInfo { | 23 class BASE_EXPORT FileVersionInfoWin : public FileVersionInfo { |
20 public: | 24 public: |
21 FileVersionInfoWin(void* data, WORD language, WORD code_page); | |
22 ~FileVersionInfoWin() override; | 25 ~FileVersionInfoWin() override; |
23 | 26 |
24 // Accessors to the different version properties. | 27 // Accessors to the different version properties. |
25 // Returns an empty string if the property is not found. | 28 // Returns an empty string if the property is not found. |
26 base::string16 company_name() override; | 29 base::string16 company_name() override; |
27 base::string16 company_short_name() override; | 30 base::string16 company_short_name() override; |
28 base::string16 product_name() override; | 31 base::string16 product_name() override; |
29 base::string16 product_short_name() override; | 32 base::string16 product_short_name() override; |
30 base::string16 internal_name() override; | 33 base::string16 internal_name() override; |
31 base::string16 product_version() override; | 34 base::string16 product_version() override; |
32 base::string16 private_build() override; | 35 base::string16 private_build() override; |
33 base::string16 special_build() override; | 36 base::string16 special_build() override; |
34 base::string16 comments() override; | 37 base::string16 comments() override; |
35 base::string16 original_filename() override; | 38 base::string16 original_filename() override; |
36 base::string16 file_description() override; | 39 base::string16 file_description() override; |
37 base::string16 file_version() override; | 40 base::string16 file_version() override; |
38 base::string16 legal_copyright() override; | 41 base::string16 legal_copyright() override; |
39 base::string16 legal_trademarks() override; | 42 base::string16 legal_trademarks() override; |
40 base::string16 last_change() override; | 43 base::string16 last_change() override; |
41 bool is_official_build() override; | 44 bool is_official_build() override; |
42 | 45 |
43 // Lets you access other properties not covered above. | 46 // Lets you access other properties not covered above. |
44 bool GetValue(const wchar_t* name, std::wstring* value); | 47 bool GetValue(const wchar_t* name, std::wstring* value); |
45 | 48 |
46 // Similar to GetValue but returns a wstring (empty string if the property | 49 // Similar to GetValue but returns a wstring (empty string if the property |
47 // does not exist). | 50 // does not exist). |
48 std::wstring GetStringValue(const wchar_t* name); | 51 std::wstring GetStringValue(const wchar_t* name); |
49 | 52 |
50 // Get the fixed file info if it exists. Otherwise NULL | 53 // Get the fixed file info if it exists. Otherwise NULL |
51 VS_FIXEDFILEINFO* fixed_file_info() { return fixed_file_info_; } | 54 const VS_FIXEDFILEINFO* fixed_file_info() const { return fixed_file_info_; } |
52 | 55 |
53 private: | 56 private: |
54 std::unique_ptr<char, base::FreeDeleter> data_; | 57 friend FileVersionInfo; |
55 WORD language_; | 58 |
56 WORD code_page_; | 59 // |data| is a VS_VERSION_INFO resource. |language| and |code_page| are |
57 // This is a pointer into the data_ if it exists. Otherwise NULL. | 60 // extracted from the \VarFileInfo\Translation value of |data|. |
58 VS_FIXEDFILEINFO* fixed_file_info_; | 61 FileVersionInfoWin(std::vector<uint8_t>&& data, |
| 62 WORD language, |
| 63 WORD code_page); |
| 64 FileVersionInfoWin(void* data, WORD language, WORD code_page); |
| 65 |
| 66 const std::vector<uint8_t> owned_data_; |
| 67 const void* const data_; |
| 68 const WORD language_; |
| 69 const WORD code_page_; |
| 70 |
| 71 // This is a pointer into |data_| if it exists. Otherwise nullptr. |
| 72 const VS_FIXEDFILEINFO* const fixed_file_info_; |
59 | 73 |
60 DISALLOW_COPY_AND_ASSIGN(FileVersionInfoWin); | 74 DISALLOW_COPY_AND_ASSIGN(FileVersionInfoWin); |
61 }; | 75 }; |
62 | 76 |
63 #endif // BASE_FILE_VERSION_INFO_WIN_H_ | 77 #endif // BASE_FILE_VERSION_INFO_WIN_H_ |
OLD | NEW |