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/logging.h" | 8 #include "base/logging.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "chrome/browser/extensions/api/declarative/initializing_rules_registry.
h" | 10 #include "chrome/browser/extensions/api/declarative/initializing_rules_registry.
h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 // Registers |web_request_rules_registry| on the IO thread. | 23 // Registers |web_request_rules_registry| on the IO thread. |
24 void RegisterToExtensionWebRequestEventRouterOnIO( | 24 void RegisterToExtensionWebRequestEventRouterOnIO( |
25 scoped_refptr<WebRequestRulesRegistry> web_request_rules_registry) { | 25 scoped_refptr<WebRequestRulesRegistry> web_request_rules_registry) { |
26 ExtensionWebRequestEventRouter::GetInstance()->RegisterRulesRegistry( | 26 ExtensionWebRequestEventRouter::GetInstance()->RegisterRulesRegistry( |
27 web_request_rules_registry); | 27 web_request_rules_registry); |
28 } | 28 } |
29 | 29 |
30 } // namespace | 30 } // namespace |
31 | 31 |
32 RulesRegistryService::RulesRegistryService(Profile* profile) { | 32 RulesRegistryService::RulesRegistryService(Profile* profile) |
| 33 : profile_(profile) { |
33 if (profile) { | 34 if (profile) { |
34 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 35 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
35 content::Source<Profile>(profile)); | 36 content::Source<Profile>(profile)); |
36 } | 37 } |
37 } | 38 } |
38 | 39 |
39 RulesRegistryService::~RulesRegistryService() {} | 40 RulesRegistryService::~RulesRegistryService() {} |
40 | 41 |
41 void RulesRegistryService::RegisterDefaultRulesRegistries() { | 42 void RulesRegistryService::RegisterDefaultRulesRegistries() { |
42 scoped_refptr<WebRequestRulesRegistry> web_request_rules_registry( | 43 scoped_refptr<WebRequestRulesRegistry> web_request_rules_registry( |
43 new WebRequestRulesRegistry); | 44 new WebRequestRulesRegistry(profile_)); |
44 RegisterRulesRegistry(declarative_webrequest_constants::kOnRequest, | 45 RegisterRulesRegistry(declarative_webrequest_constants::kOnRequest, |
45 web_request_rules_registry); | 46 web_request_rules_registry); |
46 content::BrowserThread::PostTask( | 47 content::BrowserThread::PostTask( |
47 content::BrowserThread::IO, FROM_HERE, | 48 content::BrowserThread::IO, FROM_HERE, |
48 base::Bind(&RegisterToExtensionWebRequestEventRouterOnIO, | 49 base::Bind(&RegisterToExtensionWebRequestEventRouterOnIO, |
49 web_request_rules_registry)); | 50 web_request_rules_registry)); |
50 } | 51 } |
51 | 52 |
52 void RulesRegistryService::Shutdown() { | 53 void RulesRegistryService::Shutdown() { |
53 content::BrowserThread::PostTask( | 54 content::BrowserThread::PostTask( |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 OnExtensionUnloaded(extension->id()); | 105 OnExtensionUnloaded(extension->id()); |
105 break; | 106 break; |
106 } | 107 } |
107 default: | 108 default: |
108 NOTREACHED(); | 109 NOTREACHED(); |
109 break; | 110 break; |
110 } | 111 } |
111 } | 112 } |
112 | 113 |
113 } // namespace extensions | 114 } // namespace extensions |
OLD | NEW |