OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/enumerate_modules_model_win.h" | 5 #include "chrome/browser/enumerate_modules_model_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <Tlhelp32.h> | 8 #include <Tlhelp32.h> |
9 #include <wintrust.h> | 9 #include <wintrust.h> |
10 | 10 |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 std::string filename_hash, location_hash; | 334 std::string filename_hash, location_hash; |
335 GenerateHash(WideToUTF8(module.name), &filename_hash); | 335 GenerateHash(WideToUTF8(module.name), &filename_hash); |
336 GenerateHash(WideToUTF8(module.location), &location_hash); | 336 GenerateHash(WideToUTF8(module.location), &location_hash); |
337 | 337 |
338 // Filenames are mandatory. Location is mandatory if given. | 338 // Filenames are mandatory. Location is mandatory if given. |
339 if (filename_hash == blacklisted.filename && | 339 if (filename_hash == blacklisted.filename && |
340 (std::string(blacklisted.location).empty() || | 340 (std::string(blacklisted.location).empty() || |
341 location_hash == blacklisted.location)) { | 341 location_hash == blacklisted.location)) { |
342 // We have a name match against the blacklist (and possibly location match | 342 // We have a name match against the blacklist (and possibly location match |
343 // also), so check version. | 343 // also), so check version. |
344 scoped_ptr<Version> module_version( | 344 Version module_version(UTF16ToASCII(module.version)); |
345 Version::GetVersionFromString(UTF16ToASCII(module.version))); | 345 Version version_min(blacklisted.version_from); |
346 scoped_ptr<Version> version_min( | 346 Version version_max(blacklisted.version_to); |
347 Version::GetVersionFromString(blacklisted.version_from)); | 347 bool version_ok = !version_min.IsValid() && !version_max.IsValid(); |
348 scoped_ptr<Version> version_max( | |
349 Version::GetVersionFromString(blacklisted.version_to)); | |
350 bool version_ok = !version_min.get() && !version_max.get(); | |
351 if (!version_ok) { | 348 if (!version_ok) { |
352 bool too_low = version_min.get() && | 349 bool too_low = version_min.IsValid() && |
353 (!module_version.get() || | 350 (!module_version.IsValid() || |
354 module_version->CompareTo(*version_min.get()) < 0); | 351 module_version.CompareTo(version_min) < 0); |
355 bool too_high = version_max.get() && | 352 bool too_high = version_max.IsValid() && |
356 (!module_version.get() || | 353 (!module_version.IsValid() || |
357 module_version->CompareTo(*version_max.get()) >= 0); | 354 module_version.CompareTo(version_max) >= 0); |
358 version_ok = !too_low && !too_high; | 355 version_ok = !too_low && !too_high; |
359 } | 356 } |
360 | 357 |
361 if (version_ok) { | 358 if (version_ok) { |
362 // At this point, the names match and there is no version specified | 359 // At this point, the names match and there is no version specified |
363 // or the versions also match. | 360 // or the versions also match. |
364 | 361 |
365 std::string desc_or_signer(blacklisted.desc_or_signer); | 362 std::string desc_or_signer(blacklisted.desc_or_signer); |
366 std::string signer_hash, description_hash; | 363 std::string signer_hash, description_hash; |
367 GenerateHash(WideToUTF8(module.digital_signer), &signer_hash); | 364 GenerateHash(WideToUTF8(module.digital_signer), &signer_hash); |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 GenerateHash(WideToUTF8(module.name), &filename); | 970 GenerateHash(WideToUTF8(module.name), &filename); |
974 GenerateHash(WideToUTF8(module.location), &location); | 971 GenerateHash(WideToUTF8(module.location), &location); |
975 GenerateHash(WideToUTF8(module.description), &description); | 972 GenerateHash(WideToUTF8(module.description), &description); |
976 GenerateHash(WideToUTF8(module.digital_signer), &signer); | 973 GenerateHash(WideToUTF8(module.digital_signer), &signer); |
977 | 974 |
978 string16 url = l10n_util::GetStringFUTF16(IDS_HELP_CENTER_VIEW_CONFLICTS, | 975 string16 url = l10n_util::GetStringFUTF16(IDS_HELP_CENTER_VIEW_CONFLICTS, |
979 ASCIIToUTF16(filename), ASCIIToUTF16(location), | 976 ASCIIToUTF16(filename), ASCIIToUTF16(location), |
980 ASCIIToUTF16(description), ASCIIToUTF16(signer)); | 977 ASCIIToUTF16(description), ASCIIToUTF16(signer)); |
981 return GURL(UTF16ToUTF8(url)); | 978 return GURL(UTF16ToUTF8(url)); |
982 } | 979 } |
OLD | NEW |