| 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 "base/bind.h" |
| 10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 11 #include "base/environment.h" | 12 #include "base/environment.h" |
| 12 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 13 #include "base/file_version_info_win.h" | 14 #include "base/file_version_info_win.h" |
| 14 #include "base/i18n/case_conversion.h" | 15 #include "base/i18n/case_conversion.h" |
| 15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 16 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
| 17 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 18 #include "base/time.h" | 19 #include "base/time.h" |
| 19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 } | 393 } |
| 393 | 394 |
| 394 void ModuleEnumerator::ScanNow(ModulesVector* list, bool limited_mode) { | 395 void ModuleEnumerator::ScanNow(ModulesVector* list, bool limited_mode) { |
| 395 enumerated_modules_ = list; | 396 enumerated_modules_ = list; |
| 396 | 397 |
| 397 limited_mode_ = limited_mode; | 398 limited_mode_ = limited_mode; |
| 398 | 399 |
| 399 if (!limited_mode_) { | 400 if (!limited_mode_) { |
| 400 CHECK(BrowserThread::GetCurrentThreadIdentifier(&callback_thread_id_)); | 401 CHECK(BrowserThread::GetCurrentThreadIdentifier(&callback_thread_id_)); |
| 401 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 402 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 402 BrowserThread::PostTask( | 403 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 403 BrowserThread::FILE, FROM_HERE, | 404 base::Bind(&ModuleEnumerator::ScanImpl, this)); |
| 404 NewRunnableMethod(this, &ModuleEnumerator::ScanImpl)); | |
| 405 } else { | 405 } else { |
| 406 // Run it synchronously. | 406 // Run it synchronously. |
| 407 ScanImpl(); | 407 ScanImpl(); |
| 408 } | 408 } |
| 409 } | 409 } |
| 410 | 410 |
| 411 void ModuleEnumerator::ScanImpl() { | 411 void ModuleEnumerator::ScanImpl() { |
| 412 base::TimeTicks start_time = base::TimeTicks::Now(); | 412 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 413 | 413 |
| 414 enumerated_modules_->clear(); | 414 enumerated_modules_->clear(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 436 UMA_HISTOGRAM_TIMES("Conflicts.EnumerateWinsockModules", | 436 UMA_HISTOGRAM_TIMES("Conflicts.EnumerateWinsockModules", |
| 437 checkpoint2 - checkpoint); | 437 checkpoint2 - checkpoint); |
| 438 | 438 |
| 439 MatchAgainstBlacklist(); | 439 MatchAgainstBlacklist(); |
| 440 | 440 |
| 441 std::sort(enumerated_modules_->begin(), | 441 std::sort(enumerated_modules_->begin(), |
| 442 enumerated_modules_->end(), ModuleSort); | 442 enumerated_modules_->end(), ModuleSort); |
| 443 | 443 |
| 444 if (!limited_mode_) { | 444 if (!limited_mode_) { |
| 445 // Send a reply back on the UI thread. | 445 // Send a reply back on the UI thread. |
| 446 BrowserThread::PostTask( | 446 BrowserThread::PostTask(callback_thread_id_, FROM_HERE, |
| 447 callback_thread_id_, FROM_HERE, | 447 base::Bind(&ModuleEnumerator::ReportBack, this)); |
| 448 NewRunnableMethod(this, &ModuleEnumerator::ReportBack)); | |
| 449 } else { | 448 } else { |
| 450 // We are on the main thread already. | 449 // We are on the main thread already. |
| 451 ReportBack(); | 450 ReportBack(); |
| 452 } | 451 } |
| 453 | 452 |
| 454 UMA_HISTOGRAM_TIMES("Conflicts.EnumerationTotalTime", | 453 UMA_HISTOGRAM_TIMES("Conflicts.EnumerationTotalTime", |
| 455 base::TimeTicks::Now() - start_time); | 454 base::TimeTicks::Now() - start_time); |
| 456 } | 455 } |
| 457 | 456 |
| 458 void ModuleEnumerator::EnumerateLoadedModules() { | 457 void ModuleEnumerator::EnumerateLoadedModules() { |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 GenerateHash(WideToUTF8(module.name), &filename); | 969 GenerateHash(WideToUTF8(module.name), &filename); |
| 971 GenerateHash(WideToUTF8(module.location), &location); | 970 GenerateHash(WideToUTF8(module.location), &location); |
| 972 GenerateHash(WideToUTF8(module.description), &description); | 971 GenerateHash(WideToUTF8(module.description), &description); |
| 973 GenerateHash(WideToUTF8(module.digital_signer), &signer); | 972 GenerateHash(WideToUTF8(module.digital_signer), &signer); |
| 974 | 973 |
| 975 string16 url = l10n_util::GetStringFUTF16(IDS_HELP_CENTER_VIEW_CONFLICTS, | 974 string16 url = l10n_util::GetStringFUTF16(IDS_HELP_CENTER_VIEW_CONFLICTS, |
| 976 ASCIIToUTF16(filename), ASCIIToUTF16(location), | 975 ASCIIToUTF16(filename), ASCIIToUTF16(location), |
| 977 ASCIIToUTF16(description), ASCIIToUTF16(signer)); | 976 ASCIIToUTF16(description), ASCIIToUTF16(signer)); |
| 978 return GURL(UTF16ToUTF8(url)); | 977 return GURL(UTF16ToUTF8(url)); |
| 979 } | 978 } |
| OLD | NEW |