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 "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 13 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
13 #include "extensions/common/extension_set.h" | 14 #include "extensions/common/extension_set.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; |
| 22 class ExtensionRegistryObserver; |
21 | 23 |
22 // ExtensionRegistry holds sets of the installed extensions for a given | 24 // ExtensionRegistry holds sets of the installed extensions for a given |
23 // BrowserContext. An incognito browser context and its master browser context | 25 // BrowserContext. An incognito browser context and its master browser context |
24 // share a single registry. | 26 // share a single registry. |
25 class ExtensionRegistry : public BrowserContextKeyedService { | 27 class ExtensionRegistry : public BrowserContextKeyedService { |
26 public: | 28 public: |
27 // 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. |
28 enum IncludeFlag { | 30 enum IncludeFlag { |
29 NONE = 0, | 31 NONE = 0, |
30 ENABLED = 1 << 0, | 32 ENABLED = 1 << 0, |
(...skipping 17 matching lines...) Expand all Loading... |
48 const ExtensionSet& disabled_extensions() const { | 50 const ExtensionSet& disabled_extensions() const { |
49 return disabled_extensions_; | 51 return disabled_extensions_; |
50 } | 52 } |
51 const ExtensionSet& terminated_extensions() const { | 53 const ExtensionSet& terminated_extensions() const { |
52 return terminated_extensions_; | 54 return terminated_extensions_; |
53 } | 55 } |
54 const ExtensionSet& blacklisted_extensions() const { | 56 const ExtensionSet& blacklisted_extensions() const { |
55 return blacklisted_extensions_; | 57 return blacklisted_extensions_; |
56 } | 58 } |
57 | 59 |
| 60 // The usual observer interface. |
| 61 void AddObserver(ExtensionRegistryObserver* observer); |
| 62 void RemoveObserver(ExtensionRegistryObserver* observer); |
| 63 |
| 64 // Invokes the observer method OnExtensionUnloaded(). The extension must not |
| 65 // be enabled at the time of the call. |
| 66 void TriggerOnUnloaded(const Extension* extension); |
| 67 |
58 // Find an extension by ID using |include_mask| to pick the sets to search: | 68 // Find an extension by ID using |include_mask| to pick the sets to search: |
59 // * enabled_extensions() --> ExtensionRegistry::ENABLED | 69 // * enabled_extensions() --> ExtensionRegistry::ENABLED |
60 // * disabled_extensions() --> ExtensionRegistry::DISABLED | 70 // * disabled_extensions() --> ExtensionRegistry::DISABLED |
61 // * terminated_extensions() --> ExtensionRegistry::TERMINATED | 71 // * terminated_extensions() --> ExtensionRegistry::TERMINATED |
62 // * blacklisted_extensions() --> ExtensionRegistry::BLACKLISTED | 72 // * blacklisted_extensions() --> ExtensionRegistry::BLACKLISTED |
63 // Returns NULL if the extension is not found in the selected sets. | 73 // Returns NULL if the extension is not found in the selected sets. |
64 const Extension* GetExtensionById(const std::string& id, | 74 const Extension* GetExtensionById(const std::string& id, |
65 int include_mask) const; | 75 int include_mask) const; |
66 | 76 |
67 // Adds the specified extension to the enabled set. The registry becomes an | 77 // Adds the specified extension to the enabled set. The registry becomes an |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 120 |
111 // Extensions that are installed and terminated. | 121 // Extensions that are installed and terminated. |
112 ExtensionSet terminated_extensions_; | 122 ExtensionSet terminated_extensions_; |
113 | 123 |
114 // Extensions that are installed and blacklisted. Generally these shouldn't be | 124 // Extensions that are installed and blacklisted. Generally these shouldn't be |
115 // 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 |
116 // 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 |
117 // un-blacklisted. | 127 // un-blacklisted. |
118 ExtensionSet blacklisted_extensions_; | 128 ExtensionSet blacklisted_extensions_; |
119 | 129 |
| 130 ObserverList<ExtensionRegistryObserver> observers_; |
| 131 |
120 DISALLOW_COPY_AND_ASSIGN(ExtensionRegistry); | 132 DISALLOW_COPY_AND_ASSIGN(ExtensionRegistry); |
121 }; | 133 }; |
122 | 134 |
123 } // namespace extensions | 135 } // namespace extensions |
124 | 136 |
125 #endif // EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_ | 137 #endif // EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_ |
OLD | NEW |