| 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/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/environment.h" | 11 #include "base/environment.h" |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/file_version_info_win.h" | 13 #include "base/file_version_info_win.h" |
| 14 #include "base/i18n/case_conversion.h" | 14 #include "base/i18n/case_conversion.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
| 17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
| 18 #include "base/time.h" | 18 #include "base/time.h" |
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "base/version.h" | 21 #include "base/version.h" |
| 22 #include "base/win/registry.h" | 22 #include "base/win/registry.h" |
| 23 #include "base/win/scoped_handle.h" | 23 #include "base/win/scoped_handle.h" |
| 24 #include "crypto/sha2.h" | 24 #include "crypto/sha2.h" |
| 25 #include "chrome/browser/net/service_providers_win.h" | 25 #include "chrome/browser/net/service_providers_win.h" |
| 26 #include "chrome/common/chrome_constants.h" | 26 #include "chrome/common/chrome_constants.h" |
| 27 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
| 28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 29 #include "content/common/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
| 30 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 32 | 32 |
| 33 // The period of time (in milliseconds) to wait until checking to see if any | 33 // The period of time (in milliseconds) to wait until checking to see if any |
| 34 // incompatible modules exist. | 34 // incompatible modules exist. |
| 35 static const int kModuleCheckDelayMs = 60 * 1000; | 35 static const int kModuleCheckDelayMs = 60 * 1000; |
| 36 | 36 |
| 37 // The path to the Shell Extension key in the Windows registry. | 37 // The path to the Shell Extension key in the Windows registry. |
| 38 static const wchar_t kRegPath[] = | 38 static const wchar_t kRegPath[] = |
| 39 L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"; | 39 L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"; |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 // need to clear the flag somewhere when we are ready to show it again. | 778 // need to clear the flag somewhere when we are ready to show it again. |
| 779 if (conflict_notification_acknowledged_) | 779 if (conflict_notification_acknowledged_) |
| 780 return false; | 780 return false; |
| 781 | 781 |
| 782 return confirmed_bad_modules_detected_ > 0; | 782 return confirmed_bad_modules_detected_ > 0; |
| 783 } | 783 } |
| 784 | 784 |
| 785 void EnumerateModulesModel::AcknowledgeConflictNotification() { | 785 void EnumerateModulesModel::AcknowledgeConflictNotification() { |
| 786 if (!conflict_notification_acknowledged_) { | 786 if (!conflict_notification_acknowledged_) { |
| 787 conflict_notification_acknowledged_ = true; | 787 conflict_notification_acknowledged_ = true; |
| 788 NotificationService::current()->Notify( | 788 content::NotificationService::current()->Notify( |
| 789 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, | 789 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, |
| 790 content::Source<EnumerateModulesModel>(this), | 790 content::Source<EnumerateModulesModel>(this), |
| 791 NotificationService::NoDetails()); | 791 content::NotificationService::NoDetails()); |
| 792 } | 792 } |
| 793 } | 793 } |
| 794 | 794 |
| 795 void EnumerateModulesModel::ScanNow() { | 795 void EnumerateModulesModel::ScanNow() { |
| 796 if (scanning_) | 796 if (scanning_) |
| 797 return; // A scan is already in progress. | 797 return; // A scan is already in progress. |
| 798 | 798 |
| 799 lock->Acquire(); // Balanced in DoneScanning(); | 799 lock->Acquire(); // Balanced in DoneScanning(); |
| 800 | 800 |
| 801 scanning_ = true; | 801 scanning_ = true; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 | 933 |
| 934 UMA_HISTOGRAM_COUNTS_100("Conflicts.SuspectedBadModules", | 934 UMA_HISTOGRAM_COUNTS_100("Conflicts.SuspectedBadModules", |
| 935 suspected_bad_modules_detected_); | 935 suspected_bad_modules_detected_); |
| 936 UMA_HISTOGRAM_COUNTS_100("Conflicts.ConfirmedBadModules", | 936 UMA_HISTOGRAM_COUNTS_100("Conflicts.ConfirmedBadModules", |
| 937 confirmed_bad_modules_detected_); | 937 confirmed_bad_modules_detected_); |
| 938 | 938 |
| 939 // Notifications are not available in limited mode. | 939 // Notifications are not available in limited mode. |
| 940 if (limited_mode_) | 940 if (limited_mode_) |
| 941 return; | 941 return; |
| 942 | 942 |
| 943 NotificationService::current()->Notify( | 943 content::NotificationService::current()->Notify( |
| 944 chrome::NOTIFICATION_MODULE_LIST_ENUMERATED, | 944 chrome::NOTIFICATION_MODULE_LIST_ENUMERATED, |
| 945 content::Source<EnumerateModulesModel>(this), | 945 content::Source<EnumerateModulesModel>(this), |
| 946 NotificationService::NoDetails()); | 946 content::NotificationService::NoDetails()); |
| 947 | 947 |
| 948 // Command line flag must be enabled for the notification to get sent out. | 948 // Command line flag must be enabled for the notification to get sent out. |
| 949 // Otherwise we'd get the badge (while the feature is disabled) when we | 949 // Otherwise we'd get the badge (while the feature is disabled) when we |
| 950 // navigate to about:conflicts and find confirmed matches. | 950 // navigate to about:conflicts and find confirmed matches. |
| 951 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 951 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
| 952 if (!cmd_line.HasSwitch(switches::kConflictingModulesCheck)) | 952 if (!cmd_line.HasSwitch(switches::kConflictingModulesCheck)) |
| 953 return; | 953 return; |
| 954 | 954 |
| 955 NotificationService::current()->Notify( | 955 content::NotificationService::current()->Notify( |
| 956 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, | 956 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, |
| 957 content::Source<EnumerateModulesModel>(this), | 957 content::Source<EnumerateModulesModel>(this), |
| 958 NotificationService::NoDetails()); | 958 content::NotificationService::NoDetails()); |
| 959 } | 959 } |
| 960 | 960 |
| 961 GURL EnumerateModulesModel::ConstructHelpCenterUrl( | 961 GURL EnumerateModulesModel::ConstructHelpCenterUrl( |
| 962 const ModuleEnumerator::Module& module) const { | 962 const ModuleEnumerator::Module& module) const { |
| 963 if (!(module.recommended_action & ModuleEnumerator::SEE_LINK)) | 963 if (!(module.recommended_action & ModuleEnumerator::SEE_LINK)) |
| 964 return GURL(); | 964 return GURL(); |
| 965 | 965 |
| 966 // Construct the needed hashes. | 966 // Construct the needed hashes. |
| 967 std::string filename, location, description, signer; | 967 std::string filename, location, description, signer; |
| 968 GenerateHash(WideToUTF8(module.name), &filename); | 968 GenerateHash(WideToUTF8(module.name), &filename); |
| 969 GenerateHash(WideToUTF8(module.location), &location); | 969 GenerateHash(WideToUTF8(module.location), &location); |
| 970 GenerateHash(WideToUTF8(module.description), &description); | 970 GenerateHash(WideToUTF8(module.description), &description); |
| 971 GenerateHash(WideToUTF8(module.digital_signer), &signer); | 971 GenerateHash(WideToUTF8(module.digital_signer), &signer); |
| 972 | 972 |
| 973 string16 url = l10n_util::GetStringFUTF16(IDS_HELP_CENTER_VIEW_CONFLICTS, | 973 string16 url = l10n_util::GetStringFUTF16(IDS_HELP_CENTER_VIEW_CONFLICTS, |
| 974 ASCIIToUTF16(filename), ASCIIToUTF16(location), | 974 ASCIIToUTF16(filename), ASCIIToUTF16(location), |
| 975 ASCIIToUTF16(description), ASCIIToUTF16(signer)); | 975 ASCIIToUTF16(description), ASCIIToUTF16(signer)); |
| 976 return GURL(UTF16ToUTF8(url)); | 976 return GURL(UTF16ToUTF8(url)); |
| 977 } | 977 } |
| OLD | NEW |