| 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/compiler_specific.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 13 #include "components/keyed_service/core/keyed_service.h" |
| 14 #include "extensions/common/extension_set.h" | 14 #include "extensions/common/extension_set.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 class BrowserContext; | 17 class BrowserContext; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace extensions { | 20 namespace extensions { |
| 21 class Extension; | 21 class Extension; |
| 22 class ExtensionRegistryObserver; | 22 class ExtensionRegistryObserver; |
| 23 | 23 |
| 24 // ExtensionRegistry holds sets of the installed extensions for a given | 24 // ExtensionRegistry holds sets of the installed extensions for a given |
| 25 // BrowserContext. An incognito browser context and its master browser context | 25 // BrowserContext. An incognito browser context and its master browser context |
| 26 // share a single registry. | 26 // share a single registry. |
| 27 class ExtensionRegistry : public BrowserContextKeyedService { | 27 class ExtensionRegistry : public KeyedService { |
| 28 public: | 28 public: |
| 29 // Flags to pass to GetExtensionById() to select which sets to look in. | 29 // Flags to pass to GetExtensionById() to select which sets to look in. |
| 30 enum IncludeFlag { | 30 enum IncludeFlag { |
| 31 NONE = 0, | 31 NONE = 0, |
| 32 ENABLED = 1 << 0, | 32 ENABLED = 1 << 0, |
| 33 DISABLED = 1 << 1, | 33 DISABLED = 1 << 1, |
| 34 TERMINATED = 1 << 2, | 34 TERMINATED = 1 << 2, |
| 35 BLACKLISTED = 1 << 3, | 35 BLACKLISTED = 1 << 3, |
| 36 EVERYTHING = (1 << 4) - 1, | 36 EVERYTHING = (1 << 4) - 1, |
| 37 }; | 37 }; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 // Removes all extensions from all sets. | 102 // Removes all extensions from all sets. |
| 103 void ClearAll(); | 103 void ClearAll(); |
| 104 | 104 |
| 105 // Sets a callback to run when the disabled extension set is modified. | 105 // Sets a callback to run when the disabled extension set is modified. |
| 106 // TODO(jamescook): This is too specific for a generic registry; find some | 106 // TODO(jamescook): This is too specific for a generic registry; find some |
| 107 // other way to do this. | 107 // other way to do this. |
| 108 void SetDisabledModificationCallback( | 108 void SetDisabledModificationCallback( |
| 109 const ExtensionSet::ModificationCallback& callback); | 109 const ExtensionSet::ModificationCallback& callback); |
| 110 | 110 |
| 111 // BrowserContextKeyedService implementation: | 111 // KeyedService implementation: |
| 112 virtual void Shutdown() OVERRIDE; | 112 virtual void Shutdown() OVERRIDE; |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 // Extensions that are installed, enabled and not terminated. | 115 // Extensions that are installed, enabled and not terminated. |
| 116 ExtensionSet enabled_extensions_; | 116 ExtensionSet enabled_extensions_; |
| 117 | 117 |
| 118 // Extensions that are installed and disabled. | 118 // Extensions that are installed and disabled. |
| 119 ExtensionSet disabled_extensions_; | 119 ExtensionSet disabled_extensions_; |
| 120 | 120 |
| 121 // Extensions that are installed and terminated. | 121 // Extensions that are installed and terminated. |
| 122 ExtensionSet terminated_extensions_; | 122 ExtensionSet terminated_extensions_; |
| 123 | 123 |
| 124 // Extensions that are installed and blacklisted. Generally these shouldn't be | 124 // Extensions that are installed and blacklisted. Generally these shouldn't be |
| 125 // considered as installed by the extension platform: we only keep them around | 125 // considered as installed by the extension platform: we only keep them around |
| 126 // so that if extensions are blacklisted by mistake they can easily be | 126 // so that if extensions are blacklisted by mistake they can easily be |
| 127 // un-blacklisted. | 127 // un-blacklisted. |
| 128 ExtensionSet blacklisted_extensions_; | 128 ExtensionSet blacklisted_extensions_; |
| 129 | 129 |
| 130 ObserverList<ExtensionRegistryObserver> observers_; | 130 ObserverList<ExtensionRegistryObserver> observers_; |
| 131 | 131 |
| 132 DISALLOW_COPY_AND_ASSIGN(ExtensionRegistry); | 132 DISALLOW_COPY_AND_ASSIGN(ExtensionRegistry); |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 } // namespace extensions | 135 } // namespace extensions |
| 136 | 136 |
| 137 #endif // EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_ | 137 #endif // EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_ |
| OLD | NEW |