OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/api/declarative/rules_registry_service.h" | 5 #include "extensions/browser/api/declarative/rules_registry_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 RulesRegistryService::GetFactoryInstance() { | 130 RulesRegistryService::GetFactoryInstance() { |
131 return g_factory.Pointer(); | 131 return g_factory.Pointer(); |
132 } | 132 } |
133 | 133 |
134 // static | 134 // static |
135 RulesRegistryService* RulesRegistryService::Get( | 135 RulesRegistryService* RulesRegistryService::Get( |
136 content::BrowserContext* context) { | 136 content::BrowserContext* context) { |
137 return BrowserContextKeyedAPIFactory<RulesRegistryService>::Get(context); | 137 return BrowserContextKeyedAPIFactory<RulesRegistryService>::Get(context); |
138 } | 138 } |
139 | 139 |
| 140 // static |
| 141 RulesRegistryService* RulesRegistryService::GetIfExists( |
| 142 content::BrowserContext* context) { |
| 143 return BrowserContextKeyedAPIFactory<RulesRegistryService>::GetIfExists( |
| 144 context); |
| 145 } |
| 146 |
140 void RulesRegistryService::RegisterRulesRegistry( | 147 void RulesRegistryService::RegisterRulesRegistry( |
141 scoped_refptr<RulesRegistry> rule_registry) { | 148 scoped_refptr<RulesRegistry> rule_registry) { |
142 const std::string event_name(rule_registry->event_name()); | 149 const std::string event_name(rule_registry->event_name()); |
143 RulesRegistryKey key(event_name, rule_registry->id()); | 150 RulesRegistryKey key(event_name, rule_registry->id()); |
144 DCHECK(rule_registries_.find(key) == rule_registries_.end()); | 151 DCHECK(rule_registries_.find(key) == rule_registries_.end()); |
145 rule_registries_[key] = rule_registry; | 152 rule_registries_[key] = rule_registry; |
146 } | 153 } |
147 | 154 |
148 scoped_refptr<RulesRegistry> RulesRegistryService::GetRulesRegistry( | 155 scoped_refptr<RulesRegistry> RulesRegistryService::GetRulesRegistry( |
149 int rules_registry_id, | 156 int rules_registry_id, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 } | 218 } |
212 | 219 |
213 void RulesRegistryService::OnExtensionUninstalled( | 220 void RulesRegistryService::OnExtensionUninstalled( |
214 content::BrowserContext* browser_context, | 221 content::BrowserContext* browser_context, |
215 const Extension* extension, | 222 const Extension* extension, |
216 extensions::UninstallReason reason) { | 223 extensions::UninstallReason reason) { |
217 NotifyRegistriesHelper(&RulesRegistry::OnExtensionUninstalled, extension); | 224 NotifyRegistriesHelper(&RulesRegistry::OnExtensionUninstalled, extension); |
218 } | 225 } |
219 | 226 |
220 } // namespace extensions | 227 } // namespace extensions |
OLD | NEW |