Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1484)

Unified Diff: chrome/browser/extensions/api/declarative/rules_registry_service.h

Issue 28273006: <webview>: Implement declarativeWebRequest API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Istiaque's comments Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+
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(
+ 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
+ // 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.
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;
+ 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 +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_;

Powered by Google App Engine
This is Rietveld 408576698