Chromium Code Reviews| Index: extensions/browser/api/declarative/rules_registry_service.h |
| diff --git a/extensions/browser/api/declarative/rules_registry_service.h b/extensions/browser/api/declarative/rules_registry_service.h |
| index 693d5e73c220b16d25618bc685682bcea0a8b670..57c4699a3dec3ea7ad822edffd031d087ebdea93 100644 |
| --- a/extensions/browser/api/declarative/rules_registry_service.h |
| +++ b/extensions/browser/api/declarative/rules_registry_service.h |
| @@ -38,18 +38,17 @@ class RulesRegistryService : public BrowserContextKeyedAPI, |
| public content::NotificationObserver, |
| public ExtensionRegistryObserver { |
| public: |
| - typedef RulesRegistry::WebViewKey WebViewKey; |
| + static const int kDefultRulesRegistryID = 0; |
|
Fady Samuel
2014/11/26 23:39:41
typo: kDefaultRulesRegistryID
Xi Han
2014/11/27 23:25:25
Renamed.
|
| + |
| struct RulesRegistryKey { |
| std::string event_name; |
| - WebViewKey webview_key; |
| - RulesRegistryKey(const std::string event_name, |
| - const WebViewKey& webview_key) |
| - : event_name(event_name), |
| - webview_key(webview_key) {} |
| + int rules_registry_id; |
| + RulesRegistryKey(const std::string event_name, int rules_registry_id) |
| + : event_name(event_name), rules_registry_id(rules_registry_id) {} |
|
Fady Samuel
2014/11/26 23:39:41
Put this on the next line.
Xi Han
2014/11/27 23:25:25
Done.
|
| bool operator<(const RulesRegistryKey& other) const { |
| return (event_name < other.event_name) || |
| - ((event_name == other.event_name) && |
| - (webview_key < other.webview_key)); |
| + ((event_name == other.event_name) && |
| + (rules_registry_id < other.rules_registry_id)); |
| } |
| }; |
| @@ -67,16 +66,20 @@ class RulesRegistryService : public BrowserContextKeyedAPI, |
| // Convenience method to get the RulesRegistryService for a context. |
| static RulesRegistryService* Get(content::BrowserContext* context); |
| + int GetNextRulesRegistryId(); |
|
Fady Samuel
2014/11/26 23:39:41
GetNextRulesRegistryID
Xi Han
2014/11/27 23:25:25
Done.
|
| + |
| // Registers the default RulesRegistries used in Chromium. |
| - void EnsureDefaultRulesRegistriesRegistered(const WebViewKey& webview_key); |
| + void EnsureDefaultRulesRegistriesRegistered(int rules_registry_id, |
| + bool is_web_view); |
|
Fady Samuel
2014/11/26 23:39:41
Avoid this is_web_view. Maybe instead:
GetNextRul
Xi Han
2014/11/27 23:25:25
Yes, this name is more clear.
|
| // Registers a RulesRegistry and wraps it in an InitializingRulesRegistry. |
| void RegisterRulesRegistry(scoped_refptr<RulesRegistry> rule_registry); |
| - // Returns the RulesRegistry for |event_name| and |webview_key| or NULL if no |
| - // such registry has been registered. Default rules registries (such as the |
| - // WebRequest rules registry) will be created on first access. |
| - scoped_refptr<RulesRegistry> GetRulesRegistry(const WebViewKey& webview_key, |
| + // Returns the RulesRegistry for |event_name| and |rules_registry_id| or |
| + // NULL if no such registry has been registered. Default rules registries |
| + // (such as the WebRequest rules registry) will be created on first access. |
| + scoped_refptr<RulesRegistry> GetRulesRegistry(int rules_registry_id, |
| + bool is_web_view, |
| const std::string& event_name); |
| // Accessors for each type of rules registry. |
| @@ -129,6 +132,8 @@ class RulesRegistryService : public BrowserContextKeyedAPI, |
| static const bool kServiceHasOwnInstanceInIncognito = true; |
| static const bool kServiceIsNULLWhileTesting = true; |
| + int current_rules_registry_id_; |
| + |
| RulesRegistryMap rule_registries_; |
| // We own the parts of the registries which need to run on the UI thread. |