| 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" | |
| 17 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 18 #include "extensions/browser/api/declarative/rules_registry.h" |
| 19 #include "extensions/browser/browser_context_keyed_api_factory.h" | 19 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 20 #include "extensions/browser/extension_registry_observer.h" | 20 #include "extensions/browser/extension_registry_observer.h" |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 class BrowserContext; | 23 class BrowserContext; |
| 24 class NotificationSource; | 24 class NotificationSource; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace extensions { | 27 namespace extensions { |
| 28 class ContentRulesRegistry; | 28 class ContentRulesRegistry; |
| 29 class ExtensionRegistry; | 29 class ExtensionRegistry; |
| 30 class RulesRegistry; | |
| 31 class RulesRegistryStorageDelegate; | 30 class RulesRegistryStorageDelegate; |
| 32 } | 31 } |
| 33 | 32 |
| 34 namespace extensions { | 33 namespace extensions { |
| 35 | 34 |
| 36 // This class owns all RulesRegistries implementations of an ExtensionService. | 35 // This class owns all RulesRegistries implementations of an ExtensionService. |
| 37 // This class lives on the UI thread. | 36 // This class lives on the UI thread. |
| 38 class RulesRegistryService : public BrowserContextKeyedAPI, | 37 class RulesRegistryService : public BrowserContextKeyedAPI, |
| 39 public content::NotificationObserver, | 38 public content::NotificationObserver, |
| 40 public ExtensionRegistryObserver { | 39 public ExtensionRegistryObserver { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 70 | 69 |
| 71 // Registers the default RulesRegistries used in Chromium. | 70 // Registers the default RulesRegistries used in Chromium. |
| 72 void EnsureDefaultRulesRegistriesRegistered(const WebViewKey& webview_key); | 71 void EnsureDefaultRulesRegistriesRegistered(const WebViewKey& webview_key); |
| 73 | 72 |
| 74 // Registers a RulesRegistry and wraps it in an InitializingRulesRegistry. | 73 // Registers a RulesRegistry and wraps it in an InitializingRulesRegistry. |
| 75 void RegisterRulesRegistry(scoped_refptr<RulesRegistry> rule_registry); | 74 void RegisterRulesRegistry(scoped_refptr<RulesRegistry> rule_registry); |
| 76 | 75 |
| 77 // Returns the RulesRegistry for |event_name| and |webview_key| or NULL if no | 76 // Returns the RulesRegistry for |event_name| and |webview_key| or NULL if no |
| 78 // such registry has been registered. Default rules registries (such as the | 77 // such registry has been registered. Default rules registries (such as the |
| 79 // WebRequest rules registry) will be created on first access. | 78 // WebRequest rules registry) will be created on first access. |
| 80 scoped_refptr<RulesRegistry> GetRulesRegistry( | 79 scoped_refptr<RulesRegistry> GetRulesRegistry(const WebViewKey& webview_key, |
| 81 const WebViewKey& webview_key, | 80 const std::string& event_name); |
| 82 const std::string& event_name); | |
| 83 | 81 |
| 84 // Accessors for each type of rules registry. | 82 // Accessors for each type of rules registry. |
| 85 ContentRulesRegistry* content_rules_registry() const { | 83 ContentRulesRegistry* content_rules_registry() const { |
| 86 CHECK(content_rules_registry_); | 84 CHECK(content_rules_registry_); |
| 87 return content_rules_registry_; | 85 return content_rules_registry_; |
| 88 } | 86 } |
| 89 | 87 |
| 90 // Removes all rules registries of a given webview embedder process ID. | 88 // Removes all rules registries of a given webview embedder process ID. |
| 91 void RemoveWebViewRulesRegistries(int process_id); | 89 void RemoveWebViewRulesRegistries(int process_id); |
| 92 | 90 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 extension_registry_observer_; | 147 extension_registry_observer_; |
| 150 | 148 |
| 151 content::BrowserContext* browser_context_; | 149 content::BrowserContext* browser_context_; |
| 152 | 150 |
| 153 DISALLOW_COPY_AND_ASSIGN(RulesRegistryService); | 151 DISALLOW_COPY_AND_ASSIGN(RulesRegistryService); |
| 154 }; | 152 }; |
| 155 | 153 |
| 156 } // namespace extensions | 154 } // namespace extensions |
| 157 | 155 |
| 158 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ | 156 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ |
| OLD | NEW |