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 "chrome/browser/extensions/api/declarative/rules_registry_service.h" | 5 #include "chrome/browser/extensions/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 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 } // namespace | 43 } // namespace |
44 | 44 |
45 RulesRegistryService::RulesRegistryService(content::BrowserContext* context) | 45 RulesRegistryService::RulesRegistryService(content::BrowserContext* context) |
46 : content_rules_registry_(NULL), | 46 : content_rules_registry_(NULL), |
47 extension_registry_observer_(this), | 47 extension_registry_observer_(this), |
48 profile_(Profile::FromBrowserContext(context)) { | 48 profile_(Profile::FromBrowserContext(context)) { |
49 if (profile_) { | 49 if (profile_) { |
50 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); | 50 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); |
51 registrar_.Add(this, | |
52 chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, | |
53 content::Source<Profile>(profile_->GetOriginalProfile())); | |
54 registrar_.Add( | 51 registrar_.Add( |
55 this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 52 this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
56 content::NotificationService::AllBrowserContextsAndSources()); | 53 content::NotificationService::AllBrowserContextsAndSources()); |
57 EnsureDefaultRulesRegistriesRegistered(WebViewKey(0, 0)); | 54 EnsureDefaultRulesRegistriesRegistered(WebViewKey(0, 0)); |
58 } | 55 } |
59 } | 56 } |
60 | 57 |
61 RulesRegistryService::~RulesRegistryService() {} | 58 RulesRegistryService::~RulesRegistryService() {} |
62 | 59 |
63 void RulesRegistryService::EnsureDefaultRulesRegistriesRegistered( | 60 void RulesRegistryService::EnsureDefaultRulesRegistriesRegistered( |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 NotifyRegistriesHelper(&RulesRegistry::OnExtensionLoaded, extension->id()); | 206 NotifyRegistriesHelper(&RulesRegistry::OnExtensionLoaded, extension->id()); |
210 } | 207 } |
211 | 208 |
212 void RulesRegistryService::OnExtensionUnloaded( | 209 void RulesRegistryService::OnExtensionUnloaded( |
213 content::BrowserContext* browser_context, | 210 content::BrowserContext* browser_context, |
214 const Extension* extension, | 211 const Extension* extension, |
215 UnloadedExtensionInfo::Reason reason) { | 212 UnloadedExtensionInfo::Reason reason) { |
216 NotifyRegistriesHelper(&RulesRegistry::OnExtensionUnloaded, extension->id()); | 213 NotifyRegistriesHelper(&RulesRegistry::OnExtensionUnloaded, extension->id()); |
217 } | 214 } |
218 | 215 |
| 216 void RulesRegistryService::OnExtensionUninstalled( |
| 217 content::BrowserContext* browser_context, |
| 218 const Extension* extension) { |
| 219 NotifyRegistriesHelper(&RulesRegistry::OnExtensionUninstalled, |
| 220 extension->id()); |
| 221 } |
| 222 |
219 void RulesRegistryService::Observe( | 223 void RulesRegistryService::Observe( |
220 int type, | 224 int type, |
221 const content::NotificationSource& source, | 225 const content::NotificationSource& source, |
222 const content::NotificationDetails& details) { | 226 const content::NotificationDetails& details) { |
223 switch (type) { | 227 DCHECK_EQ(content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, type); |
224 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED: { | 228 |
225 const Extension* extension = | 229 content::RenderProcessHost* process = |
226 content::Details<const Extension>(details).ptr(); | 230 content::Source<content::RenderProcessHost>(source).ptr(); |
227 NotifyRegistriesHelper(&RulesRegistry::OnExtensionUninstalled, | 231 RemoveWebViewRulesRegistries(process->GetID()); |
228 extension->id()); | |
229 break; | |
230 } | |
231 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: { | |
232 content::RenderProcessHost* process = | |
233 content::Source<content::RenderProcessHost>(source).ptr(); | |
234 RemoveWebViewRulesRegistries(process->GetID()); | |
235 break; | |
236 } | |
237 default: | |
238 NOTREACHED(); | |
239 break; | |
240 } | |
241 } | 232 } |
242 | 233 |
243 } // namespace extensions | 234 } // namespace extensions |
OLD | NEW |