[email protected] | d80268a5 | 2011-01-06 08:57:45 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
pmonette | 23c8fb7e | 2016-06-27 20:45:11 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_WIN_ENUMERATE_MODULES_MODEL_H_ |
| 6 | #define CHROME_BROWSER_WIN_ENUMERATE_MODULES_MODEL_H_ |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 7 | |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 8 | #include <memory> |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 9 | #include <utility> |
| 10 | #include <vector> |
| 11 | |
chrisha | cd02dc9 | 2016-10-06 20:37:13 | [diff] [blame] | 12 | #include "base/files/file_path.h" |
[email protected] | 09fe8beb | 2010-12-16 10:03:01 | [diff] [blame] | 13 | #include "base/gtest_prod_util.h" |
avi | 6846aef | 2015-12-26 01:09:38 | [diff] [blame] | 14 | #include "base/macros.h" |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 15 | #include "base/observer_list.h" |
[email protected] | d883056 | 2013-06-10 22:01:54 | [diff] [blame] | 16 | #include "base/strings/string16.h" |
[email protected] | 41a17c5 | 2013-06-28 00:27:53 | [diff] [blame] | 17 | #include "base/timer/timer.h" |
chrisha | 2b10cfe | 2017-02-07 03:34:21 | [diff] [blame] | 18 | #include "chrome/browser/conflicts/module_info_util_win.h" |
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 19 | #include "content/public/browser/browser_thread.h" |
[email protected] | 761fa470 | 2013-07-02 15:25:15 | [diff] [blame] | 20 | #include "url/gurl.h" |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 21 | |
| 22 | class EnumerateModulesModel; |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 23 | |
| 24 | namespace base { |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 25 | class ListValue; |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 26 | } |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 27 | |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 28 | // A helper class that implements the enumerate module functionality on the FILE |
| 29 | // thread. Not to be used directly. |
| 30 | // TODO(chrisha): Move this to a separate .h and .cc. |
| 31 | class ModuleEnumerator { |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 32 | public: |
| 33 | // What type of module we are dealing with. Loaded modules are modules we |
| 34 | // detect as loaded in the process at the time of scanning. The others are |
| 35 | // modules of interest and may or may not be loaded in the process at the |
| 36 | // time of scan. |
| 37 | enum ModuleType { |
[email protected] | c8965289 | 2010-11-29 22:19:18 | [diff] [blame] | 38 | LOADED_MODULE = 1 << 0, |
| 39 | SHELL_EXTENSION = 1 << 1, |
| 40 | WINSOCK_MODULE_REGISTRATION = 1 << 2, |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | // The blacklist status of the module. Suspected Bad modules have been |
| 44 | // partially matched (ie. name matches and location, but not description) |
| 45 | // whereas Confirmed Bad modules have been identified further (ie. |
| 46 | // AuthentiCode signer matches). |
| 47 | enum ModuleStatus { |
| 48 | // This is returned by the matching function when comparing against the |
| 49 | // blacklist and the module does not match the current entry in the |
| 50 | // blacklist. |
| 51 | NOT_MATCHED, |
| 52 | // The module is not on the blacklist. Assume it is good. |
| 53 | GOOD, |
| 54 | // Module is a suspected bad module. |
| 55 | SUSPECTED_BAD, |
| 56 | // Module is a bad bad dog. |
| 57 | CONFIRMED_BAD, |
| 58 | }; |
| 59 | |
| 60 | // A bitmask with the possible resolutions for bad modules. |
| 61 | enum RecommendedAction { |
| 62 | NONE = 0, |
| 63 | INVESTIGATING = 1 << 0, |
| 64 | UNINSTALL = 1 << 1, |
| 65 | DISABLE = 1 << 2, |
| 66 | UPDATE = 1 << 3, |
| 67 | SEE_LINK = 1 << 4, |
[email protected] | d04126a | 2013-06-06 15:28:33 | [diff] [blame] | 68 | NOTIFY_USER = 1 << 5, |
| 69 | }; |
| 70 | |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 71 | // The structure we populate when enumerating modules. |
| 72 | struct Module { |
thakis | 3b7c20e3 | 2015-05-08 19:35:04 | [diff] [blame] | 73 | Module(); |
| 74 | Module(const Module& rhs); |
chrisha | cd02dc9 | 2016-10-06 20:37:13 | [diff] [blame] | 75 | // Constructor exposed for unittesting. |
thakis | 3b7c20e3 | 2015-05-08 19:35:04 | [diff] [blame] | 76 | Module(ModuleType type, |
| 77 | ModuleStatus status, |
| 78 | const base::string16& location, |
| 79 | const base::string16& name, |
| 80 | const base::string16& product_name, |
| 81 | const base::string16& description, |
| 82 | const base::string16& version, |
thakis | 3b7c20e3 | 2015-05-08 19:35:04 | [diff] [blame] | 83 | RecommendedAction recommended_action); |
| 84 | ~Module(); |
| 85 | |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 86 | // The type of module found |
| 87 | ModuleType type; |
| 88 | // The module status (benign/bad/etc). |
| 89 | ModuleStatus status; |
| 90 | // The module path, not including filename. |
[email protected] | 439f1e3 | 2013-12-09 20:09:09 | [diff] [blame] | 91 | base::string16 location; |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 92 | // The name of the module (filename). |
[email protected] | 439f1e3 | 2013-12-09 20:09:09 | [diff] [blame] | 93 | base::string16 name; |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 94 | // The name of the product the module belongs to. |
[email protected] | 439f1e3 | 2013-12-09 20:09:09 | [diff] [blame] | 95 | base::string16 product_name; |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 96 | // The module file description. |
[email protected] | 439f1e3 | 2013-12-09 20:09:09 | [diff] [blame] | 97 | base::string16 description; |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 98 | // The module version. |
[email protected] | 439f1e3 | 2013-12-09 20:09:09 | [diff] [blame] | 99 | base::string16 version; |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 100 | // The help tips bitmask. |
| 101 | RecommendedAction recommended_action; |
[email protected] | 47db01d | 2010-11-20 10:00:19 | [diff] [blame] | 102 | // The duplicate count within each category of modules. |
| 103 | int duplicate_count; |
chrisha | cd02dc9 | 2016-10-06 20:37:13 | [diff] [blame] | 104 | // The certificate info for the module. |
pmonette | cfe91abf | 2017-02-25 00:11:11 | [diff] [blame] | 105 | CertificateInfo cert_info; |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | // A vector typedef of all modules enumerated. |
| 109 | typedef std::vector<Module> ModulesVector; |
| 110 | |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 111 | // A static function that normalizes the module information in the |module| |
| 112 | // struct. Module information needs to be normalized before comparing against |
| 113 | // the blacklist. This is because the same module can be described in many |
| 114 | // different ways, ie. file paths can be presented in long/short name form, |
| 115 | // and are not case sensitive on Windows. Also, the version string returned |
| 116 | // can include appended text, which we don't want to use during comparison |
| 117 | // against the blacklist. |
| 118 | static void NormalizeModule(Module* module); |
| 119 | |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 120 | // Constructs a ModuleEnumerator that will notify the provided |observer| once |
| 121 | // enumeration is complete. |observer| must outlive the ModuleEnumerator. |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 122 | explicit ModuleEnumerator(EnumerateModulesModel* observer); |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 123 | |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 124 | ~ModuleEnumerator(); |
| 125 | |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 126 | // Start scanning the loaded module list (if a scan is not already in |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 127 | // progress). This function does not block while reading the module list and |
| 128 | // will notify when done by calling the DoneScanning method of |observer_|. |
| 129 | void ScanNow(ModulesVector* list); |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 130 | |
chrisha | 6949a31c | 2016-10-18 21:49:37 | [diff] [blame] | 131 | // Sets |per_module_delay_| to zero, causing the modules to be inspected |
| 132 | // in realtime. |
| 133 | void SetPerModuleDelayToZero(); |
| 134 | |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 135 | private: |
[email protected] | 09fe8beb | 2010-12-16 10:03:01 | [diff] [blame] | 136 | FRIEND_TEST_ALL_PREFIXES(EnumerateModulesTest, CollapsePath); |
| 137 | |
fdoray | d4716407 | 2017-02-24 14:32:49 | [diff] [blame] | 138 | // This function posts a task to enumerate all modules asynchronously. Once |
| 139 | // the list of module filenames is populated, a delayed task is posted to scan |
| 140 | // the first module. |
chrisha | 6949a31c | 2016-10-18 21:49:37 | [diff] [blame] | 141 | void ScanImplStart(); |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 142 | |
chrisha | 6949a31c | 2016-10-18 21:49:37 | [diff] [blame] | 143 | // Inspects the module in |enumerated_modules_| at the given |index|. Gets |
| 144 | // module information, normalizes it, and collapses the path. This is an |
| 145 | // expensive operation and non-critical. Posts a delayed task to ScanImplDelay |
| 146 | // for the next module. When all modules are finished forwards directly to |
| 147 | // ScanImplFinish. |
| 148 | void ScanImplModule(size_t index); |
| 149 | |
| 150 | // Collects metrics and notifies the observer that the enumeration is complete |
| 151 | // by invoking DoneScanning on the UI thread. |
| 152 | void ScanImplFinish(); |
| 153 | |
| 154 | // Enumerate all modules loaded into the Chrome process. Creates empty |
| 155 | // entries in |enumerated_modules_| with a populated |location| field. |
[email protected] | cd60d2c5 | 2010-11-19 10:35:36 | [diff] [blame] | 156 | void EnumerateLoadedModules(); |
| 157 | |
chrisha | 6949a31c | 2016-10-18 21:49:37 | [diff] [blame] | 158 | // Enumerate all registered Windows shell extensions. Creates empty |
| 159 | // entries in |enumerated_modules_| with a populated |location| field. |
[email protected] | cd60d2c5 | 2010-11-19 10:35:36 | [diff] [blame] | 160 | void EnumerateShellExtensions(); |
| 161 | |
chrisha | 6949a31c | 2016-10-18 21:49:37 | [diff] [blame] | 162 | // Enumerate all registered Winsock LSP modules. Creates empty |
| 163 | // entries in |enumerated_modules_| with a populated |location| field. |
[email protected] | 47db01d | 2010-11-20 10:00:19 | [diff] [blame] | 164 | void EnumerateWinsockModules(); |
[email protected] | cd60d2c5 | 2010-11-19 10:35:36 | [diff] [blame] | 165 | |
| 166 | // Reads the registered shell extensions found under |parent| key in the |
chrisha | 6949a31c | 2016-10-18 21:49:37 | [diff] [blame] | 167 | // registry. Creates empty entries in |enumerated_modules_| with a populated |
| 168 | // |location| field. |
[email protected] | cd60d2c5 | 2010-11-19 10:35:36 | [diff] [blame] | 169 | void ReadShellExtensions(HKEY parent); |
| 170 | |
| 171 | // Given a |module|, initializes the structure and loads additional |
| 172 | // information using the location field of the module. |
| 173 | void PopulateModuleInformation(Module* module); |
| 174 | |
[email protected] | 47db01d | 2010-11-20 10:00:19 | [diff] [blame] | 175 | // Checks the module list to see if a |module| of the same type, location |
| 176 | // and name has been added before and if so, increments its duplication |
| 177 | // counter. If it doesn't appear in the list, it is added. |
| 178 | void AddToListWithoutDuplicating(const Module&); |
| 179 | |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 180 | // Builds up a vector of path values mapping to environment variable, |
| 181 | // with pairs like [c:\windows\, %systemroot%]. This is later used to |
| 182 | // collapse paths like c:\windows\system32 into %systemroot%\system32, which |
| 183 | // we can use for comparison against our blacklist (which uses only env vars). |
| 184 | // NOTE: The vector will not contain an exhaustive list of environment |
| 185 | // variables, only the ones currently found on the blacklist or ones that are |
| 186 | // likely to appear there. |
| 187 | void PreparePathMappings(); |
| 188 | |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 189 | // Reports (via UMA) a handful of high-level metrics regarding third party |
chrisha | 6949a31c | 2016-10-18 21:49:37 | [diff] [blame] | 190 | // modules in this process. Called by ScanImplFinish. |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 191 | void ReportThirdPartyMetrics(); |
| 192 | |
fdoray | d4716407 | 2017-02-24 14:32:49 | [diff] [blame] | 193 | // The TaskRunner to perform work in the background. |
| 194 | const scoped_refptr<base::TaskRunner> background_task_runner_; |
| 195 | |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 196 | // The vector of paths to %env_var%, used to account for differences in |
| 197 | // where people keep there files, c:\windows vs. d:\windows, etc. |
pmonette | 61e9340 | 2017-03-06 22:48:48 | [diff] [blame] | 198 | StringMapping path_mapping_; |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 199 | |
| 200 | // The vector containing all the enumerated modules (loaded and modules of |
| 201 | // interest). |
| 202 | ModulesVector* enumerated_modules_; |
| 203 | |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 204 | // The observer, which needs to be notified when the scan is complete. |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 205 | EnumerateModulesModel* observer_; |
| 206 | |
chrisha | 6949a31c | 2016-10-18 21:49:37 | [diff] [blame] | 207 | // The delay that is observed between module inspection tasks. This is |
| 208 | // currently 1 second, which means it takes several minutes to iterate over |
| 209 | // all modules on average. |
| 210 | base::TimeDelta per_module_delay_; |
| 211 | |
| 212 | // The amount of time taken for on-disk module inspection. Reported in |
| 213 | // ScanImplFinish. |
| 214 | base::TimeDelta enumeration_inspection_time_; |
| 215 | |
| 216 | // The total amount of time taken for module enumeration. Reported in |
| 217 | // ScanImplFinish. |
| 218 | base::TimeDelta enumeration_total_time_; |
| 219 | |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 220 | DISALLOW_COPY_AND_ASSIGN(ModuleEnumerator); |
| 221 | }; |
| 222 | |
| 223 | // This is a singleton class that enumerates all modules loaded into Chrome, |
| 224 | // both currently loaded modules (called DLLs on Windows) and modules 'of |
| 225 | // interest', such as WinSock LSP modules. This class also marks each module |
| 226 | // as benign or suspected bad or outright bad, using a supplied blacklist that |
| 227 | // is currently hard-coded. |
| 228 | // |
| 229 | // To use this class, grab the singleton pointer and call ScanNow(). |
| 230 | // Then wait to get notified through MODULE_LIST_ENUMERATED when the list is |
| 231 | // ready. |
| 232 | // |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 233 | // The member functions of this class may only be used from the UI thread. The |
fdoray | d4716407 | 2017-02-24 14:32:49 | [diff] [blame] | 234 | // bulk of the work is actually performed asynchronously in TaskScheduler with |
chrisha | 210ad10 | 2016-09-26 22:08:26 | [diff] [blame] | 235 | // CONTINUE_ON_SHUTDOWN semantics, as the WinCrypt functions can effectively |
| 236 | // block arbitrarily during shutdown. |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 237 | // |
| 238 | // TODO(chrisha): If this logic is ever extended to other platforms, then make |
| 239 | // this file generic for all platforms, and remove the precompiler logic in |
| 240 | // app_menu_icon_controller.*. |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 241 | class EnumerateModulesModel { |
| 242 | public: |
[email protected] | d04126a | 2013-06-06 15:28:33 | [diff] [blame] | 243 | // UMA histogram constants. |
| 244 | enum UmaModuleConflictHistogramOptions { |
| 245 | ACTION_BUBBLE_SHOWN = 0, |
| 246 | ACTION_BUBBLE_LEARN_MORE, |
| 247 | ACTION_MENU_LEARN_MORE, |
pmonette | cfe91abf | 2017-02-25 00:11:11 | [diff] [blame] | 248 | ACTION_BOUNDARY, // Must be the last value. |
[email protected] | d04126a | 2013-06-06 15:28:33 | [diff] [blame] | 249 | }; |
| 250 | |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 251 | // Observer class used to determine when a scan has completed and when any |
| 252 | // associated UI elements have been dismissed. |
| 253 | class Observer { |
| 254 | public: |
| 255 | // Invoked when EnumerateModulesModel has completed a scan of modules. |
| 256 | virtual void OnScanCompleted() {} |
| 257 | |
| 258 | // Invoked when a user has acknowledged incompatible modules found in a |
| 259 | // module scan. |
| 260 | virtual void OnConflictsAcknowledged() {} |
| 261 | |
| 262 | protected: |
| 263 | virtual ~Observer() = default; |
| 264 | }; |
| 265 | |
| 266 | // Returns the singleton instance of this class. |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 267 | static EnumerateModulesModel* GetInstance(); |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 268 | |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 269 | // Adds an |observer| to the enumerator. Callbacks will occur on the UI |
| 270 | // thread. |
| 271 | void AddObserver(Observer* observer); |
| 272 | |
| 273 | // Removes an |observer| from the enumerator. |
| 274 | void RemoveObserver(Observer* observer); |
| 275 | |
[email protected] | cfc23434 | 2011-04-08 12:03:50 | [diff] [blame] | 276 | // Returns true if we should show the conflict notification. The conflict |
| 277 | // notification is only shown once during the lifetime of the process. |
| 278 | bool ShouldShowConflictWarning() const; |
| 279 | |
| 280 | // Called when the user has acknowledged the conflict notification. |
| 281 | void AcknowledgeConflictNotification(); |
| 282 | |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 283 | // Returns the number of suspected bad modules found in the last scan. |
| 284 | // Returns 0 if no scan has taken place yet. |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 285 | int suspected_bad_modules_detected() const; |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 286 | |
| 287 | // Returns the number of confirmed bad modules found in the last scan. |
| 288 | // Returns 0 if no scan has taken place yet. |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 289 | int confirmed_bad_modules_detected() const; |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 290 | |
[email protected] | d04126a | 2013-06-06 15:28:33 | [diff] [blame] | 291 | // Returns how many modules to notify the user about. |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 292 | int modules_to_notify_about() const; |
[email protected] | d80268a5 | 2011-01-06 08:57:45 | [diff] [blame] | 293 | |
[email protected] | d04126a | 2013-06-06 15:28:33 | [diff] [blame] | 294 | // Checks to see if a scanning task should be started and sets one off, if so. |
chrisha | 6949a31c | 2016-10-18 21:49:37 | [diff] [blame] | 295 | // This will cause ScanNow to be invoked in background mode. |
[email protected] | d04126a | 2013-06-06 15:28:33 | [diff] [blame] | 296 | void MaybePostScanningTask(); |
| 297 | |
chrisha | 6949a31c | 2016-10-18 21:49:37 | [diff] [blame] | 298 | // Asynchronously start the scan for the loaded module list. If |
| 299 | // |background_mode| is true the scan will happen slowly over a process of |
| 300 | // minutes, spread across dozens or even hundreds of delayed tasks. Otherwise |
| 301 | // the processing will occur in a single task. |
| 302 | void ScanNow(bool background_mode); |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 303 | |
| 304 | // Gets the whole module list as a ListValue. |
jdoerrie | cb205a5 | 2017-06-08 16:16:44 | [diff] [blame^] | 305 | std::unique_ptr<base::ListValue> GetModuleList(); |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 306 | |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 307 | // Returns the site to which the user should be taken when the conflict bubble |
| 308 | // or app menu item is clicked. For now this is simply chrome://conflicts, |
| 309 | // which contains detailed information about conflicts. Returns an empty URL |
| 310 | // if there are no conficts. May only be called on UI thread. |
| 311 | GURL GetConflictUrl(); |
[email protected] | d04126a | 2013-06-06 15:28:33 | [diff] [blame] | 312 | |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 313 | private: |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 314 | friend class ModuleEnumerator; |
| 315 | |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 316 | // Private to enforce singleton nature of this class. |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 317 | EnumerateModulesModel(); |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 318 | ~EnumerateModulesModel(); |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 319 | |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 320 | // Called on the UI thread when the helper class is done scanning. The |
| 321 | // ModuleEnumerator that calls this must not do any work after causing this |
| 322 | // function to be called, as the EnumerateModulesModel may delete the |
| 323 | // ModuleEnumerator. |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 324 | void DoneScanning(); |
| 325 | |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 326 | // The vector containing all the modules enumerated. Will be normalized and |
fdoray | d4716407 | 2017-02-24 14:32:49 | [diff] [blame] | 327 | // any bad modules will be marked. Written to from the background TaskRunner |
| 328 | // by the |module_enumerator_|, read from on the UI thread by this class. |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 329 | ModuleEnumerator::ModulesVector enumerated_modules_; |
| 330 | |
fdoray | d4716407 | 2017-02-24 14:32:49 | [diff] [blame] | 331 | // The object responsible for enumerating the modules on a background |
| 332 | // TaskRunner. Only accessed from the UI thread. |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 333 | std::unique_ptr<ModuleEnumerator> module_enumerator_; |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 334 | |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 335 | // Whether the conflict notification has been acknowledged by the user. Only |
| 336 | // modified on the UI thread. |
[email protected] | cfc23434 | 2011-04-08 12:03:50 | [diff] [blame] | 337 | bool conflict_notification_acknowledged_; |
| 338 | |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 339 | // The number of confirmed bad modules (not including suspected bad ones) |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 340 | // found during last scan. Only modified on the UI thread. |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 341 | int confirmed_bad_modules_detected_; |
| 342 | |
[email protected] | d04126a | 2013-06-06 15:28:33 | [diff] [blame] | 343 | // The number of bad modules the user needs to be aggressively notified about. |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 344 | // Only modified on the UI thread. |
[email protected] | d04126a | 2013-06-06 15:28:33 | [diff] [blame] | 345 | int modules_to_notify_about_; |
| 346 | |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 347 | // The number of suspected bad modules (not including confirmed bad ones) |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 348 | // found during last scan. Only modified on the UI thread. |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 349 | int suspected_bad_modules_detected_; |
| 350 | |
chrisha | 8645b589 | 2016-08-30 18:50:26 | [diff] [blame] | 351 | base::ObserverList<Observer> observers_; |
| 352 | |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 353 | DISALLOW_COPY_AND_ASSIGN(EnumerateModulesModel); |
| 354 | }; |
| 355 | |
pmonette | 23c8fb7e | 2016-06-27 20:45:11 | [diff] [blame] | 356 | #endif // CHROME_BROWSER_WIN_ENUMERATE_MODULES_MODEL_H_ |