Chromium Code Reviews| Index: chrome/browser/extensions/api/declarative_webrequest/webrequest_condition.h |
| diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition.h b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition.h |
| index 922dba7f111ffdc12352c2e06703c3fa828e3197..c22d9385923e28531d916a29f8c82f77a1346adb 100644 |
| --- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition.h |
| +++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition.h |
| @@ -5,6 +5,7 @@ |
| #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITION_H_ |
| #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITION_H_ |
| +#include <set> |
| #include <string> |
| #include <vector> |
| @@ -47,22 +48,21 @@ class WebRequestCondition { |
| const base::Value& condition, |
| std::string* error); |
| - // Returns whether the request is a match, given that the URLMatcher found |
| - // a match for |url_matcher_conditions_|. |
| - bool IsFulfilled(const WebRequestRule::RequestData& request_data) const; |
| + // Returns whether the request matches this condition. |url_matches| lists |
| + // the IDs that match the request's URL. |
| + bool IsFulfilled(const std::set<URLMatcherConditionSet::ID>& url_matches, |
| + const WebRequestRule::RequestData& request_data) const; |
| // Returns a URLMatcherConditionSet::ID which is the canonical representation |
| // for all URL patterns that need to be matched by this WebRequestCondition. |
| // This ID is registered in a URLMatcher that can inform us in case of a |
| // match. |
| URLMatcherConditionSet::ID url_matcher_condition_set_id() const { |
| + DCHECK(url_matcher_conditions_.get()); |
| return url_matcher_conditions_->id(); |
| } |
| - // Returns the set of conditions that are checked on the URL. This is the |
| - // primary trigger for WebRequestCondition and therefore never empty. |
| - // (If it was empty, the URLMatcher would never notify us about network |
| - // requests which might fulfill the entire WebRequestCondition). |
| + // Returns the set of conditions that are checked on the URL. May be NULL. |
| scoped_refptr<URLMatcherConditionSet> url_matcher_condition_set() const { |
| return url_matcher_conditions_; |
| } |
| @@ -78,7 +78,11 @@ class WebRequestCondition { |
| int stages() const { return applicable_request_stages_; } |
| private: |
| + // Represents the 'url' attribute of this condition. If NULL then there was no |
|
battre
2012/12/19 14:38:01
NULL,
vabr (Chromium)
2012/12/19 18:26:52
Done.
|
| + // 'url' attribute in this condition. |
| scoped_refptr<URLMatcherConditionSet> url_matcher_conditions_; |
| + |
| + // All non-UrlFilter attributes of this condition. |
| WebRequestConditionAttributes condition_attributes_; |
| // Bit vector indicating all RequestStage during which all |
| @@ -111,25 +115,25 @@ class WebRequestConditionSet { |
| return conditions_; |
| } |
| - // Returns whether any condition in the condition set is fulfilled |
| - // based on a match |url_match| and the value of |request_data.request|. |
| - // This function should be called for each URLMatcherConditionSet::ID |
| - // that was found by the URLMatcher to ensure that the each trigger in |
| - // |match_triggers_| is found. |
| + // Returns whether any condition in the condition set is fulfilled. Filters |
| + // out conditions which have UrlFilter attributes but are not listed in |
| + // |url_matches|, and tests the rest against |request_data.request|. |
|
battre
2012/12/19 14:38:01
I find the second sentence hard to parse.
Returns
vabr (Chromium)
2012/12/19 18:26:52
Done.
|
| bool IsFulfilled( |
| - URLMatcherConditionSet::ID url_match, |
| + const std::set<URLMatcherConditionSet::ID>& url_matches, |
| const WebRequestRule::RequestData& request_data) const; |
| // Appends the URLMatcherConditionSet from all conditions to |condition_sets|. |
| void GetURLMatcherConditionSets( |
| URLMatcherConditionSet::Vector* condition_sets) const; |
| - private: |
| - Conditions conditions_; |
| + // Returns whether there are some conditions without UrlFilter attributes. |
| + bool has_conditions_without_urls() const { |
| + return has_conditions_without_urls_; |
| + } |
| - typedef std::map<URLMatcherConditionSet::ID, WebRequestCondition*> |
| - MatchTriggers; |
| - MatchTriggers match_triggers_; |
| + private: |
| + const Conditions conditions_; |
| + const bool has_conditions_without_urls_; |
| DISALLOW_COPY_AND_ASSIGN(WebRequestConditionSet); |
| }; |