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

Unified Diff: chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.h

Issue 11572061: Create DeclarativeConditionSet, DeclarativeActionSet, and DeclarativeRule templates (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix kalman's nit Created 7 years, 11 months 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_webrequest/webrequest_rules_registry.h
diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.h b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.h
index 6433f5ceead4f80f3e9a03f63fb8a05f1104bb2e..9746a9b7d7f5ece1825898a539dfdf264d9d5444 100644
--- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.h
+++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.h
@@ -14,9 +14,11 @@
#include "base/time.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
+#include "chrome/browser/extensions/api/declarative/declarative_rule.h"
#include "chrome/browser/extensions/api/declarative/rules_registry_with_cache.h"
#include "chrome/browser/extensions/api/declarative_webrequest/request_stage.h"
-#include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rule.h"
+#include "chrome/browser/extensions/api/declarative_webrequest/webrequest_action.h"
+#include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condition.h"
#include "chrome/browser/extensions/extension_info_map.h"
#include "chrome/common/extensions/matcher/url_matcher.h"
@@ -35,6 +37,10 @@ namespace extensions {
class RulesRegistryService;
+typedef linked_ptr<extension_web_request_api_helpers::EventResponseDelta>
+ LinkedPtrEventResponseDelta;
+typedef DeclarativeRule<WebRequestCondition, WebRequestAction> WebRequestRule;
+
// The WebRequestRulesRegistry is responsible for managing
// the internal representation of rules for the Declarative Web Request API.
//
@@ -70,13 +76,13 @@ class WebRequestRulesRegistry : public RulesRegistryWithCache {
// TODO(battre): This will become an implementation detail, because we need
// a way to also execute the actions of the rules.
std::set<const WebRequestRule*> GetMatches(
- const WebRequestRule::RequestData& request_data);
+ const DeclarativeWebRequestData& request_data);
// Returns which modifications should be executed on the network request
// according to the rules registered in this registry.
std::list<LinkedPtrEventResponseDelta> CreateDeltas(
const ExtensionInfoMap* extension_info_map,
- const WebRequestRule::RequestData& request_data,
+ const DeclarativeWebRequestData& request_data,
bool crosses_incognito);
// Implementation of RulesRegistryWithCache:
@@ -107,6 +113,14 @@ class WebRequestRulesRegistry : public RulesRegistryWithCache {
}
private:
+ // Checks whether the set of |conditions| and |actions| are consistent,
+ // meaning for example that we do not allow combining an |action| that needs
+ // to be executed before the |condition| can be fulfilled.
+ // Returns true in case of consistency and MUST set |error| otherwise.
+ static bool CheckConsistency(const WebRequestConditionSet* conditions,
+ const WebRequestActionSet* actions,
+ std::string* error);
+
typedef std::map<URLMatcherConditionSet::ID, WebRequestRule*> RuleTriggers;
typedef std::map<WebRequestRule::GlobalRuleId, linked_ptr<WebRequestRule> >
RulesMap;

Powered by Google App Engine
This is Rietveld 408576698