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" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 class Extension; | 26 class Extension; |
27 class ExtensionRegistryObserver; | 27 class ExtensionRegistryObserver; |
28 | 28 |
29 // ExtensionRegistry holds sets of the installed extensions for a given | 29 // ExtensionRegistry holds sets of the installed extensions for a given |
30 // BrowserContext. An incognito browser context and its master browser context | 30 // BrowserContext. An incognito browser context and its master browser context |
31 // share a single registry. | 31 // share a single registry. |
32 class ExtensionRegistry : public KeyedService { | 32 class ExtensionRegistry : public KeyedService { |
33 public: | 33 public: |
34 // Flags to pass to GetExtensionById() to select which sets to look in. | 34 // Flags to pass to GetExtensionById() to select which sets to look in. |
35 enum IncludeFlag { | 35 enum IncludeFlag { |
36 NONE = 0, | 36 NONE = 0, |
not at google - send to devlin
2014/11/12 18:23:01
Did clang-format really do this? Damn :( oh well.
Mike Lerman
2014/11/12 20:58:42
git cl format - ya it did :*(
| |
37 ENABLED = 1 << 0, | 37 ENABLED = 1 << 0, |
38 DISABLED = 1 << 1, | 38 DISABLED = 1 << 1, |
39 TERMINATED = 1 << 2, | 39 TERMINATED = 1 << 2, |
40 BLACKLISTED = 1 << 3, | 40 BLACKLISTED = 1 << 3, |
41 EVERYTHING = (1 << 4) - 1, | 41 LOCKED = 1 << 4, |
42 EVERYTHING = (1 << 5) - 1, | |
42 }; | 43 }; |
43 | 44 |
44 explicit ExtensionRegistry(content::BrowserContext* browser_context); | 45 explicit ExtensionRegistry(content::BrowserContext* browser_context); |
45 ~ExtensionRegistry() override; | 46 ~ExtensionRegistry() override; |
46 | 47 |
47 // Returns the instance for the given |browser_context|. | 48 // Returns the instance for the given |browser_context|. |
48 static ExtensionRegistry* Get(content::BrowserContext* browser_context); | 49 static ExtensionRegistry* Get(content::BrowserContext* browser_context); |
49 | 50 |
50 content::BrowserContext* browser_context() const { return browser_context_; } | 51 content::BrowserContext* browser_context() const { return browser_context_; } |
51 | 52 |
52 // NOTE: These sets are *eventually* mutually exclusive, but an extension can | 53 // NOTE: These sets are *eventually* mutually exclusive, but an extension can |
53 // appear in two sets for short periods of time. | 54 // appear in two sets for short periods of time. |
54 const ExtensionSet& enabled_extensions() const { | 55 const ExtensionSet& enabled_extensions() const { |
55 return enabled_extensions_; | 56 return enabled_extensions_; |
56 } | 57 } |
57 const ExtensionSet& disabled_extensions() const { | 58 const ExtensionSet& disabled_extensions() const { |
58 return disabled_extensions_; | 59 return disabled_extensions_; |
59 } | 60 } |
60 const ExtensionSet& terminated_extensions() const { | 61 const ExtensionSet& terminated_extensions() const { |
61 return terminated_extensions_; | 62 return terminated_extensions_; |
62 } | 63 } |
63 const ExtensionSet& blacklisted_extensions() const { | 64 const ExtensionSet& blacklisted_extensions() const { |
64 return blacklisted_extensions_; | 65 return blacklisted_extensions_; |
65 } | 66 } |
67 const ExtensionSet& locked_extensions() const { return locked_extensions_; } | |
66 | 68 |
67 // Returns a set of all installed, disabled, blacklisted, and terminated | 69 // Returns a set of all installed, disabled, blacklisted, and terminated |
68 // extensions. | 70 // extensions. |
69 scoped_ptr<ExtensionSet> GenerateInstalledExtensionsSet() const; | 71 scoped_ptr<ExtensionSet> GenerateInstalledExtensionsSet() const; |
70 | 72 |
71 // The usual observer interface. | 73 // The usual observer interface. |
72 void AddObserver(ExtensionRegistryObserver* observer); | 74 void AddObserver(ExtensionRegistryObserver* observer); |
73 void RemoveObserver(ExtensionRegistryObserver* observer); | 75 void RemoveObserver(ExtensionRegistryObserver* observer); |
74 | 76 |
75 // Invokes the observer method OnExtensionLoaded(). The extension must be | 77 // Invokes the observer method OnExtensionLoaded(). The extension must be |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 bool RemoveDisabled(const std::string& id); | 131 bool RemoveDisabled(const std::string& id); |
130 | 132 |
131 // As above, but for the terminated set. | 133 // As above, but for the terminated set. |
132 bool AddTerminated(const scoped_refptr<const Extension>& extension); | 134 bool AddTerminated(const scoped_refptr<const Extension>& extension); |
133 bool RemoveTerminated(const std::string& id); | 135 bool RemoveTerminated(const std::string& id); |
134 | 136 |
135 // As above, but for the blacklisted set. | 137 // As above, but for the blacklisted set. |
136 bool AddBlacklisted(const scoped_refptr<const Extension>& extension); | 138 bool AddBlacklisted(const scoped_refptr<const Extension>& extension); |
137 bool RemoveBlacklisted(const std::string& id); | 139 bool RemoveBlacklisted(const std::string& id); |
138 | 140 |
141 // As above, but for the locked set. | |
142 bool AddLocked(const scoped_refptr<const Extension>& extension); | |
143 bool RemoveLocked(const std::string& id); | |
144 | |
139 // Removes all extensions from all sets. | 145 // Removes all extensions from all sets. |
140 void ClearAll(); | 146 void ClearAll(); |
141 | 147 |
142 // Sets a callback to run when the disabled extension set is modified. | 148 // Sets a callback to run when the disabled extension set is modified. |
143 // TODO(jamescook): This is too specific for a generic registry; find some | 149 // TODO(jamescook): This is too specific for a generic registry; find some |
144 // other way to do this. | 150 // other way to do this. |
145 void SetDisabledModificationCallback( | 151 void SetDisabledModificationCallback( |
146 const ExtensionSet::ModificationCallback& callback); | 152 const ExtensionSet::ModificationCallback& callback); |
147 | 153 |
148 // KeyedService implementation: | 154 // KeyedService implementation: |
149 void Shutdown() override; | 155 void Shutdown() override; |
150 | 156 |
151 private: | 157 private: |
152 // Extensions that are installed, enabled and not terminated. | 158 // Extensions that are installed, enabled and not terminated. |
153 ExtensionSet enabled_extensions_; | 159 ExtensionSet enabled_extensions_; |
154 | 160 |
155 // Extensions that are installed and disabled. | 161 // Extensions that are installed and disabled. |
156 ExtensionSet disabled_extensions_; | 162 ExtensionSet disabled_extensions_; |
157 | 163 |
158 // Extensions that are installed and terminated. | 164 // Extensions that are installed and terminated. |
159 ExtensionSet terminated_extensions_; | 165 ExtensionSet terminated_extensions_; |
160 | 166 |
161 // Extensions that are installed and blacklisted. Generally these shouldn't be | 167 // Extensions that are installed and blacklisted. Generally these shouldn't be |
162 // considered as installed by the extension platform: we only keep them around | 168 // considered as installed by the extension platform: we only keep them around |
163 // so that if extensions are blacklisted by mistake they can easily be | 169 // so that if extensions are blacklisted by mistake they can easily be |
164 // un-blacklisted. | 170 // un-blacklisted. |
165 ExtensionSet blacklisted_extensions_; | 171 ExtensionSet blacklisted_extensions_; |
166 | 172 |
173 // Extensions that are installed and locked. | |
174 ExtensionSet locked_extensions_; | |
175 | |
167 ObserverList<ExtensionRegistryObserver> observers_; | 176 ObserverList<ExtensionRegistryObserver> observers_; |
168 | 177 |
169 content::BrowserContext* const browser_context_; | 178 content::BrowserContext* const browser_context_; |
170 | 179 |
171 DISALLOW_COPY_AND_ASSIGN(ExtensionRegistry); | 180 DISALLOW_COPY_AND_ASSIGN(ExtensionRegistry); |
172 }; | 181 }; |
173 | 182 |
174 } // namespace extensions | 183 } // namespace extensions |
175 | 184 |
176 #endif // EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_ | 185 #endif // EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_ |
OLD | NEW |