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 "extensions/browser/extension_registry_factory.h" | 8 #include "extensions/browser/extension_registry_factory.h" |
8 | 9 |
9 namespace extensions { | 10 namespace extensions { |
10 | 11 |
11 ExtensionRegistry::ExtensionRegistry() {} | 12 ExtensionRegistry::ExtensionRegistry() {} |
12 ExtensionRegistry::~ExtensionRegistry() {} | 13 ExtensionRegistry::~ExtensionRegistry() {} |
13 | 14 |
14 // static | 15 // static |
15 ExtensionRegistry* ExtensionRegistry::Get(content::BrowserContext* context) { | 16 ExtensionRegistry* ExtensionRegistry::Get(content::BrowserContext* context) { |
16 return ExtensionRegistryFactory::GetForBrowserContext(context); | 17 return ExtensionRegistryFactory::GetForBrowserContext(context); |
17 } | 18 } |
18 | 19 |
| 20 const Extension* ExtensionRegistry::GetExtensionById(const std::string& id, |
| 21 int include_mask) const { |
| 22 std::string lowercase_id = StringToLowerASCII(id); |
| 23 if (include_mask & INCLUDE_ENABLED) { |
| 24 const Extension* extension = enabled_extensions_.GetByID(lowercase_id); |
| 25 if (extension) |
| 26 return extension; |
| 27 } |
| 28 if (include_mask & INCLUDE_DISABLED) { |
| 29 const Extension* extension = disabled_extensions_.GetByID(lowercase_id); |
| 30 if (extension) |
| 31 return extension; |
| 32 } |
| 33 if (include_mask & INCLUDE_TERMINATED) { |
| 34 const Extension* extension = terminated_extensions_.GetByID(lowercase_id); |
| 35 if (extension) |
| 36 return extension; |
| 37 } |
| 38 if (include_mask & INCLUDE_BLACKLISTED) { |
| 39 const Extension* extension = blacklisted_extensions_.GetByID(lowercase_id); |
| 40 if (extension) |
| 41 return extension; |
| 42 } |
| 43 return NULL; |
| 44 } |
| 45 |
19 bool ExtensionRegistry::AddEnabled( | 46 bool ExtensionRegistry::AddEnabled( |
20 const scoped_refptr<const Extension>& extension) { | 47 const scoped_refptr<const Extension>& extension) { |
21 return enabled_extensions_.Insert(extension); | 48 return enabled_extensions_.Insert(extension); |
22 } | 49 } |
23 | 50 |
24 bool ExtensionRegistry::RemoveEnabled(const std::string& id) { | 51 bool ExtensionRegistry::RemoveEnabled(const std::string& id) { |
25 return enabled_extensions_.Remove(id); | 52 return enabled_extensions_.Remove(id); |
26 } | 53 } |
27 | 54 |
28 bool ExtensionRegistry::AddDisabled( | 55 bool ExtensionRegistry::AddDisabled( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 const ExtensionSet::ModificationCallback& callback) { | 90 const ExtensionSet::ModificationCallback& callback) { |
64 disabled_extensions_.set_modification_callback(callback); | 91 disabled_extensions_.set_modification_callback(callback); |
65 } | 92 } |
66 | 93 |
67 void ExtensionRegistry::Shutdown() { | 94 void ExtensionRegistry::Shutdown() { |
68 // Release references to all Extension objects in the sets. | 95 // Release references to all Extension objects in the sets. |
69 ClearAll(); | 96 ClearAll(); |
70 } | 97 } |
71 | 98 |
72 } // namespace extensions | 99 } // namespace extensions |
OLD | NEW |