| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "base/file_version_info_win.h" | 5 #include "base/file_version_info_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_version_info.h" | 10 #include "base/file_version_info.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 if (query_result && translate) { | 70 if (query_result && translate) { |
| 71 return new FileVersionInfoWin(data, translate->language, | 71 return new FileVersionInfoWin(data, translate->language, |
| 72 translate->code_page); | 72 translate->code_page); |
| 73 | 73 |
| 74 } else { | 74 } else { |
| 75 free(data); | 75 free(data); |
| 76 return NULL; | 76 return NULL; |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 // static | 80 string16 FileVersionInfoWin::company_name() { |
| 81 FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( | |
| 82 const std::wstring& file_path) { | |
| 83 FilePath file_path_fp = FilePath::FromWStringHack(file_path); | |
| 84 return CreateFileVersionInfo(file_path_fp); | |
| 85 } | |
| 86 | |
| 87 std::wstring FileVersionInfoWin::company_name() { | |
| 88 return GetStringValue(L"CompanyName"); | 81 return GetStringValue(L"CompanyName"); |
| 89 } | 82 } |
| 90 | 83 |
| 91 std::wstring FileVersionInfoWin::company_short_name() { | 84 string16 FileVersionInfoWin::company_short_name() { |
| 92 return GetStringValue(L"CompanyShortName"); | 85 return GetStringValue(L"CompanyShortName"); |
| 93 } | 86 } |
| 94 | 87 |
| 95 std::wstring FileVersionInfoWin::internal_name() { | 88 string16 FileVersionInfoWin::internal_name() { |
| 96 return GetStringValue(L"InternalName"); | 89 return GetStringValue(L"InternalName"); |
| 97 } | 90 } |
| 98 | 91 |
| 99 std::wstring FileVersionInfoWin::product_name() { | 92 string16 FileVersionInfoWin::product_name() { |
| 100 return GetStringValue(L"ProductName"); | 93 return GetStringValue(L"ProductName"); |
| 101 } | 94 } |
| 102 | 95 |
| 103 std::wstring FileVersionInfoWin::product_short_name() { | 96 string16 FileVersionInfoWin::product_short_name() { |
| 104 return GetStringValue(L"ProductShortName"); | 97 return GetStringValue(L"ProductShortName"); |
| 105 } | 98 } |
| 106 | 99 |
| 107 std::wstring FileVersionInfoWin::comments() { | 100 string16 FileVersionInfoWin::comments() { |
| 108 return GetStringValue(L"Comments"); | 101 return GetStringValue(L"Comments"); |
| 109 } | 102 } |
| 110 | 103 |
| 111 std::wstring FileVersionInfoWin::legal_copyright() { | 104 string16 FileVersionInfoWin::legal_copyright() { |
| 112 return GetStringValue(L"LegalCopyright"); | 105 return GetStringValue(L"LegalCopyright"); |
| 113 } | 106 } |
| 114 | 107 |
| 115 std::wstring FileVersionInfoWin::product_version() { | 108 string16 FileVersionInfoWin::product_version() { |
| 116 return GetStringValue(L"ProductVersion"); | 109 return GetStringValue(L"ProductVersion"); |
| 117 } | 110 } |
| 118 | 111 |
| 119 std::wstring FileVersionInfoWin::file_description() { | 112 string16 FileVersionInfoWin::file_description() { |
| 120 return GetStringValue(L"FileDescription"); | 113 return GetStringValue(L"FileDescription"); |
| 121 } | 114 } |
| 122 | 115 |
| 123 std::wstring FileVersionInfoWin::legal_trademarks() { | 116 string16 FileVersionInfoWin::legal_trademarks() { |
| 124 return GetStringValue(L"LegalTrademarks"); | 117 return GetStringValue(L"LegalTrademarks"); |
| 125 } | 118 } |
| 126 | 119 |
| 127 std::wstring FileVersionInfoWin::private_build() { | 120 string16 FileVersionInfoWin::private_build() { |
| 128 return GetStringValue(L"PrivateBuild"); | 121 return GetStringValue(L"PrivateBuild"); |
| 129 } | 122 } |
| 130 | 123 |
| 131 std::wstring FileVersionInfoWin::file_version() { | 124 string16 FileVersionInfoWin::file_version() { |
| 132 return GetStringValue(L"FileVersion"); | 125 return GetStringValue(L"FileVersion"); |
| 133 } | 126 } |
| 134 | 127 |
| 135 std::wstring FileVersionInfoWin::original_filename() { | 128 string16 FileVersionInfoWin::original_filename() { |
| 136 return GetStringValue(L"OriginalFilename"); | 129 return GetStringValue(L"OriginalFilename"); |
| 137 } | 130 } |
| 138 | 131 |
| 139 std::wstring FileVersionInfoWin::special_build() { | 132 string16 FileVersionInfoWin::special_build() { |
| 140 return GetStringValue(L"SpecialBuild"); | 133 return GetStringValue(L"SpecialBuild"); |
| 141 } | 134 } |
| 142 | 135 |
| 143 std::wstring FileVersionInfoWin::last_change() { | 136 string16 FileVersionInfoWin::last_change() { |
| 144 return GetStringValue(L"LastChange"); | 137 return GetStringValue(L"LastChange"); |
| 145 } | 138 } |
| 146 | 139 |
| 147 bool FileVersionInfoWin::is_official_build() { | 140 bool FileVersionInfoWin::is_official_build() { |
| 148 return (GetStringValue(L"Official Build").compare(L"1") == 0); | 141 return (GetStringValue(L"Official Build").compare(L"1") == 0); |
| 149 } | 142 } |
| 150 | 143 |
| 151 bool FileVersionInfoWin::GetValue(const wchar_t* name, | 144 bool FileVersionInfoWin::GetValue(const wchar_t* name, |
| 152 std::wstring* value_str) { | 145 std::wstring* value_str) { |
| 153 WORD lang_codepage[8]; | 146 WORD lang_codepage[8]; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 183 return false; | 176 return false; |
| 184 } | 177 } |
| 185 | 178 |
| 186 std::wstring FileVersionInfoWin::GetStringValue(const wchar_t* name) { | 179 std::wstring FileVersionInfoWin::GetStringValue(const wchar_t* name) { |
| 187 std::wstring str; | 180 std::wstring str; |
| 188 if (GetValue(name, &str)) | 181 if (GetValue(name, &str)) |
| 189 return str; | 182 return str; |
| 190 else | 183 else |
| 191 return L""; | 184 return L""; |
| 192 } | 185 } |
| OLD | NEW |