Chromium Code Reviews| Index: chrome/browser/extensions/api/declarative/rules_registry_service.h |
| diff --git a/chrome/browser/extensions/api/declarative/rules_registry_service.h b/chrome/browser/extensions/api/declarative/rules_registry_service.h |
| index aa51607d30611e8b999f67cdbe862c87a6db7960..2e36ee224d13f3a470d47051f05b2b94c2d0226a 100644 |
| --- a/chrome/browser/extensions/api/declarative/rules_registry_service.h |
| +++ b/chrome/browser/extensions/api/declarative/rules_registry_service.h |
| @@ -38,6 +38,9 @@ namespace extensions { |
| class RulesRegistryService : public ProfileKeyedAPI, |
| public content::NotificationObserver { |
| public: |
| + typedef RulesRegistry::WebViewKey WebViewKey; |
| + typedef std::pair<std::string, WebViewKey> RulesRegistryKey; |
| + |
| explicit RulesRegistryService(Profile* profile); |
| virtual ~RulesRegistryService(); |
| @@ -52,35 +55,46 @@ class RulesRegistryService : public ProfileKeyedAPI, |
| static RulesRegistryService* Get(Profile* profile); |
| // Registers the default RulesRegistries used in Chromium. |
| - void RegisterDefaultRulesRegistries(); |
| + void RegisterDefaultRulesRegistriesIfNotAvailable( |
| + const WebViewKey& webview_key); |
| // Registers a RulesRegistry and wraps it in an InitializingRulesRegistry. |
| void RegisterRulesRegistry(scoped_refptr<RulesRegistry> rule_registry); |
| - // Returns the RulesRegistry for |event_name| or NULL if no such registry |
| - // has been registered. |
| + // Returns the RulesRegistry for |event_name| and |webview_key| orr NULL if no |
| + // such registry has been registered. |
|
vabr (Chromium)
2013/11/04 11:12:13
This comment is more precise now, but it still doe
Fady Samuel
2013/11/04 20:13:53
Done.
|
| scoped_refptr<RulesRegistry> GetRulesRegistry( |
| - const std::string& event_name) const; |
| + const WebViewKey& webview_key, |
| + const std::string& event_name); |
| - // Accessors for each type of rules registry. |
| - ContentRulesRegistry* content_rules_registry() const { |
| - return content_rules_registry_; |
| - } |
| + // Accessors for each type of rules registry. This method will install default |
| + // rules registries if they haven't been installed yet. |
| + ContentRulesRegistry* GetContentRulesRegistry(); |
| + |
| + // Removes all rules registries of a given webview embedder process ID. |
| + void RemoveWebViewRulesRegistries(int process_id); |
| // For testing. |
| void SimulateExtensionUnloaded(const std::string& extension_id); |
| private: |
| friend class ProfileKeyedAPIFactory<RulesRegistryService>; |
| - // Maps event names to RuleRegistries that handle these events. |
| - typedef std::map<std::string, scoped_refptr<RulesRegistry> > |
| + // Maps <event name, webview key> to RuleRegistries that handle these |
| + // events. |
| + typedef std::map<RulesRegistryKey, scoped_refptr<RulesRegistry> > |
| RulesRegistryMap; |
| + typedef std::set<WebViewKey> WebViewKeySet; |
| + typedef std::set<RulesRegistryKey> RulesRegistryKeySet; |
| + |
| // Notifies all RulesRegistries that |extension_id| was unloaded. |
| // It is not guaranteed that this notification is processed synchronously. |
| // If extensions live on another thread, the notification is posted. |
| void OnExtensionUnloaded(const std::string& extension_id); |
| + // Removes a rules registry associated with a given |key|. |
| + void RemoveRulesRegistry(const RulesRegistryKey& key); |
| + |
| // Implementation of content::NotificationObserver. |
| virtual void Observe(int type, |
| const content::NotificationSource& source, |
| @@ -95,6 +109,10 @@ class RulesRegistryService : public ProfileKeyedAPI, |
| RulesRegistryMap rule_registries_; |
| + // Indicates the set of <webview>s that have default rule registries |
| + // installed. |
| + WebViewKeySet installed_rules_registries_; |
| + |
| // We own the parts of the registries which need to run on the UI thread. |
| ScopedVector<RulesCacheDelegate> cache_delegates_; |