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. | |
not at google - send to devlin
2014/01/22 16:17:43
[musing]
One nice thing about explicit dependenci
| |
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); | |
not at google - send to devlin
2014/01/22 16:17:43
It looks like the notification also has an "unload
James Cook
2014/01/22 17:41:52
I don't understand what you mean by "might as well
not at google - send to devlin
2014/01/22 17:49:07
Up to you, I don't feel one way or the other, just
| |
67 | |
68 // Invokes the observer method OnExtensionDisabled(). The extension must be | |
69 // disabled at the time of the call. | |
70 void TriggerOnDisabled(const Extension* extension); | |
not at google - send to devlin
2014/01/22 16:17:43
It's interesting; there's no disabled notification
James Cook
2014/01/22 17:41:52
I agree it looks odd.
not at google - send to devlin
2014/01/22 17:49:07
I meant that it seems like we should clear all of
| |
71 | |
58 // Find an extension by ID using |include_mask| to pick the sets to search: | 72 // Find an extension by ID using |include_mask| to pick the sets to search: |
59 // * enabled_extensions() --> ExtensionRegistry::ENABLED | 73 // * enabled_extensions() --> ExtensionRegistry::ENABLED |
60 // * disabled_extensions() --> ExtensionRegistry::DISABLED | 74 // * disabled_extensions() --> ExtensionRegistry::DISABLED |
61 // * terminated_extensions() --> ExtensionRegistry::TERMINATED | 75 // * terminated_extensions() --> ExtensionRegistry::TERMINATED |
62 // * blacklisted_extensions() --> ExtensionRegistry::BLACKLISTED | 76 // * blacklisted_extensions() --> ExtensionRegistry::BLACKLISTED |
63 // Returns NULL if the extension is not found in the selected sets. | 77 // Returns NULL if the extension is not found in the selected sets. |
64 const Extension* GetExtensionById(const std::string& id, | 78 const Extension* GetExtensionById(const std::string& id, |
65 int include_mask) const; | 79 int include_mask) const; |
66 | 80 |
67 // Adds the specified extension to the enabled set. The registry becomes an | 81 // 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 | 124 |
111 // Extensions that are installed and terminated. | 125 // Extensions that are installed and terminated. |
112 ExtensionSet terminated_extensions_; | 126 ExtensionSet terminated_extensions_; |
113 | 127 |
114 // Extensions that are installed and blacklisted. Generally these shouldn't be | 128 // Extensions that are installed and blacklisted. Generally these shouldn't be |
115 // considered as installed by the extension platform: we only keep them around | 129 // 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 | 130 // so that if extensions are blacklisted by mistake they can easily be |
117 // un-blacklisted. | 131 // un-blacklisted. |
118 ExtensionSet blacklisted_extensions_; | 132 ExtensionSet blacklisted_extensions_; |
119 | 133 |
134 ObserverList<ExtensionRegistryObserver> observers_; | |
135 | |
120 DISALLOW_COPY_AND_ASSIGN(ExtensionRegistry); | 136 DISALLOW_COPY_AND_ASSIGN(ExtensionRegistry); |
121 }; | 137 }; |
122 | 138 |
123 } // namespace extensions | 139 } // namespace extensions |
124 | 140 |
125 #endif // EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_ | 141 #endif // EXTENSIONS_BROWSER_EXTENSION_REGISTRY_H_ |
OLD | NEW |