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 #include "extensions/browser/extension_registry.h" | 5 #include "extensions/browser/extension_registry.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "extensions/browser/extension_registry_factory.h" | 8 #include "extensions/browser/extension_registry_factory.h" |
9 #include "extensions/browser/extension_registry_observer.h" | 9 #include "extensions/browser/extension_registry_observer.h" |
10 | 10 |
11 namespace extensions { | 11 namespace extensions { |
12 | 12 |
13 ExtensionRegistry::ExtensionRegistry(content::BrowserContext* browser_context) | 13 ExtensionRegistry::ExtensionRegistry(content::BrowserContext* browser_context) |
14 : browser_context_(browser_context) {} | 14 : browser_context_(browser_context) {} |
15 ExtensionRegistry::~ExtensionRegistry() {} | 15 ExtensionRegistry::~ExtensionRegistry() {} |
16 | 16 |
17 // static | 17 // static |
18 ExtensionRegistry* ExtensionRegistry::Get(content::BrowserContext* context) { | 18 ExtensionRegistry* ExtensionRegistry::Get(content::BrowserContext* context) { |
19 return ExtensionRegistryFactory::GetForBrowserContext(context); | 19 return ExtensionRegistryFactory::GetForBrowserContext(context); |
20 } | 20 } |
21 | 21 |
22 scoped_ptr<ExtensionSet> ExtensionRegistry::GenerateInstalledExtensionsSet() | 22 scoped_ptr<ExtensionSet> ExtensionRegistry::GenerateInstalledExtensionsSet() |
23 const { | 23 const { |
| 24 return GenerateInstalledExtensionsSet(EVERYTHING).Pass(); |
| 25 } |
| 26 |
| 27 scoped_ptr<ExtensionSet> ExtensionRegistry::GenerateInstalledExtensionsSet( |
| 28 int include_mask) const { |
24 scoped_ptr<ExtensionSet> installed_extensions(new ExtensionSet); | 29 scoped_ptr<ExtensionSet> installed_extensions(new ExtensionSet); |
25 installed_extensions->InsertAll(enabled_extensions_); | 30 if (include_mask & IncludeFlag::ENABLED) |
26 installed_extensions->InsertAll(disabled_extensions_); | 31 installed_extensions->InsertAll(enabled_extensions_); |
27 installed_extensions->InsertAll(terminated_extensions_); | 32 if (include_mask & IncludeFlag::DISABLED) |
28 installed_extensions->InsertAll(blacklisted_extensions_); | 33 installed_extensions->InsertAll(disabled_extensions_); |
| 34 if (include_mask & IncludeFlag::TERMINATED) |
| 35 installed_extensions->InsertAll(terminated_extensions_); |
| 36 if (include_mask & IncludeFlag::BLACKLISTED) |
| 37 installed_extensions->InsertAll(blacklisted_extensions_); |
| 38 if (include_mask & IncludeFlag::BLOCKED) |
| 39 installed_extensions->InsertAll(blocked_extensions_); |
29 return installed_extensions.Pass(); | 40 return installed_extensions.Pass(); |
30 } | 41 } |
31 | 42 |
32 void ExtensionRegistry::AddObserver(ExtensionRegistryObserver* observer) { | 43 void ExtensionRegistry::AddObserver(ExtensionRegistryObserver* observer) { |
33 observers_.AddObserver(observer); | 44 observers_.AddObserver(observer); |
34 } | 45 } |
35 | 46 |
36 void ExtensionRegistry::RemoveObserver(ExtensionRegistryObserver* observer) { | 47 void ExtensionRegistry::RemoveObserver(ExtensionRegistryObserver* observer) { |
37 observers_.RemoveObserver(observer); | 48 observers_.RemoveObserver(observer); |
38 } | 49 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 if (include_mask & TERMINATED) { | 112 if (include_mask & TERMINATED) { |
102 const Extension* extension = terminated_extensions_.GetByID(lowercase_id); | 113 const Extension* extension = terminated_extensions_.GetByID(lowercase_id); |
103 if (extension) | 114 if (extension) |
104 return extension; | 115 return extension; |
105 } | 116 } |
106 if (include_mask & BLACKLISTED) { | 117 if (include_mask & BLACKLISTED) { |
107 const Extension* extension = blacklisted_extensions_.GetByID(lowercase_id); | 118 const Extension* extension = blacklisted_extensions_.GetByID(lowercase_id); |
108 if (extension) | 119 if (extension) |
109 return extension; | 120 return extension; |
110 } | 121 } |
| 122 if (include_mask & BLOCKED) { |
| 123 const Extension* extension = blocked_extensions_.GetByID(lowercase_id); |
| 124 if (extension) |
| 125 return extension; |
| 126 } |
111 return NULL; | 127 return NULL; |
112 } | 128 } |
113 | 129 |
114 bool ExtensionRegistry::AddEnabled( | 130 bool ExtensionRegistry::AddEnabled( |
115 const scoped_refptr<const Extension>& extension) { | 131 const scoped_refptr<const Extension>& extension) { |
116 return enabled_extensions_.Insert(extension); | 132 return enabled_extensions_.Insert(extension); |
117 } | 133 } |
118 | 134 |
119 bool ExtensionRegistry::RemoveEnabled(const std::string& id) { | 135 bool ExtensionRegistry::RemoveEnabled(const std::string& id) { |
120 return enabled_extensions_.Remove(id); | 136 return enabled_extensions_.Remove(id); |
(...skipping 19 matching lines...) Expand all Loading... |
140 | 156 |
141 bool ExtensionRegistry::AddBlacklisted( | 157 bool ExtensionRegistry::AddBlacklisted( |
142 const scoped_refptr<const Extension>& extension) { | 158 const scoped_refptr<const Extension>& extension) { |
143 return blacklisted_extensions_.Insert(extension); | 159 return blacklisted_extensions_.Insert(extension); |
144 } | 160 } |
145 | 161 |
146 bool ExtensionRegistry::RemoveBlacklisted(const std::string& id) { | 162 bool ExtensionRegistry::RemoveBlacklisted(const std::string& id) { |
147 return blacklisted_extensions_.Remove(id); | 163 return blacklisted_extensions_.Remove(id); |
148 } | 164 } |
149 | 165 |
| 166 bool ExtensionRegistry::AddBlocked( |
| 167 const scoped_refptr<const Extension>& extension) { |
| 168 return blocked_extensions_.Insert(extension); |
| 169 } |
| 170 |
| 171 bool ExtensionRegistry::RemoveBlocked(const std::string& id) { |
| 172 return blocked_extensions_.Remove(id); |
| 173 } |
| 174 |
150 void ExtensionRegistry::ClearAll() { | 175 void ExtensionRegistry::ClearAll() { |
151 enabled_extensions_.Clear(); | 176 enabled_extensions_.Clear(); |
152 disabled_extensions_.Clear(); | 177 disabled_extensions_.Clear(); |
153 terminated_extensions_.Clear(); | 178 terminated_extensions_.Clear(); |
154 blacklisted_extensions_.Clear(); | 179 blacklisted_extensions_.Clear(); |
| 180 blocked_extensions_.Clear(); |
155 } | 181 } |
156 | 182 |
157 void ExtensionRegistry::SetDisabledModificationCallback( | 183 void ExtensionRegistry::SetDisabledModificationCallback( |
158 const ExtensionSet::ModificationCallback& callback) { | 184 const ExtensionSet::ModificationCallback& callback) { |
159 disabled_extensions_.set_modification_callback(callback); | 185 disabled_extensions_.set_modification_callback(callback); |
160 } | 186 } |
161 | 187 |
162 void ExtensionRegistry::Shutdown() { | 188 void ExtensionRegistry::Shutdown() { |
163 // Release references to all Extension objects in the sets. | 189 // Release references to all Extension objects in the sets. |
164 ClearAll(); | 190 ClearAll(); |
165 FOR_EACH_OBSERVER(ExtensionRegistryObserver, observers_, OnShutdown(this)); | 191 FOR_EACH_OBSERVER(ExtensionRegistryObserver, observers_, OnShutdown(this)); |
166 } | 192 } |
167 | 193 |
168 } // namespace extensions | 194 } // namespace extensions |
OLD | NEW |