| 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 27 matching lines...) Expand all Loading... |
| 38 if (profile) { | 38 if (profile) { |
| 39 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 39 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 40 content::Source<Profile>(profile->GetOriginalProfile())); | 40 content::Source<Profile>(profile->GetOriginalProfile())); |
| 41 RegisterDefaultRulesRegistries(); | 41 RegisterDefaultRulesRegistries(); |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 | 44 |
| 45 RulesRegistryService::~RulesRegistryService() {} | 45 RulesRegistryService::~RulesRegistryService() {} |
| 46 | 46 |
| 47 void RulesRegistryService::RegisterDefaultRulesRegistries() { | 47 void RulesRegistryService::RegisterDefaultRulesRegistries() { |
| 48 scoped_ptr<RulesCacheDelegate> ui_part; | 48 scoped_ptr<RulesCacheDelegate> web_request_cache_delegate( |
| 49 new RulesCacheDelegate(true /*log_storage_init_delay*/)); |
| 49 scoped_refptr<WebRequestRulesRegistry> web_request_rules_registry( | 50 scoped_refptr<WebRequestRulesRegistry> web_request_rules_registry( |
| 50 new WebRequestRulesRegistry(profile_, &ui_part)); | 51 new WebRequestRulesRegistry(profile_, web_request_cache_delegate.get())); |
| 51 ui_parts_of_registries_.push_back(ui_part.release()); | 52 cache_delegates_.push_back(web_request_cache_delegate.release()); |
| 52 | 53 |
| 53 RegisterRulesRegistry(web_request_rules_registry); | 54 RegisterRulesRegistry(web_request_rules_registry); |
| 54 content::BrowserThread::PostTask( | 55 content::BrowserThread::PostTask( |
| 55 content::BrowserThread::IO, FROM_HERE, | 56 content::BrowserThread::IO, FROM_HERE, |
| 56 base::Bind(&RegisterToExtensionWebRequestEventRouterOnIO, | 57 base::Bind(&RegisterToExtensionWebRequestEventRouterOnIO, |
| 57 profile_, web_request_rules_registry)); | 58 profile_, web_request_rules_registry)); |
| 58 | 59 |
| 59 #if defined(ENABLE_EXTENSIONS) | 60 #if defined(ENABLE_EXTENSIONS) |
| 61 scoped_ptr<RulesCacheDelegate> content_rules_cache_delegate( |
| 62 new RulesCacheDelegate(false /*log_storage_init_delay*/)); |
| 60 scoped_refptr<ContentRulesRegistry> content_rules_registry( | 63 scoped_refptr<ContentRulesRegistry> content_rules_registry( |
| 61 new ContentRulesRegistry(profile_, &ui_part)); | 64 new ContentRulesRegistry(profile_, content_rules_cache_delegate.get())); |
| 62 ui_parts_of_registries_.push_back(ui_part.release()); | 65 cache_delegates_.push_back(content_rules_cache_delegate.release()); |
| 63 | 66 |
| 64 RegisterRulesRegistry(content_rules_registry); | 67 RegisterRulesRegistry(content_rules_registry); |
| 65 content_rules_registry_ = content_rules_registry.get(); | 68 content_rules_registry_ = content_rules_registry.get(); |
| 66 #endif // defined(ENABLE_EXTENSIONS) | 69 #endif // defined(ENABLE_EXTENSIONS) |
| 67 } | 70 } |
| 68 | 71 |
| 69 void RulesRegistryService::Shutdown() { | 72 void RulesRegistryService::Shutdown() { |
| 70 // Release the references to all registries. This would happen soon during | 73 // Release the references to all registries. This would happen soon during |
| 71 // destruction of |*this|, but we need the ExtensionWebRequestEventRouter to | 74 // destruction of |*this|, but we need the ExtensionWebRequestEventRouter to |
| 72 // be the last to reference the WebRequestRulesRegistry objects, so that | 75 // be the last to reference the WebRequestRulesRegistry objects, so that |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 OnExtensionUnloaded(extension->id()); | 145 OnExtensionUnloaded(extension->id()); |
| 143 break; | 146 break; |
| 144 } | 147 } |
| 145 default: | 148 default: |
| 146 NOTREACHED(); | 149 NOTREACHED(); |
| 147 break; | 150 break; |
| 148 } | 151 } |
| 149 } | 152 } |
| 150 | 153 |
| 151 } // namespace extensions | 154 } // namespace extensions |
| OLD | NEW |