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/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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <wintrust.h> | 10 #include <wintrust.h> |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
26 #include "base/time/time.h" | 26 #include "base/time/time.h" |
27 #include "base/values.h" | 27 #include "base/values.h" |
28 #include "base/version.h" | 28 #include "base/version.h" |
29 #include "base/win/registry.h" | 29 #include "base/win/registry.h" |
30 #include "base/win/scoped_handle.h" | 30 #include "base/win/scoped_handle.h" |
31 #include "base/win/windows_version.h" | 31 #include "base/win/windows_version.h" |
32 #include "chrome/browser/chrome_notification_types.h" | 32 #include "chrome/browser/chrome_notification_types.h" |
33 #include "chrome/browser/net/service_providers_win.h" | 33 #include "chrome/browser/net/service_providers_win.h" |
34 #include "chrome/common/chrome_constants.h" | 34 #include "chrome/common/chrome_constants.h" |
| 35 #include "chrome/common/chrome_switches.h" |
35 #include "chrome/grit/generated_resources.h" | 36 #include "chrome/grit/generated_resources.h" |
36 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
37 #include "crypto/sha2.h" | 38 #include "crypto/sha2.h" |
38 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
39 | 40 |
40 using content::BrowserThread; | 41 using content::BrowserThread; |
41 | 42 |
42 // The period of time (in milliseconds) to wait until checking to see if any | 43 // The period of time (in milliseconds) to wait until checking to see if any |
43 // incompatible modules exist. | 44 // incompatible modules exist. |
44 static const int kModuleCheckDelayMs = 45 * 1000; | 45 static const int kModuleCheckDelayMs = 45 * 1000; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 DWORD return_value = GetLongPathName(short_path.c_str(), long_path_buf, | 100 DWORD return_value = GetLongPathName(short_path.c_str(), long_path_buf, |
100 MAX_PATH); | 101 MAX_PATH); |
101 if (return_value != 0 && return_value < MAX_PATH) { | 102 if (return_value != 0 && return_value < MAX_PATH) { |
102 *long_path = long_path_buf; | 103 *long_path = long_path_buf; |
103 return true; | 104 return true; |
104 } | 105 } |
105 | 106 |
106 return false; | 107 return false; |
107 } | 108 } |
108 | 109 |
| 110 bool SimulateBadModules() { |
| 111 const base::CommandLine& cmd_line = *base::CommandLine::ForCurrentProcess(); |
| 112 return cmd_line.HasSwitch(switches::kSimulateBadModules); |
| 113 } |
| 114 |
109 } // namespace | 115 } // namespace |
110 | 116 |
111 ModuleEnumerator::Module::Module() { | 117 ModuleEnumerator::Module::Module() { |
112 } | 118 } |
113 | 119 |
114 ModuleEnumerator::Module::Module(const Module& rhs) = default; | 120 ModuleEnumerator::Module::Module(const Module& rhs) = default; |
115 | 121 |
116 ModuleEnumerator::Module::Module(ModuleType type, | 122 ModuleEnumerator::Module::Module(ModuleType type, |
117 ModuleStatus status, | 123 ModuleStatus status, |
118 const base::string16& location, | 124 const base::string16& location, |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 } | 853 } |
848 | 854 |
849 bool EnumerateModulesModel::ShouldShowConflictWarning() const { | 855 bool EnumerateModulesModel::ShouldShowConflictWarning() const { |
850 // If the user has acknowledged the conflict notification, then we don't need | 856 // If the user has acknowledged the conflict notification, then we don't need |
851 // to show it again (because the scanning only happens once per the lifetime | 857 // to show it again (because the scanning only happens once per the lifetime |
852 // of the process). If we were to run the scanning more than once, then we'd | 858 // of the process). If we were to run the scanning more than once, then we'd |
853 // need to clear the flag somewhere when we are ready to show it again. | 859 // need to clear the flag somewhere when we are ready to show it again. |
854 if (conflict_notification_acknowledged_) | 860 if (conflict_notification_acknowledged_) |
855 return false; | 861 return false; |
856 | 862 |
857 return confirmed_bad_modules_detected_ > 0; | 863 return SimulateBadModules() || (confirmed_bad_modules_detected_ > 0); |
858 } | 864 } |
859 | 865 |
860 void EnumerateModulesModel::AcknowledgeConflictNotification() { | 866 void EnumerateModulesModel::AcknowledgeConflictNotification() { |
861 if (!conflict_notification_acknowledged_) { | 867 if (!conflict_notification_acknowledged_) { |
862 conflict_notification_acknowledged_ = true; | 868 conflict_notification_acknowledged_ = true; |
863 content::NotificationService::current()->Notify( | 869 content::NotificationService::current()->Notify( |
864 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, | 870 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, |
865 content::Source<EnumerateModulesModel>(this), | 871 content::Source<EnumerateModulesModel>(this), |
866 content::NotificationService::NoDetails()); | 872 content::NotificationService::NoDetails()); |
867 } | 873 } |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 GenerateHash(base::WideToUTF8(module.location), &location); | 1079 GenerateHash(base::WideToUTF8(module.location), &location); |
1074 GenerateHash(base::WideToUTF8(module.description), &description); | 1080 GenerateHash(base::WideToUTF8(module.description), &description); |
1075 GenerateHash(base::WideToUTF8(module.digital_signer), &signer); | 1081 GenerateHash(base::WideToUTF8(module.digital_signer), &signer); |
1076 | 1082 |
1077 base::string16 url = | 1083 base::string16 url = |
1078 l10n_util::GetStringFUTF16(IDS_HELP_CENTER_VIEW_CONFLICTS, | 1084 l10n_util::GetStringFUTF16(IDS_HELP_CENTER_VIEW_CONFLICTS, |
1079 base::ASCIIToUTF16(filename), base::ASCIIToUTF16(location), | 1085 base::ASCIIToUTF16(filename), base::ASCIIToUTF16(location), |
1080 base::ASCIIToUTF16(description), base::ASCIIToUTF16(signer)); | 1086 base::ASCIIToUTF16(description), base::ASCIIToUTF16(signer)); |
1081 return GURL(base::UTF16ToUTF8(url)); | 1087 return GURL(base::UTF16ToUTF8(url)); |
1082 } | 1088 } |
OLD | NEW |