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..7030ac76c305b06a94098c4fd5fe11acd42f14f4 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; |
|
Jeffrey Yasskin
2013/11/09 02:47:22
Similarly, this should at the very least have a co
Fady Samuel
2013/11/10 03:39:56
Made it a struct. I agree, this is far more readab
|
| + |
| explicit RulesRegistryService(Profile* profile); |
| virtual ~RulesRegistryService(); |
| @@ -52,35 +55,50 @@ class RulesRegistryService : public ProfileKeyedAPI, |
| static RulesRegistryService* Get(Profile* profile); |
| // Registers the default RulesRegistries used in Chromium. |
| - void RegisterDefaultRulesRegistries(); |
| + void RegisterDefaultRulesRegistriesIfNotAvailable( |
|
Jeffrey Yasskin
2013/11/09 02:47:22
If what aren't available? If this is a "do it the
Fady Samuel
2013/11/10 03:39:56
Done.
|
| + 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| or NULL if no |
| + // such registry has been registered. Default rules registries (such as the |
|
Jeffrey Yasskin
2013/11/09 02:47:22
Can this return NULL anymore, since it auto-regist
Fady Samuel
2013/11/10 03:39:56
Yes, it's possible for this to return NULL if ther
|
| + // WebRequest rules registry) will be created on first access. |
| 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. |
| + // Accessors for each type of rules registry. This method will install default |
| + // rules registries if they haven't been installed yet. |
|
Jeffrey Yasskin
2013/11/09 02:47:22
No it won't. :)
Fady Samuel
2013/11/10 03:39:56
Doh. Stale comment. Removed!
|
| ContentRulesRegistry* content_rules_registry() const { |
| + CHECK(content_rules_registry_); |
| return content_rules_registry_; |
| } |
| + // 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; |
|
Jeffrey Yasskin
2013/11/09 02:47:22
FWIW, I'm not a fan of typedefs that save 7 charac
Fady Samuel
2013/11/10 03:39:56
Removed.
|
| + typedef std::set<RulesRegistryKey> RulesRegistryKeySet; |
|
Jeffrey Yasskin
2013/11/09 02:47:22
This doesn't look used.
Fady Samuel
2013/11/10 03:39:56
Removed.
|
| + |
| // 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 +113,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_; |