OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITIO N_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITIO N_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITIO N_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITIO N_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 | 42 |
43 // Factory method that instantiates a WebRequestCondition according to | 43 // Factory method that instantiates a WebRequestCondition according to |
44 // the description |condition| passed by the extension API. | 44 // the description |condition| passed by the extension API. |
45 static scoped_ptr<WebRequestCondition> Create( | 45 static scoped_ptr<WebRequestCondition> Create( |
46 URLMatcherConditionFactory* url_matcher_condition_factory, | 46 URLMatcherConditionFactory* url_matcher_condition_factory, |
47 const base::Value& condition, | 47 const base::Value& condition, |
48 std::string* error); | 48 std::string* error); |
49 | 49 |
50 // Returns whether the request is a match, given that the URLMatcher found | 50 // Returns whether the request is a match, given that the URLMatcher found |
51 // a match for |url_matcher_conditions_|. | 51 // a match for |url_matcher_conditions_|. |
52 bool IsFulfilled(const WebRequestRule::RequestData& request_data) const; | 52 bool IsFulfilled(const WebRequestRule::RequestData& request_data) const; |
battre
2012/12/18 08:20:44
nit: can you add a new line here, please?
vabr (Chromium)
2012/12/18 18:26:42
Done.
| |
53 // Returns true iff the request is a match and no condition attribute of this | |
54 // condition is a UrlFilter. | |
55 bool IsFulfilledIndependentlyOfURL( | |
56 const WebRequestRule::RequestData& request_data) const; | |
53 | 57 |
54 // Returns a URLMatcherConditionSet::ID which is the canonical representation | 58 // Returns a URLMatcherConditionSet::ID which is the canonical representation |
55 // for all URL patterns that need to be matched by this WebRequestCondition. | 59 // for all URL patterns that need to be matched by this WebRequestCondition. |
56 // This ID is registered in a URLMatcher that can inform us in case of a | 60 // This ID is registered in a URLMatcher that can inform us in case of a |
57 // match. | 61 // match. |
58 URLMatcherConditionSet::ID url_matcher_condition_set_id() const { | 62 URLMatcherConditionSet::ID url_matcher_condition_set_id() const { |
63 CHECK(url_matcher_conditions_.get()); | |
vabr (Chromium)
2012/12/13 12:18:06
This check is needed because now it is possible to
Jeffrey Yasskin
2012/12/18 02:24:32
I believe Chrome convention is to DCHECK in this c
vabr (Chromium)
2012/12/18 18:26:42
TIL, thanks! Done.
| |
59 return url_matcher_conditions_->id(); | 64 return url_matcher_conditions_->id(); |
60 } | 65 } |
61 | 66 |
62 // Returns the set of conditions that are checked on the URL. This is the | 67 // Returns the set of conditions that are checked on the URL. This is the |
63 // primary trigger for WebRequestCondition and therefore never empty. | 68 // primary trigger for WebRequestCondition and therefore never empty. |
64 // (If it was empty, the URLMatcher would never notify us about network | 69 // (If it was empty, the URLMatcher would never notify us about network |
65 // requests which might fulfill the entire WebRequestCondition). | 70 // requests which might fulfill the entire WebRequestCondition). |
66 scoped_refptr<URLMatcherConditionSet> url_matcher_condition_set() const { | 71 scoped_refptr<URLMatcherConditionSet> url_matcher_condition_set() const { |
67 return url_matcher_conditions_; | 72 return url_matcher_conditions_; |
68 } | 73 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 | 118 |
114 // Returns whether any condition in the condition set is fulfilled | 119 // Returns whether any condition in the condition set is fulfilled |
115 // based on a match |url_match| and the value of |request_data.request|. | 120 // based on a match |url_match| and the value of |request_data.request|. |
116 // This function should be called for each URLMatcherConditionSet::ID | 121 // This function should be called for each URLMatcherConditionSet::ID |
117 // that was found by the URLMatcher to ensure that the each trigger in | 122 // that was found by the URLMatcher to ensure that the each trigger in |
118 // |match_triggers_| is found. | 123 // |match_triggers_| is found. |
119 bool IsFulfilled( | 124 bool IsFulfilled( |
120 URLMatcherConditionSet::ID url_match, | 125 URLMatcherConditionSet::ID url_match, |
121 const WebRequestRule::RequestData& request_data) const; | 126 const WebRequestRule::RequestData& request_data) const; |
122 | 127 |
128 // Returns whether any condition in the condition set is fulfilled even when | |
129 // no URL match has been triggered. Same as |IsFulfilled|, but only | |
130 // considering conditions which don't have UrlFilter attributes. | |
131 bool IsFulfilledWithoutURLMatcher( | |
132 const WebRequestRule::RequestData& request_data) const; | |
133 | |
123 // Appends the URLMatcherConditionSet from all conditions to |condition_sets|. | 134 // Appends the URLMatcherConditionSet from all conditions to |condition_sets|. |
124 void GetURLMatcherConditionSets( | 135 void GetURLMatcherConditionSets( |
125 URLMatcherConditionSet::Vector* condition_sets) const; | 136 URLMatcherConditionSet::Vector* condition_sets) const; |
126 | 137 |
138 // Returns whether there are some conditions without UrlFilter attributes. | |
139 bool has_untriggered_conditions() const { | |
Jeffrey Yasskin
2012/12/18 02:24:32
"untriggered" isn't a great word for this. Perhaps
vabr (Chromium)
2012/12/18 18:26:42
Done.
| |
140 return has_untriggered_conditions_; | |
141 } | |
142 | |
127 private: | 143 private: |
128 Conditions conditions_; | |
129 | |
130 typedef std::map<URLMatcherConditionSet::ID, WebRequestCondition*> | 144 typedef std::map<URLMatcherConditionSet::ID, WebRequestCondition*> |
vabr (Chromium)
2012/12/13 12:18:06
Typedefs should be before variables, so I reshuffl
| |
131 MatchTriggers; | 145 MatchTriggers; |
146 | |
147 // Returns whether there is a condition among |conditions| which has no | |
148 // URLMatcherConditionSet assigned. | |
149 static bool IsSomeConditionWithoutUrlMatcher( | |
battre
2012/12/18 08:20:44
nit: ContainsConditionWithoutUrlMatcher?
vabr (Chromium)
2012/12/18 18:26:42
Already changed due to Jeffrey's comment (HasCondi
| |
150 const WebRequestConditionSet::Conditions& conditions); | |
151 | |
132 MatchTriggers match_triggers_; | 152 MatchTriggers match_triggers_; |
133 | 153 |
154 const Conditions conditions_; | |
155 const bool has_untriggered_conditions_; | |
156 | |
134 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionSet); | 157 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionSet); |
135 }; | 158 }; |
136 | 159 |
137 } // namespace extensions | 160 } // namespace extensions |
138 | 161 |
139 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDI TION_H_ | 162 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDI TION_H_ |
OLD | NEW |