| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_ |
| 6 #define EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 11 #include "extensions/common/extension_set.h" | 13 #include "extensions/common/extension_set.h" |
| 12 | 14 |
| 15 namespace content { |
| 16 class BrowserContext; |
| 17 } |
| 18 |
| 13 namespace extensions { | 19 namespace extensions { |
| 14 class Extension; | 20 class Extension; |
| 15 | 21 |
| 16 // ExtensionRegistry holds sets of the installed extensions for a given | 22 // ExtensionRegistry holds sets of the installed extensions for a given |
| 17 // BrowserContext. | 23 // BrowserContext. An incognito browser context and its master browser context |
| 18 // TODO(jamescook): Convert this to a BrowserContextKeyedService. | 24 // share a single registry. |
| 19 class ExtensionRegistry { | 25 class ExtensionRegistry : public BrowserContextKeyedService { |
| 20 public: | 26 public: |
| 21 ExtensionRegistry(); | 27 ExtensionRegistry(); |
| 22 ~ExtensionRegistry(); | 28 virtual ~ExtensionRegistry(); |
| 29 |
| 30 // Returns the instance for the given |browser_context|. |
| 31 static ExtensionRegistry* Get(content::BrowserContext* browser_context); |
| 23 | 32 |
| 24 // NOTE: These sets are *eventually* mututally exclusive, but an extension can | 33 // NOTE: These sets are *eventually* mututally exclusive, but an extension can |
| 25 // appear in two sets for short periods of time. | 34 // appear in two sets for short periods of time. |
| 26 const ExtensionSet& enabled_extensions() const { | 35 const ExtensionSet& enabled_extensions() const { |
| 27 return enabled_extensions_; | 36 return enabled_extensions_; |
| 28 } | 37 } |
| 29 const ExtensionSet& disabled_extensions() const { | 38 const ExtensionSet& disabled_extensions() const { |
| 30 return disabled_extensions_; | 39 return disabled_extensions_; |
| 31 } | 40 } |
| 32 const ExtensionSet& terminated_extensions() const { | 41 const ExtensionSet& terminated_extensions() const { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 63 | 72 |
| 64 // Removes all extensions from all sets. | 73 // Removes all extensions from all sets. |
| 65 void ClearAll(); | 74 void ClearAll(); |
| 66 | 75 |
| 67 // Sets a callback to run when the disabled extension set is modified. | 76 // Sets a callback to run when the disabled extension set is modified. |
| 68 // TODO(jamescook): This is too specific for a generic registry; find some | 77 // TODO(jamescook): This is too specific for a generic registry; find some |
| 69 // other way to do this. | 78 // other way to do this. |
| 70 void SetDisabledModificationCallback( | 79 void SetDisabledModificationCallback( |
| 71 const ExtensionSet::ModificationCallback& callback); | 80 const ExtensionSet::ModificationCallback& callback); |
| 72 | 81 |
| 82 // BrowserContextKeyedService implementation: |
| 83 virtual void Shutdown() OVERRIDE; |
| 84 |
| 73 private: | 85 private: |
| 74 // Extensions that are installed, enabled and not terminated. | 86 // Extensions that are installed, enabled and not terminated. |
| 75 ExtensionSet enabled_extensions_; | 87 ExtensionSet enabled_extensions_; |
| 76 | 88 |
| 77 // Extensions that are installed and disabled. | 89 // Extensions that are installed and disabled. |
| 78 ExtensionSet disabled_extensions_; | 90 ExtensionSet disabled_extensions_; |
| 79 | 91 |
| 80 // Extensions that are installed and terminated. | 92 // Extensions that are installed and terminated. |
| 81 ExtensionSet terminated_extensions_; | 93 ExtensionSet terminated_extensions_; |
| 82 | 94 |
| 83 // Extensions that are installed and blacklisted. Generally these shouldn't be | 95 // Extensions that are installed and blacklisted. Generally these shouldn't be |
| 84 // considered as installed by the extension platform: we only keep them around | 96 // considered as installed by the extension platform: we only keep them around |
| 85 // so that if extensions are blacklisted by mistake they can easily be | 97 // so that if extensions are blacklisted by mistake they can easily be |
| 86 // un-blacklisted. | 98 // un-blacklisted. |
| 87 ExtensionSet blacklisted_extensions_; | 99 ExtensionSet blacklisted_extensions_; |
| 88 | 100 |
| 89 DISALLOW_COPY_AND_ASSIGN(ExtensionRegistry); | 101 DISALLOW_COPY_AND_ASSIGN(ExtensionRegistry); |
| 90 }; | 102 }; |
| 91 | 103 |
| 92 } // namespace extensions | 104 } // namespace extensions |
| 93 | 105 |
| 94 #endif // EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_ | 106 #endif // EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_ |
| OLD | NEW |