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 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ |
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/scoped_observer.h" | 15 #include "base/scoped_observer.h" |
16 #include "chrome/browser/extensions/api/declarative/rules_registry.h" | 16 #include "chrome/browser/extensions/api/declarative/rules_registry.h" |
17 #include "chrome/browser/profiles/profile.h" | |
18 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
19 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
20 #include "extensions/browser/browser_context_keyed_api_factory.h" | 19 #include "extensions/browser/browser_context_keyed_api_factory.h" |
21 #include "extensions/browser/extension_registry_observer.h" | 20 #include "extensions/browser/extension_registry_observer.h" |
22 | 21 |
23 class Profile; | |
24 | |
25 namespace content { | 22 namespace content { |
26 class BrowserContext; | 23 class BrowserContext; |
27 class NotificationSource; | 24 class NotificationSource; |
28 } | 25 } |
29 | 26 |
30 namespace extensions { | 27 namespace extensions { |
31 class ContentRulesRegistry; | 28 class ContentRulesRegistry; |
32 class ExtensionRegistry; | 29 class ExtensionRegistry; |
33 class RulesRegistry; | 30 class RulesRegistry; |
34 class RulesRegistryStorageDelegate; | 31 class RulesRegistryStorageDelegate; |
(...skipping 26 matching lines...) Expand all Loading... |
61 virtual ~RulesRegistryService(); | 58 virtual ~RulesRegistryService(); |
62 | 59 |
63 // Unregisters refptrs to concrete RulesRegistries at other objects that were | 60 // Unregisters refptrs to concrete RulesRegistries at other objects that were |
64 // created by us so that the RulesRegistries can be released. | 61 // created by us so that the RulesRegistries can be released. |
65 virtual void Shutdown() OVERRIDE; | 62 virtual void Shutdown() OVERRIDE; |
66 | 63 |
67 // BrowserContextKeyedAPI implementation. | 64 // BrowserContextKeyedAPI implementation. |
68 static BrowserContextKeyedAPIFactory<RulesRegistryService>* | 65 static BrowserContextKeyedAPIFactory<RulesRegistryService>* |
69 GetFactoryInstance(); | 66 GetFactoryInstance(); |
70 | 67 |
71 // Convenience method to get the RulesRegistryService for a profile. | 68 // Convenience method to get the RulesRegistryService for a context. |
72 static RulesRegistryService* Get(content::BrowserContext* context); | 69 static RulesRegistryService* Get(content::BrowserContext* context); |
73 | 70 |
74 // Registers the default RulesRegistries used in Chromium. | 71 // Registers the default RulesRegistries used in Chromium. |
75 void EnsureDefaultRulesRegistriesRegistered(const WebViewKey& webview_key); | 72 void EnsureDefaultRulesRegistriesRegistered(const WebViewKey& webview_key); |
76 | 73 |
77 // Registers a RulesRegistry and wraps it in an InitializingRulesRegistry. | 74 // Registers a RulesRegistry and wraps it in an InitializingRulesRegistry. |
78 void RegisterRulesRegistry(scoped_refptr<RulesRegistry> rule_registry); | 75 void RegisterRulesRegistry(scoped_refptr<RulesRegistry> rule_registry); |
79 | 76 |
80 // Returns the RulesRegistry for |event_name| and |webview_key| or NULL if no | 77 // Returns the RulesRegistry for |event_name| and |webview_key| or NULL if no |
81 // such registry has been registered. Default rules registries (such as the | 78 // such registry has been registered. Default rules registries (such as the |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 // Weak pointer into rule_registries_ to make it easier to handle content rule | 141 // Weak pointer into rule_registries_ to make it easier to handle content rule |
145 // conditions. | 142 // conditions. |
146 ContentRulesRegistry* content_rules_registry_; | 143 ContentRulesRegistry* content_rules_registry_; |
147 | 144 |
148 content::NotificationRegistrar registrar_; | 145 content::NotificationRegistrar registrar_; |
149 | 146 |
150 // Listen to extension load, unloaded notification. | 147 // Listen to extension load, unloaded notification. |
151 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 148 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
152 extension_registry_observer_; | 149 extension_registry_observer_; |
153 | 150 |
154 Profile* profile_; | 151 content::BrowserContext* browser_context_; |
155 | 152 |
156 DISALLOW_COPY_AND_ASSIGN(RulesRegistryService); | 153 DISALLOW_COPY_AND_ASSIGN(RulesRegistryService); |
157 }; | 154 }; |
158 | 155 |
159 } // namespace extensions | 156 } // namespace extensions |
160 | 157 |
161 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ | 158 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ |
OLD | NEW |