| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 registries_to_delete.insert(key); | 162 registries_to_delete.insert(key); |
| 163 } | 163 } |
| 164 | 164 |
| 165 for (std::set<RulesRegistryKey>::iterator it = registries_to_delete.begin(); | 165 for (std::set<RulesRegistryKey>::iterator it = registries_to_delete.begin(); |
| 166 it != registries_to_delete.end(); ++it) { | 166 it != registries_to_delete.end(); ++it) { |
| 167 rule_registries_.erase(*it); | 167 rule_registries_.erase(*it); |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 | 170 |
| 171 void RulesRegistryService::SimulateExtensionUninstalled( | 171 void RulesRegistryService::SimulateExtensionUninstalled( |
| 172 const std::string& extension_id) { | 172 const Extension* extension) { |
| 173 NotifyRegistriesHelper(&RulesRegistry::OnExtensionUninstalled, extension_id); | 173 NotifyRegistriesHelper(&RulesRegistry::OnExtensionUninstalled, extension); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void RulesRegistryService::NotifyRegistriesHelper( | 176 void RulesRegistryService::NotifyRegistriesHelper( |
| 177 void (RulesRegistry::*notification_callback)(const std::string&), | 177 void (RulesRegistry::*notification_callback)(const Extension*), |
| 178 const std::string& extension_id) { | 178 const Extension* extension) { |
| 179 RulesRegistryMap::iterator i; | 179 RulesRegistryMap::iterator i; |
| 180 for (i = rule_registries_.begin(); i != rule_registries_.end(); ++i) { | 180 for (i = rule_registries_.begin(); i != rule_registries_.end(); ++i) { |
| 181 scoped_refptr<RulesRegistry> registry = i->second; | 181 scoped_refptr<RulesRegistry> registry = i->second; |
| 182 if (content::BrowserThread::CurrentlyOn(registry->owner_thread())) { | 182 if (content::BrowserThread::CurrentlyOn(registry->owner_thread())) { |
| 183 (registry.get()->*notification_callback)(extension_id); | 183 (registry.get()->*notification_callback)(extension); |
| 184 } else { | 184 } else { |
| 185 content::BrowserThread::PostTask( | 185 content::BrowserThread::PostTask( |
| 186 registry->owner_thread(), | 186 registry->owner_thread(), FROM_HERE, |
| 187 FROM_HERE, | 187 base::Bind(notification_callback, registry, extension)); |
| 188 base::Bind(notification_callback, registry, extension_id)); | |
| 189 } | 188 } |
| 190 } | 189 } |
| 191 } | 190 } |
| 192 | 191 |
| 193 void RulesRegistryService::OnExtensionLoaded( | 192 void RulesRegistryService::OnExtensionLoaded( |
| 194 content::BrowserContext* browser_context, | 193 content::BrowserContext* browser_context, |
| 195 const Extension* extension) { | 194 const Extension* extension) { |
| 196 NotifyRegistriesHelper(&RulesRegistry::OnExtensionLoaded, extension->id()); | 195 NotifyRegistriesHelper(&RulesRegistry::OnExtensionLoaded, extension); |
| 197 } | 196 } |
| 198 | 197 |
| 199 void RulesRegistryService::OnExtensionUnloaded( | 198 void RulesRegistryService::OnExtensionUnloaded( |
| 200 content::BrowserContext* browser_context, | 199 content::BrowserContext* browser_context, |
| 201 const Extension* extension, | 200 const Extension* extension, |
| 202 UnloadedExtensionInfo::Reason reason) { | 201 UnloadedExtensionInfo::Reason reason) { |
| 203 NotifyRegistriesHelper(&RulesRegistry::OnExtensionUnloaded, extension->id()); | 202 NotifyRegistriesHelper(&RulesRegistry::OnExtensionUnloaded, extension); |
| 204 } | 203 } |
| 205 | 204 |
| 206 void RulesRegistryService::OnExtensionUninstalled( | 205 void RulesRegistryService::OnExtensionUninstalled( |
| 207 content::BrowserContext* browser_context, | 206 content::BrowserContext* browser_context, |
| 208 const Extension* extension, | 207 const Extension* extension, |
| 209 extensions::UninstallReason reason) { | 208 extensions::UninstallReason reason) { |
| 210 NotifyRegistriesHelper(&RulesRegistry::OnExtensionUninstalled, | 209 NotifyRegistriesHelper(&RulesRegistry::OnExtensionUninstalled, extension); |
| 211 extension->id()); | |
| 212 } | 210 } |
| 213 | 211 |
| 214 } // namespace extensions | 212 } // namespace extensions |
| OLD | NEW |