| 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 #include "chrome/browser/enumerate_modules_model_win.h" | 5 #include "chrome/browser/enumerate_modules_model_win.h" |
| 6 | 6 |
| 7 #include <Tlhelp32.h> | 7 #include <Tlhelp32.h> |
| 8 #include <wintrust.h> | 8 #include <wintrust.h> |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| 11 #include "app/win/win_util.h" | 11 #include "app/win/win_util.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/environment.h" | 13 #include "base/environment.h" |
| 14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 15 #include "base/file_version_info_win.h" | 15 #include "base/file_version_info_win.h" |
| 16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 17 #include "base/scoped_handle.h" | |
| 18 #include "base/sha2.h" | 17 #include "base/sha2.h" |
| 19 #include "base/string_number_conversions.h" | 18 #include "base/string_number_conversions.h" |
| 20 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 21 #include "base/time.h" | 20 #include "base/time.h" |
| 22 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 23 #include "base/values.h" | 22 #include "base/values.h" |
| 24 #include "base/version.h" | 23 #include "base/version.h" |
| 25 #include "base/win/registry.h" | 24 #include "base/win/registry.h" |
| 25 #include "base/win/scoped_handle.h" |
| 26 #include "chrome/browser/net/service_providers_win.h" | 26 #include "chrome/browser/net/service_providers_win.h" |
| 27 #include "chrome/common/chrome_constants.h" | 27 #include "chrome/common/chrome_constants.h" |
| 28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 29 #include "chrome/common/notification_service.h" | 29 #include "chrome/common/notification_service.h" |
| 30 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
| 31 | 31 |
| 32 // The period of time (in milliseconds) to wait until checking to see if any | 32 // The period of time (in milliseconds) to wait until checking to see if any |
| 33 // incompatible modules exist. | 33 // incompatible modules exist. |
| 34 static const int kModuleCheckDelayMs = 60 * 1000; | 34 static const int kModuleCheckDelayMs = 60 * 1000; |
| 35 | 35 |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 // We are on the main thread already. | 377 // We are on the main thread already. |
| 378 ReportBack(); | 378 ReportBack(); |
| 379 } | 379 } |
| 380 | 380 |
| 381 HISTOGRAM_TIMES("Conflicts.EnumerationTotalTime", | 381 HISTOGRAM_TIMES("Conflicts.EnumerationTotalTime", |
| 382 base::TimeTicks::Now() - start_time); | 382 base::TimeTicks::Now() - start_time); |
| 383 } | 383 } |
| 384 | 384 |
| 385 void ModuleEnumerator::EnumerateLoadedModules() { | 385 void ModuleEnumerator::EnumerateLoadedModules() { |
| 386 // Get all modules in the current process. | 386 // Get all modules in the current process. |
| 387 ScopedHandle snap(::CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, | 387 base::win::ScopedHandle snap(::CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, |
| 388 ::GetCurrentProcessId())); | 388 ::GetCurrentProcessId())); |
| 389 if (!snap.Get()) | 389 if (!snap.Get()) |
| 390 return; | 390 return; |
| 391 | 391 |
| 392 // Walk the module list. | 392 // Walk the module list. |
| 393 MODULEENTRY32 module = { sizeof(module) }; | 393 MODULEENTRY32 module = { sizeof(module) }; |
| 394 if (!::Module32First(snap.Get(), &module)) | 394 if (!::Module32First(snap.Get(), &module)) |
| 395 return; | 395 return; |
| 396 | 396 |
| 397 do { | 397 do { |
| 398 // It would be weird to present chrome.exe as a loaded module. | 398 // It would be weird to present chrome.exe as a loaded module. |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 GenerateHash(WideToUTF8(module.name), &filename); | 877 GenerateHash(WideToUTF8(module.name), &filename); |
| 878 GenerateHash(WideToUTF8(module.location), &location); | 878 GenerateHash(WideToUTF8(module.location), &location); |
| 879 GenerateHash(WideToUTF8(module.description), &description); | 879 GenerateHash(WideToUTF8(module.description), &description); |
| 880 GenerateHash(WideToUTF8(module.digital_signer), &signer); | 880 GenerateHash(WideToUTF8(module.digital_signer), &signer); |
| 881 | 881 |
| 882 string16 url = l10n_util::GetStringFUTF16(IDS_HELP_CENTER_VIEW_CONFLICTS, | 882 string16 url = l10n_util::GetStringFUTF16(IDS_HELP_CENTER_VIEW_CONFLICTS, |
| 883 ASCIIToUTF16(filename), ASCIIToUTF16(location), | 883 ASCIIToUTF16(filename), ASCIIToUTF16(location), |
| 884 ASCIIToUTF16(description), ASCIIToUTF16(signer)); | 884 ASCIIToUTF16(description), ASCIIToUTF16(signer)); |
| 885 return GURL(UTF16ToUTF8(url)); | 885 return GURL(UTF16ToUTF8(url)); |
| 886 } | 886 } |
| OLD | NEW |