| Index: chrome/browser/enumerate_modules_model_win.h
|
| diff --git a/chrome/browser/enumerate_modules_model_win.h b/chrome/browser/enumerate_modules_model_win.h
|
| index d40a81e7d67f09cbd07ff338f5294b04c8f869fa..f3a452cf9a326b88457b9e6f310026ed765c8fd0 100644
|
| --- a/chrome/browser/enumerate_modules_model_win.h
|
| +++ b/chrome/browser/enumerate_modules_model_win.h
|
| @@ -8,10 +8,12 @@
|
| #include <utility>
|
| #include <vector>
|
|
|
| +#include "base/callback.h"
|
| #include "base/gtest_prod_util.h"
|
| #include "base/macros.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/singleton.h"
|
| +#include "base/observer_list.h"
|
| #include "base/strings/string16.h"
|
| #include "base/timer/timer.h"
|
| #include "content/public/browser/browser_thread.h"
|
| @@ -115,17 +117,6 @@ class ModuleEnumerator : public base::RefCountedThreadSafe<ModuleEnumerator> {
|
| // A vector typedef of all modules enumerated.
|
| typedef std::vector<Module> ModulesVector;
|
|
|
| - // A structure we populate with the blacklist entries.
|
| - struct BlacklistEntry {
|
| - const char* filename;
|
| - const char* location;
|
| - const char* desc_or_signer;
|
| - const char* version_from; // Version where conflict started.
|
| - const char* version_to; // First version that works.
|
| - OperatingSystem os; // Bitmask, representing what OS this entry applies to.
|
| - RecommendedAction help_tip;
|
| - };
|
| -
|
| // A static function that normalizes the module information in the |module|
|
| // struct. Module information needs to be normalized before comparing against
|
| // the blacklist. This is because the same module can be described in many
|
| @@ -135,10 +126,6 @@ class ModuleEnumerator : public base::RefCountedThreadSafe<ModuleEnumerator> {
|
| // against the blacklist.
|
| static void NormalizeModule(Module* module);
|
|
|
| - // A static function that checks whether |module| has been |blacklisted|.
|
| - static ModuleStatus Match(const Module& module,
|
| - const BlacklistEntry& blacklisted);
|
| -
|
| explicit ModuleEnumerator(EnumerateModulesModel* observer);
|
|
|
| // Start scanning the loaded module list (if a scan is not already in
|
| @@ -158,9 +145,6 @@ class ModuleEnumerator : public base::RefCountedThreadSafe<ModuleEnumerator> {
|
| friend class base::RefCountedThreadSafe<ModuleEnumerator>;
|
| ~ModuleEnumerator();
|
|
|
| - // The (currently) hard coded blacklist of known bad modules.
|
| - static const BlacklistEntry kModuleBlacklist[];
|
| -
|
| // This function does the actual file scanning work on the FILE thread (or
|
| // block the main thread when in limited_mode). It enumerates all loaded
|
| // modules in the process and other modules of interest, such as the
|
| @@ -205,10 +189,6 @@ class ModuleEnumerator : public base::RefCountedThreadSafe<ModuleEnumerator> {
|
| // based on the |path_mapping_| vector.
|
| void CollapsePath(Module* module);
|
|
|
| - // Takes each module in the |enumerated_modules_| vector and matches it
|
| - // against a fixed blacklist of bad and suspected bad modules.
|
| - void MatchAgainstBlacklist();
|
| -
|
| // This function executes on the UI thread when the scanning and matching
|
| // process is done. It notifies the observer.
|
| void ReportBack();
|
| @@ -218,8 +198,13 @@ class ModuleEnumerator : public base::RefCountedThreadSafe<ModuleEnumerator> {
|
| base::string16 GetSubjectNameFromDigitalSignature(
|
| const base::FilePath& filename);
|
|
|
| + // Reports (via UMA) a handful of high-level metrics regarding third party
|
| + // modules in this process. Called by ScanImpl after modules have been
|
| + // enmerated and processed.
|
| + void ReportThirdPartyMetrics();
|
| +
|
| // The typedef for the vector that maps a regular file path to %env_var%.
|
| - typedef std::vector< std::pair<base::string16, base::string16> > PathMapping;
|
| + typedef std::vector<std::pair<base::string16, base::string16>> PathMapping;
|
|
|
| // The vector of paths to %env_var%, used to account for differences in
|
| // where people keep there files, c:\windows vs. d:\windows, etc.
|
| @@ -229,7 +214,7 @@ class ModuleEnumerator : public base::RefCountedThreadSafe<ModuleEnumerator> {
|
| // interest).
|
| ModulesVector* enumerated_modules_;
|
|
|
| - // The observer, who needs to be notified when we are done.
|
| + // The observers, who need to be notified when the scan is complete.
|
| EnumerateModulesModel* observer_;
|
|
|
| // See limited_mode below.
|
| @@ -264,8 +249,39 @@ class EnumerateModulesModel {
|
| ACTION_BOUNDARY, // Must be the last value.
|
| };
|
|
|
| + // Observer class used to receive the list of modules when enumeration is
|
| + // finished.
|
| + class Observer {
|
| + public:
|
| + // Invoked when EnumerateModulesModel has completed a scan of modules.
|
| + virtual void OnScanCompleted(bool limited_mode) {}
|
| +
|
| + // Invoked when a user has acknowledge incompatible modules found in a
|
| + // module scan.
|
| + virtual void OnConflictsAcknowledged() {}
|
| +
|
| + protected:
|
| + virtual ~Observer() = default;
|
| + };
|
| +
|
| + EnumerateModulesModel();
|
| + virtual ~EnumerateModulesModel();
|
| +
|
| + // Returns the singleton instance of this class.
|
| static EnumerateModulesModel* GetInstance();
|
|
|
| + // Adds an |observer| to the enumerator. May only be called from the UI thread
|
| + // and callbacks will also occur on the UI thread.
|
| + void AddObserver(Observer* observer) {
|
| + observers_.AddObserver(observer);
|
| + }
|
| +
|
| + // Removes an |observer| from the enumerator. May only be called from the UI
|
| + // thread and callbacks will also occur on the UI thread.
|
| + void RemoveObserver(Observer* observer) {
|
| + observers_.RemoveObserver(observer);
|
| + }
|
| +
|
| // Returns true if we should show the conflict notification. The conflict
|
| // notification is only shown once during the lifetime of the process.
|
| bool ShouldShowConflictWarning() const;
|
| @@ -304,36 +320,33 @@ class EnumerateModulesModel {
|
| void ScanNow();
|
|
|
| // Gets the whole module list as a ListValue.
|
| - base::ListValue* GetModuleList() const;
|
| + base::ListValue* GetModuleList();
|
|
|
| - // Gets the Help Center URL for the first *notable* conflict module that we've
|
| - // elected to notify the user about.
|
| - GURL GetFirstNotableConflict();
|
| + // Returns the site to which the user should be taken when the conflict bubble
|
| + // or app menu item is clicked. For now this is simply chrome://conflicts,
|
| + // which contains detailed information about conflicts. Returns an empty URL
|
| + // if there are no conficts.
|
| + GURL GetConflictUrl();
|
|
|
| private:
|
| - friend struct base::DefaultSingletonTraits<EnumerateModulesModel>;
|
| friend class ModuleEnumerator;
|
|
|
| - EnumerateModulesModel();
|
| - virtual ~EnumerateModulesModel();
|
| -
|
| // Called on the UI thread when the helper class is done scanning.
|
| void DoneScanning();
|
|
|
| - // Constructs a Help Center article URL for help with a particular module.
|
| - // The module must have the SEE_LINK attribute for |recommended_action| set,
|
| - // otherwise this returns a blank string.
|
| - GURL ConstructHelpCenterUrl(const ModuleEnumerator::Module& module) const;
|
| + // Used to protect state that can be accessed from both the UI and FILE
|
| + // threads.
|
| + base::Lock lock_;
|
|
|
| // The vector containing all the modules enumerated. Will be normalized and
|
| - // any bad modules will be marked.
|
| + // any bad modules will be marked. Under lock_.
|
| ModuleEnumerator::ModulesVector enumerated_modules_;
|
|
|
| // The object responsible for enumerating the modules on the File thread.
|
| scoped_refptr<ModuleEnumerator> module_enumerator_;
|
|
|
| - // When this singleton object is constructed we go and fire off this timer to
|
| - // start scanning for modules after a certain amount of time has passed.
|
| + // When MaybePostScanningTask is called this timer is set to start scanning
|
| + // modules after a certain amount of time has passed.
|
| base::OneShotTimer check_modules_timer_;
|
|
|
| // While normally |false|, this mode can be set to indicate that the scanning
|
| @@ -343,7 +356,7 @@ class EnumerateModulesModel {
|
| // runs without firing up all necessary Chrome services first.
|
| bool limited_mode_;
|
|
|
| - // True if we are currently scanning for modules.
|
| + // True if we are currently scanning for modules. Under lock_.
|
| bool scanning_;
|
|
|
| // Whether the conflict notification has been acknowledged by the user.
|
| @@ -360,6 +373,8 @@ class EnumerateModulesModel {
|
| // found during last scan.
|
| int suspected_bad_modules_detected_;
|
|
|
| + base::ObserverList<Observer> observers_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(EnumerateModulesModel);
|
| };
|
|
|
|
|