Index: chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute.h |
diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute.h b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute.h |
index cc5d2518e12746e82ef3fda3903e03f2cf3d99cc..d502544cb38ae5dfcb19a59e9b81c55042144bfa 100644 |
--- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute.h |
+++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute.h |
@@ -36,6 +36,7 @@ class WebRequestConditionAttribute { |
enum Type { |
CONDITION_RESOURCE_TYPE, |
CONDITION_CONTENT_TYPE, |
+ CONDITION_REQUEST_HEADERS, |
CONDITION_RESPONSE_HEADERS |
}; |
@@ -138,6 +139,40 @@ class WebRequestConditionAttributeContentType |
DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeContentType); |
}; |
+// Condition attribute for matching against request headers. Uses HeaderMatcher |
+// to handle the actual tests, in connection with a boolean positiveness |
+// flag. If that flag is set to true, then IsFulfilled() returns true iff |
+// |header_matcher_| matches at least one header. Otherwise IsFulfilled() |
+// returns true iff the |header_matcher_| matches no header. |
+class WebRequestConditionAttributeRequestHeaders |
+ : public WebRequestConditionAttribute { |
+ public: |
+ virtual ~WebRequestConditionAttributeRequestHeaders(); |
+ |
+ static bool IsMatchingType(const std::string& instance_type); |
+ |
+ // Factory method, see WebRequestConditionAttribute::Create. |
+ static scoped_ptr<WebRequestConditionAttribute> Create( |
+ const std::string& name, |
+ const base::Value* value, |
+ std::string* error); |
+ |
+ // Implementation of WebRequestConditionAttribute: |
+ virtual int GetStages() const OVERRIDE; |
+ virtual bool IsFulfilled( |
+ const WebRequestRule::RequestData& request_data) const OVERRIDE; |
+ virtual Type GetType() const OVERRIDE; |
+ |
+ private: |
+ WebRequestConditionAttributeRequestHeaders( |
+ scoped_ptr<const HeaderMatcher> header_matcher, bool positive); |
+ |
+ const scoped_ptr<const HeaderMatcher> header_matcher_; |
+ const bool positive_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeRequestHeaders); |
+}; |
+ |
// Condition attribute for matching against response headers. Uses HeaderMatcher |
// to handle the actual tests, in connection with a boolean positiveness |
// flag. If that flag is set to true, then IsFulfilled() returns true iff |
@@ -164,7 +199,7 @@ class WebRequestConditionAttributeResponseHeaders |
private: |
WebRequestConditionAttributeResponseHeaders( |
- scoped_ptr<const HeaderMatcher>* header_matcher, bool positive); |
+ scoped_ptr<const HeaderMatcher> header_matcher, bool positive); |
const scoped_ptr<const HeaderMatcher> header_matcher_; |
const bool positive_; |