1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_WIN_CONFLICTS_MODULE_DATABASE_OBSERVER_H_
6 #define CHROME_BROWSER_WIN_CONFLICTS_MODULE_DATABASE_OBSERVER_H_
7 
8 struct ModuleInfoKey;
9 struct ModuleInfoData;
10 
11 class ModuleDatabaseObserver {
12  public:
13   // Invoked when a new module is found either by loading into a Chrome process,
14   // or by being registered as a shell extension or IME. Only invoked after the
15   // module was inspected on disk.
16   // Note that this is not invoked multiple times if the module subsequently
17   // loads into a different process type.
OnNewModuleFound(const ModuleInfoKey & module_key,const ModuleInfoData & module_data)18   virtual void OnNewModuleFound(const ModuleInfoKey& module_key,
19                                 const ModuleInfoData& module_data) {}
20 
21   // Invoked when a registered module (shell extension or IME) that already
22   // triggered a OnNewModuleFound() call finally loads into Chrome.
OnKnownModuleLoaded(const ModuleInfoKey & module_key,const ModuleInfoData & module_data)23   virtual void OnKnownModuleLoaded(const ModuleInfoKey& module_key,
24                                    const ModuleInfoData& module_data) {}
25 
26   // Invoked when the ModuleDatabase becomes idle. This means that the
27   // ModuleDatabase stopped inspecting modules and it received no new module
28   // events in the last 10 seconds.
OnModuleDatabaseIdle()29   virtual void OnModuleDatabaseIdle() {}
30 
31  protected:
32   virtual ~ModuleDatabaseObserver() = default;
33 };
34 
35 class ModuleDatabaseEventSource {
36  public:
37   virtual void AddObserver(ModuleDatabaseObserver* observer) = 0;
38   virtual void RemoveObserver(ModuleDatabaseObserver* observer) = 0;
39 
40  protected:
41   virtual ~ModuleDatabaseEventSource() = default;
42 };
43 
44 #endif  // CHROME_BROWSER_WIN_CONFLICTS_MODULE_DATABASE_OBSERVER_H_
45