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/win/enumerate_modules_model.h" | 5 #include "chrome/browser/win/enumerate_modules_model.h" |
6 | 6 |
7 #include <softpub.h> | 7 #include <softpub.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <tlhelp32.h> | 10 #include <tlhelp32.h> |
11 #include <wincrypt.h> | 11 #include <wincrypt.h> |
12 #include <wintrust.h> | 12 #include <wintrust.h> |
13 #include <mscat.h> // NOLINT: This must be after wincrypt and wintrust. | 13 #include <mscat.h> // NOLINT: This must be after wincrypt and wintrust. |
14 | 14 |
15 #include <algorithm> | 15 #include <algorithm> |
16 #include <set> | 16 #include <set> |
17 #include <string> | 17 #include <string> |
| 18 #include <utility> |
18 | 19 |
19 #include "base/bind.h" | 20 #include "base/bind.h" |
20 #include "base/command_line.h" | 21 #include "base/command_line.h" |
21 #include "base/debug/crash_logging.h" | 22 #include "base/debug/crash_logging.h" |
22 #include "base/debug/leak_annotations.h" | 23 #include "base/debug/leak_annotations.h" |
23 #include "base/environment.h" | 24 #include "base/environment.h" |
24 #include "base/file_version_info.h" | 25 #include "base/file_version_info.h" |
25 #include "base/i18n/case_conversion.h" | 26 #include "base/i18n/case_conversion.h" |
26 #include "base/macros.h" | 27 #include "base/macros.h" |
| 28 #include "base/memory/ptr_util.h" |
27 #include "base/metrics/histogram_macros.h" | 29 #include "base/metrics/histogram_macros.h" |
28 #include "base/scoped_generic.h" | 30 #include "base/scoped_generic.h" |
29 #include "base/strings/string_number_conversions.h" | 31 #include "base/strings/string_number_conversions.h" |
30 #include "base/strings/string_util.h" | 32 #include "base/strings/string_util.h" |
31 #include "base/strings/utf_string_conversions.h" | 33 #include "base/strings/utf_string_conversions.h" |
32 #include "base/task_scheduler/post_task.h" | 34 #include "base/task_scheduler/post_task.h" |
33 #include "base/time/time.h" | 35 #include "base/time/time.h" |
34 #include "base/values.h" | 36 #include "base/values.h" |
35 #include "base/version.h" | 37 #include "base/version.h" |
36 #include "base/win/registry.h" | 38 #include "base/win/registry.h" |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 return nullptr; | 601 return nullptr; |
600 | 602 |
601 if (enumerated_modules_.empty()) | 603 if (enumerated_modules_.empty()) |
602 return nullptr; | 604 return nullptr; |
603 | 605 |
604 base::ListValue* list = new base::ListValue(); | 606 base::ListValue* list = new base::ListValue(); |
605 | 607 |
606 for (ModuleEnumerator::ModulesVector::const_iterator module = | 608 for (ModuleEnumerator::ModulesVector::const_iterator module = |
607 enumerated_modules_.begin(); | 609 enumerated_modules_.begin(); |
608 module != enumerated_modules_.end(); ++module) { | 610 module != enumerated_modules_.end(); ++module) { |
609 base::DictionaryValue* data = new base::DictionaryValue(); | 611 auto data = base::MakeUnique<base::DictionaryValue>(); |
610 data->SetInteger("type", module->type); | 612 data->SetInteger("type", module->type); |
611 base::string16 type_string; | 613 base::string16 type_string; |
612 if ((module->type & ModuleEnumerator::LOADED_MODULE) == 0) { | 614 if ((module->type & ModuleEnumerator::LOADED_MODULE) == 0) { |
613 // Module is not loaded, denote type of module. | 615 // Module is not loaded, denote type of module. |
614 if (module->type & ModuleEnumerator::SHELL_EXTENSION) | 616 if (module->type & ModuleEnumerator::SHELL_EXTENSION) |
615 type_string = L"Shell Extension"; | 617 type_string = L"Shell Extension"; |
616 if (module->type & ModuleEnumerator::WINSOCK_MODULE_REGISTRATION) { | 618 if (module->type & ModuleEnumerator::WINSOCK_MODULE_REGISTRATION) { |
617 if (!type_string.empty()) | 619 if (!type_string.empty()) |
618 type_string += L", "; | 620 type_string += L", "; |
619 type_string += L"Winsock"; | 621 type_string += L"Winsock"; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 base::string16 possible_resolution; | 665 base::string16 possible_resolution; |
664 if (!actions.empty()) { | 666 if (!actions.empty()) { |
665 possible_resolution = | 667 possible_resolution = |
666 l10n_util::GetStringUTF16(IDS_CONFLICTS_CHECK_POSSIBLE_ACTIONS) + | 668 l10n_util::GetStringUTF16(IDS_CONFLICTS_CHECK_POSSIBLE_ACTIONS) + |
667 L" " + actions; | 669 L" " + actions; |
668 } | 670 } |
669 data->SetString("possibleResolution", possible_resolution); | 671 data->SetString("possibleResolution", possible_resolution); |
670 // TODO(chrisha): Set help_url when we have a meaningful place for users | 672 // TODO(chrisha): Set help_url when we have a meaningful place for users |
671 // to land. | 673 // to land. |
672 | 674 |
673 list->Append(data); | 675 list->Append(std::move(data)); |
674 } | 676 } |
675 | 677 |
676 return list; | 678 return list; |
677 } | 679 } |
678 | 680 |
679 GURL EnumerateModulesModel::GetConflictUrl() { | 681 GURL EnumerateModulesModel::GetConflictUrl() { |
680 // For now, simply bring up the chrome://conflicts page, which has detailed | 682 // For now, simply bring up the chrome://conflicts page, which has detailed |
681 // information about each module. | 683 // information about each module. |
682 if (ShouldShowConflictWarning()) | 684 if (ShouldShowConflictWarning()) |
683 return GURL(L"chrome://conflicts"); | 685 return GURL(L"chrome://conflicts"); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 | 721 |
720 UMA_HISTOGRAM_COUNTS_100("Conflicts.SuspectedBadModules", | 722 UMA_HISTOGRAM_COUNTS_100("Conflicts.SuspectedBadModules", |
721 suspected_bad_modules_detected_); | 723 suspected_bad_modules_detected_); |
722 UMA_HISTOGRAM_COUNTS_100("Conflicts.ConfirmedBadModules", | 724 UMA_HISTOGRAM_COUNTS_100("Conflicts.ConfirmedBadModules", |
723 confirmed_bad_modules_detected_); | 725 confirmed_bad_modules_detected_); |
724 | 726 |
725 // Forward the callback to any registered observers. | 727 // Forward the callback to any registered observers. |
726 for (Observer& observer : observers_) | 728 for (Observer& observer : observers_) |
727 observer.OnScanCompleted(); | 729 observer.OnScanCompleted(); |
728 } | 730 } |
OLD | NEW |