| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_EXTENSIONS_SHARED_MODULE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SHARED_MODULE_SERVICE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_SHARED_MODULE_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SHARED_MODULE_SERVICE_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/scoped_observer.h" | 11 #include "base/scoped_observer.h" |
| 12 #include "chrome/browser/extensions/install_gate.h" |
| 12 #include "extensions/browser/extension_registry_observer.h" | 13 #include "extensions/browser/extension_registry_observer.h" |
| 13 #include "extensions/common/manifest_handlers/shared_module_info.h" | 14 #include "extensions/common/manifest_handlers/shared_module_info.h" |
| 14 | 15 |
| 15 namespace content { | 16 namespace content { |
| 16 class BrowserContext; | 17 class BrowserContext; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace extensions { | 20 namespace extensions { |
| 20 class Extension; | 21 class Extension; |
| 21 class ExtensionSet; | 22 class ExtensionSet; |
| 22 class ExtensionRegistry; | 23 class ExtensionRegistry; |
| 23 | 24 |
| 24 class SharedModuleService : public ExtensionRegistryObserver { | 25 class SharedModuleService : public ExtensionRegistryObserver, |
| 26 public InstallGate { |
| 25 public: | 27 public: |
| 26 enum ImportStatus { | 28 enum ImportStatus { |
| 27 // No imports needed. | 29 // No imports needed. |
| 28 IMPORT_STATUS_OK, | 30 IMPORT_STATUS_OK, |
| 29 | 31 |
| 30 // Imports are needed, but can be satisfied (i.e., there are missing or | 32 // Imports are needed, but can be satisfied (i.e., there are missing or |
| 31 // outdated imports for a webstore extension). | 33 // outdated imports for a webstore extension). |
| 32 IMPORT_STATUS_UNSATISFIED, | 34 IMPORT_STATUS_UNSATISFIED, |
| 33 | 35 |
| 34 // Imports are needed, and can't be satisfied (i.e., missing or outdated | 36 // Imports are needed, and can't be satisfied (i.e., missing or outdated |
| (...skipping 14 matching lines...) Expand all Loading... |
| 49 | 51 |
| 50 // Checks an extension's shared module imports to see if they are satisfied. | 52 // Checks an extension's shared module imports to see if they are satisfied. |
| 51 // If they are not, this function adds the dependencies to the pending install | 53 // If they are not, this function adds the dependencies to the pending install |
| 52 // list if |extension| came from the webstore. | 54 // list if |extension| came from the webstore. |
| 53 ImportStatus SatisfyImports(const Extension* extension); | 55 ImportStatus SatisfyImports(const Extension* extension); |
| 54 | 56 |
| 55 // Returns a set of extensions that import a given extension. | 57 // Returns a set of extensions that import a given extension. |
| 56 std::unique_ptr<ExtensionSet> GetDependentExtensions( | 58 std::unique_ptr<ExtensionSet> GetDependentExtensions( |
| 57 const Extension* extension); | 59 const Extension* extension); |
| 58 | 60 |
| 61 // InstallGate: |
| 62 Action ShouldDelay(const Extension* extension, |
| 63 bool install_immediately) override; |
| 64 |
| 59 private: | 65 private: |
| 60 // Uninstall shared modules which are not used by other extensions. | 66 // Uninstall shared modules which are not used by other extensions. |
| 61 void PruneSharedModules(); | 67 void PruneSharedModules(); |
| 62 | 68 |
| 63 // ExtensionRegistryObserver implementation. | 69 // ExtensionRegistryObserver implementation. |
| 64 void OnExtensionInstalled(content::BrowserContext* browser_context, | 70 void OnExtensionInstalled(content::BrowserContext* browser_context, |
| 65 const Extension* extension, | 71 const Extension* extension, |
| 66 bool is_update) override; | 72 bool is_update) override; |
| 67 void OnExtensionUninstalled(content::BrowserContext* browser_context, | 73 void OnExtensionUninstalled(content::BrowserContext* browser_context, |
| 68 const Extension* extension, | 74 const Extension* extension, |
| 69 extensions::UninstallReason reason) override; | 75 extensions::UninstallReason reason) override; |
| 70 | 76 |
| 71 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 77 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 72 extension_registry_observer_; | 78 extension_registry_observer_; |
| 73 | 79 |
| 74 // The context associated with this SharedModuleService. | 80 // The context associated with this SharedModuleService. |
| 75 content::BrowserContext* browser_context_; | 81 content::BrowserContext* browser_context_; |
| 76 | 82 |
| 77 DISALLOW_COPY_AND_ASSIGN(SharedModuleService); | 83 DISALLOW_COPY_AND_ASSIGN(SharedModuleService); |
| 78 }; | 84 }; |
| 79 | 85 |
| 80 } // namespace extensions | 86 } // namespace extensions |
| 81 | 87 |
| 82 #endif // CHROME_BROWSER_EXTENSIONS_SHARED_MODULE_SERVICE_H_ | 88 #endif // CHROME_BROWSER_EXTENSIONS_SHARED_MODULE_SERVICE_H_ |
| OLD | NEW |