| 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_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 28 #include "content/common/notification_service.h" | 29 #include "content/common/notification_service.h" |
| 29 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 31 | 32 |
| 32 // 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 |
| 33 // incompatible modules exist. | 34 // incompatible modules exist. |
| 34 static const int kModuleCheckDelayMs = 60 * 1000; | 35 static const int kModuleCheckDelayMs = 60 * 1000; |
| 35 | 36 |
| 36 // The path to the Shell Extension key in the Windows registry. | 37 // The path to the Shell Extension key in the Windows registry. |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 if (conflict_notification_acknowledged_) | 764 if (conflict_notification_acknowledged_) |
| 764 return false; | 765 return false; |
| 765 | 766 |
| 766 return confirmed_bad_modules_detected_ > 0; | 767 return confirmed_bad_modules_detected_ > 0; |
| 767 } | 768 } |
| 768 | 769 |
| 769 void EnumerateModulesModel::AcknowledgeConflictNotification() { | 770 void EnumerateModulesModel::AcknowledgeConflictNotification() { |
| 770 if (!conflict_notification_acknowledged_) { | 771 if (!conflict_notification_acknowledged_) { |
| 771 conflict_notification_acknowledged_ = true; | 772 conflict_notification_acknowledged_ = true; |
| 772 NotificationService::current()->Notify( | 773 NotificationService::current()->Notify( |
| 773 NotificationType::MODULE_INCOMPATIBILITY_BADGE_CHANGE, | 774 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, |
| 774 Source<EnumerateModulesModel>(this), | 775 Source<EnumerateModulesModel>(this), |
| 775 NotificationService::NoDetails()); | 776 NotificationService::NoDetails()); |
| 776 } | 777 } |
| 777 } | 778 } |
| 778 | 779 |
| 779 void EnumerateModulesModel::ScanNow() { | 780 void EnumerateModulesModel::ScanNow() { |
| 780 if (scanning_) | 781 if (scanning_) |
| 781 return; // A scan is already in progress. | 782 return; // A scan is already in progress. |
| 782 | 783 |
| 783 lock->Acquire(); // Balanced in DoneScanning(); | 784 lock->Acquire(); // Balanced in DoneScanning(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 UMA_HISTOGRAM_COUNTS_100("Conflicts.SuspectedBadModules", | 919 UMA_HISTOGRAM_COUNTS_100("Conflicts.SuspectedBadModules", |
| 919 suspected_bad_modules_detected_); | 920 suspected_bad_modules_detected_); |
| 920 UMA_HISTOGRAM_COUNTS_100("Conflicts.ConfirmedBadModules", | 921 UMA_HISTOGRAM_COUNTS_100("Conflicts.ConfirmedBadModules", |
| 921 confirmed_bad_modules_detected_); | 922 confirmed_bad_modules_detected_); |
| 922 | 923 |
| 923 // Notifications are not available in limited mode. | 924 // Notifications are not available in limited mode. |
| 924 if (limited_mode_) | 925 if (limited_mode_) |
| 925 return; | 926 return; |
| 926 | 927 |
| 927 NotificationService::current()->Notify( | 928 NotificationService::current()->Notify( |
| 928 NotificationType::MODULE_LIST_ENUMERATED, | 929 chrome::NOTIFICATION_MODULE_LIST_ENUMERATED, |
| 929 Source<EnumerateModulesModel>(this), | 930 Source<EnumerateModulesModel>(this), |
| 930 NotificationService::NoDetails()); | 931 NotificationService::NoDetails()); |
| 931 | 932 |
| 932 // Command line flag must be enabled for the notification to get sent out. | 933 // Command line flag must be enabled for the notification to get sent out. |
| 933 // Otherwise we'd get the badge (while the feature is disabled) when we | 934 // Otherwise we'd get the badge (while the feature is disabled) when we |
| 934 // navigate to about:conflicts and find confirmed matches. | 935 // navigate to about:conflicts and find confirmed matches. |
| 935 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 936 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
| 936 if (!cmd_line.HasSwitch(switches::kConflictingModulesCheck)) | 937 if (!cmd_line.HasSwitch(switches::kConflictingModulesCheck)) |
| 937 return; | 938 return; |
| 938 | 939 |
| 939 NotificationService::current()->Notify( | 940 NotificationService::current()->Notify( |
| 940 NotificationType::MODULE_INCOMPATIBILITY_BADGE_CHANGE, | 941 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, |
| 941 Source<EnumerateModulesModel>(this), | 942 Source<EnumerateModulesModel>(this), |
| 942 NotificationService::NoDetails()); | 943 NotificationService::NoDetails()); |
| 943 } | 944 } |
| 944 | 945 |
| 945 GURL EnumerateModulesModel::ConstructHelpCenterUrl( | 946 GURL EnumerateModulesModel::ConstructHelpCenterUrl( |
| 946 const ModuleEnumerator::Module& module) const { | 947 const ModuleEnumerator::Module& module) const { |
| 947 if (!(module.recommended_action & ModuleEnumerator::SEE_LINK)) | 948 if (!(module.recommended_action & ModuleEnumerator::SEE_LINK)) |
| 948 return GURL(); | 949 return GURL(); |
| 949 | 950 |
| 950 // Construct the needed hashes. | 951 // Construct the needed hashes. |
| 951 std::string filename, location, description, signer; | 952 std::string filename, location, description, signer; |
| 952 GenerateHash(WideToUTF8(module.name), &filename); | 953 GenerateHash(WideToUTF8(module.name), &filename); |
| 953 GenerateHash(WideToUTF8(module.location), &location); | 954 GenerateHash(WideToUTF8(module.location), &location); |
| 954 GenerateHash(WideToUTF8(module.description), &description); | 955 GenerateHash(WideToUTF8(module.description), &description); |
| 955 GenerateHash(WideToUTF8(module.digital_signer), &signer); | 956 GenerateHash(WideToUTF8(module.digital_signer), &signer); |
| 956 | 957 |
| 957 string16 url = l10n_util::GetStringFUTF16(IDS_HELP_CENTER_VIEW_CONFLICTS, | 958 string16 url = l10n_util::GetStringFUTF16(IDS_HELP_CENTER_VIEW_CONFLICTS, |
| 958 ASCIIToUTF16(filename), ASCIIToUTF16(location), | 959 ASCIIToUTF16(filename), ASCIIToUTF16(location), |
| 959 ASCIIToUTF16(description), ASCIIToUTF16(signer)); | 960 ASCIIToUTF16(description), ASCIIToUTF16(signer)); |
| 960 return GURL(UTF16ToUTF8(url)); | 961 return GURL(UTF16ToUTF8(url)); |
| 961 } | 962 } |
| OLD | NEW |