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_ATTRIBUTE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITIO
N_ATTRIBUTE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITIO
N_ATTRIBUTE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITIO
N_ATTRIBUTE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 class HeaderMatcher; | 30 class HeaderMatcher; |
31 | 31 |
32 // Base class for all condition attributes of the declarative Web Request API | 32 // Base class for all condition attributes of the declarative Web Request API |
33 // except for condition attribute to test URLPatterns. | 33 // except for condition attribute to test URLPatterns. |
34 class WebRequestConditionAttribute { | 34 class WebRequestConditionAttribute { |
35 public: | 35 public: |
36 enum Type { | 36 enum Type { |
37 CONDITION_RESOURCE_TYPE, | 37 CONDITION_RESOURCE_TYPE, |
38 CONDITION_CONTENT_TYPE, | 38 CONDITION_CONTENT_TYPE, |
39 CONDITION_RESPONSE_HEADERS | 39 CONDITION_RESPONSE_HEADERS, |
| 40 CONDITION_THIRD_PARTY |
40 }; | 41 }; |
41 | 42 |
42 WebRequestConditionAttribute(); | 43 WebRequestConditionAttribute(); |
43 virtual ~WebRequestConditionAttribute(); | 44 virtual ~WebRequestConditionAttribute(); |
44 | 45 |
45 // Factory method that creates a WebRequestConditionAttribute for the JSON | 46 // Factory method that creates a WebRequestConditionAttribute for the JSON |
46 // dictionary {|name|: |value|} passed by the extension API. Sets |error| and | 47 // dictionary {|name|: |value|} passed by the extension API. Sets |error| and |
47 // returns NULL if something fails. | 48 // returns NULL if something fails. |
48 // The ownership of |value| remains at the caller. | 49 // The ownership of |value| remains at the caller. |
49 static scoped_ptr<WebRequestConditionAttribute> Create( | 50 static scoped_ptr<WebRequestConditionAttribute> Create( |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 private: | 166 private: |
166 WebRequestConditionAttributeResponseHeaders( | 167 WebRequestConditionAttributeResponseHeaders( |
167 scoped_ptr<const HeaderMatcher>* header_matcher, bool positive); | 168 scoped_ptr<const HeaderMatcher>* header_matcher, bool positive); |
168 | 169 |
169 const scoped_ptr<const HeaderMatcher> header_matcher_; | 170 const scoped_ptr<const HeaderMatcher> header_matcher_; |
170 const bool positive_; | 171 const bool positive_; |
171 | 172 |
172 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeResponseHeaders); | 173 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeResponseHeaders); |
173 }; | 174 }; |
174 | 175 |
| 176 // This condition tests whether the request origin is third-party. |
| 177 class WebRequestConditionAttributeThirdParty |
| 178 : public WebRequestConditionAttribute { |
| 179 public: |
| 180 virtual ~WebRequestConditionAttributeThirdParty(); |
| 181 |
| 182 static bool IsMatchingType(const std::string& instance_type); |
| 183 |
| 184 // Factory method, see WebRequestConditionAttribute::Create. |
| 185 static scoped_ptr<WebRequestConditionAttribute> Create( |
| 186 const std::string& name, |
| 187 const base::Value* value, |
| 188 std::string* error); |
| 189 |
| 190 // Implementation of WebRequestConditionAttribute: |
| 191 virtual int GetStages() const OVERRIDE; |
| 192 virtual bool IsFulfilled( |
| 193 const WebRequestRule::RequestData& request_data) const OVERRIDE; |
| 194 virtual Type GetType() const OVERRIDE; |
| 195 |
| 196 private: |
| 197 explicit WebRequestConditionAttributeThirdParty(bool match_third_party); |
| 198 |
| 199 const bool match_third_party_; |
| 200 |
| 201 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeThirdParty); |
| 202 }; |
| 203 |
175 } // namespace extensions | 204 } // namespace extensions |
176 | 205 |
177 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDI
TION_ATTRIBUTE_H_ | 206 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDI
TION_ATTRIBUTE_H_ |
OLD | NEW |