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 | 10 |
10 namespace extensions { | 11 namespace extensions { |
11 | 12 |
12 ExtensionRegistry::ExtensionRegistry() {} | 13 ExtensionRegistry::ExtensionRegistry() {} |
13 ExtensionRegistry::~ExtensionRegistry() {} | 14 ExtensionRegistry::~ExtensionRegistry() {} |
14 | 15 |
15 // static | 16 // static |
16 ExtensionRegistry* ExtensionRegistry::Get(content::BrowserContext* context) { | 17 ExtensionRegistry* ExtensionRegistry::Get(content::BrowserContext* context) { |
17 return ExtensionRegistryFactory::GetForBrowserContext(context); | 18 return ExtensionRegistryFactory::GetForBrowserContext(context); |
18 } | 19 } |
19 | 20 |
| 21 void ExtensionRegistry::AddObserver(ExtensionRegistryObserver* observer) { |
| 22 observers_.AddObserver(observer); |
| 23 } |
| 24 |
| 25 void ExtensionRegistry::RemoveObserver(ExtensionRegistryObserver* observer) { |
| 26 observers_.RemoveObserver(observer); |
| 27 } |
| 28 |
| 29 void ExtensionRegistry::TriggerOnUnloaded(const Extension* extension) { |
| 30 DCHECK(!enabled_extensions_.Contains(extension->id())); |
| 31 FOR_EACH_OBSERVER( |
| 32 ExtensionRegistryObserver, observers_, OnExtensionUnloaded(extension)); |
| 33 } |
| 34 |
20 const Extension* ExtensionRegistry::GetExtensionById(const std::string& id, | 35 const Extension* ExtensionRegistry::GetExtensionById(const std::string& id, |
21 int include_mask) const { | 36 int include_mask) const { |
22 std::string lowercase_id = StringToLowerASCII(id); | 37 std::string lowercase_id = StringToLowerASCII(id); |
23 if (include_mask & ENABLED) { | 38 if (include_mask & ENABLED) { |
24 const Extension* extension = enabled_extensions_.GetByID(lowercase_id); | 39 const Extension* extension = enabled_extensions_.GetByID(lowercase_id); |
25 if (extension) | 40 if (extension) |
26 return extension; | 41 return extension; |
27 } | 42 } |
28 if (include_mask & DISABLED) { | 43 if (include_mask & DISABLED) { |
29 const Extension* extension = disabled_extensions_.GetByID(lowercase_id); | 44 const Extension* extension = disabled_extensions_.GetByID(lowercase_id); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 const ExtensionSet::ModificationCallback& callback) { | 105 const ExtensionSet::ModificationCallback& callback) { |
91 disabled_extensions_.set_modification_callback(callback); | 106 disabled_extensions_.set_modification_callback(callback); |
92 } | 107 } |
93 | 108 |
94 void ExtensionRegistry::Shutdown() { | 109 void ExtensionRegistry::Shutdown() { |
95 // Release references to all Extension objects in the sets. | 110 // Release references to all Extension objects in the sets. |
96 ClearAll(); | 111 ClearAll(); |
97 } | 112 } |
98 | 113 |
99 } // namespace extensions | 114 } // namespace extensions |
OLD | NEW |