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

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

Issue 28273006: <webview>: Implement declarativeWebRequest API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nits 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.h
diff --git a/chrome/browser/extensions/api/declarative/rules_registry.h b/chrome/browser/extensions/api/declarative/rules_registry.h
index f877a656dfb5587cd172fd546f7862ecefd436f9..ae16269d23b73b6c0afb2da02d0460e221a18172 100644
--- a/chrome/browser/extensions/api/declarative/rules_registry.h
+++ b/chrome/browser/extensions/api/declarative/rules_registry.h
@@ -40,6 +40,18 @@ class RulesCacheDelegate;
class RulesRegistry : public base::RefCountedThreadSafe<RulesRegistry> {
public:
typedef extensions::api::events::Rule Rule;
+ struct WebViewKey {
+ int embedder_process_id;
+ int webview_instance_id;
+ WebViewKey(int embedder_process_id, int webview_instance_id)
+ : embedder_process_id(embedder_process_id),
+ webview_instance_id(webview_instance_id) {}
+ bool operator<(const WebViewKey& other) const {
+ return embedder_process_id < other.embedder_process_id ||
+ ((embedder_process_id == other.embedder_process_id) &&
+ (webview_instance_id < other.webview_instance_id));
+ }
+ };
enum Defaults { DEFAULT_PRIORITY = 100 };
// After the RulesCacheDelegate object (the part of the registry which runs on
@@ -50,7 +62,8 @@ class RulesRegistry : public base::RefCountedThreadSafe<RulesRegistry> {
RulesRegistry(Profile* profile,
const std::string& event_name,
content::BrowserThread::ID owner_thread,
- RulesCacheDelegate* cache_delegate);
+ RulesCacheDelegate* cache_delegate,
+ const WebViewKey& webview_key);
const OneShotEvent& ready() const {
return ready_;
@@ -120,6 +133,11 @@ class RulesRegistry : public base::RefCountedThreadSafe<RulesRegistry> {
// Every ExtensionId counts as one entry, even if it contains no rules.
size_t GetNumberOfUsedRuleIdentifiersForTesting() const;
+ // Returns the RulesCacheDelegate. This is used for testing.
+ RulesCacheDelegate* rules_cache_delegate_for_testing() const {
+ return cache_delegate_.get();
+ }
+
// Returns the profile where the rules registry lives.
Profile* profile() const { return profile_; }
@@ -130,6 +148,12 @@ class RulesRegistry : public base::RefCountedThreadSafe<RulesRegistry> {
// The name of the event with which rules are registered.
const std::string& event_name() const { return event_name_; }
+ // The key that identifies the webview (or tabs) in which these rules apply.
+ // If the rules apply to the main browser, then this returns the tuple (0, 0).
+ const WebViewKey& webview_key() const {
+ return webview_key_;
+ }
+
protected:
virtual ~RulesRegistry();
@@ -192,6 +216,9 @@ class RulesRegistry : public base::RefCountedThreadSafe<RulesRegistry> {
// The name of the event with which rules are registered.
const std::string event_name_;
+ // The key that identifies the context in which these rules apply.
+ WebViewKey webview_key_;
+
RulesDictionary rules_;
// Signaled when we have finished reading from storage for all extensions that

Powered by Google App Engine
This is Rietveld 408576698