#include <list>
-#include "chrome/browser/extensions/install_observer.h"
+#include "base/scoped_observer.h"
+#include "extensions/browser/extension_registry_observer.h"
#include "extensions/common/manifest_handlers/shared_module_info.h"
namespace content {
}
namespace extensions {
-
class Extension;
class ExtensionSet;
+class ExtensionRegistry;
-class SharedModuleService : public InstallObserver {
+class SharedModuleService : public ExtensionRegistryObserver {
public:
enum ImportStatus {
// No imports needed.
};
explicit SharedModuleService(content::BrowserContext* context);
- virtual ~SharedModuleService();
+ ~SharedModuleService() override;
// Checks an extension's imports. Imports that are not installed are stored
// in |missing_modules|, and imports that are out of date are stored in
// |outdated_modules|.
ImportStatus CheckImports(
- const extensions::Extension* extension,
+ const Extension* extension,
std::list<SharedModuleInfo::ImportInfo>* missing_modules,
std::list<SharedModuleInfo::ImportInfo>* outdated_modules);
// Checks an extension's shared module imports to see if they are satisfied.
// If they are not, this function adds the dependencies to the pending install
// list if |extension| came from the webstore.
- ImportStatus SatisfyImports(const extensions::Extension* extension);
+ ImportStatus SatisfyImports(const Extension* extension);
- private:
// Returns a set of extensions that import a given extension.
- scoped_ptr<const ExtensionSet> GetDependentExtensions(
- const Extension* extension);
+ scoped_ptr<ExtensionSet> GetDependentExtensions(const Extension* extension);
- // Uninstalls shared modules that were only referenced by |extension|.
- void PruneSharedModulesOnUninstall(const Extension* extension);
+ private:
+ // Uninstall shared modules which are not used by other extensions.
+ void PruneSharedModules();
- // InstallObserver implementation:
- virtual void OnExtensionUninstalled(const Extension* extension) OVERRIDE;
- virtual void OnShutdown() OVERRIDE;
+ // ExtensionRegistryObserver implementation.
+ void OnExtensionInstalled(content::BrowserContext* browser_context,
+ const Extension* extension,
+ bool is_update) override;
+ void OnExtensionUninstalled(content::BrowserContext* browser_context,
+ const Extension* extension,
+ extensions::UninstallReason reason) override;
- // The context associated with this SharedModuleService.
- content::BrowserContext* context_;
+ ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
+ extension_registry_observer_;
- // Whether or not we are actively observing installs.
- bool observing_;
+ // The context associated with this SharedModuleService.
+ content::BrowserContext* browser_context_;
DISALLOW_COPY_AND_ASSIGN(SharedModuleService);
};