| 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 EXTENSIONS_BROWSER_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITION_ATTRI
BUTE_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITION_ATTRI
BUTE_H_ |
| 6 #define EXTENSIONS_BROWSER_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITION_ATTRI
BUTE_H_ | 6 #define EXTENSIONS_BROWSER_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITION_ATTRI
BUTE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 : public WebRequestConditionAttribute { | 89 : public WebRequestConditionAttribute { |
| 90 public: | 90 public: |
| 91 // Factory method, see WebRequestConditionAttribute::Create. | 91 // Factory method, see WebRequestConditionAttribute::Create. |
| 92 static scoped_refptr<const WebRequestConditionAttribute> Create( | 92 static scoped_refptr<const WebRequestConditionAttribute> Create( |
| 93 const std::string& instance_type, | 93 const std::string& instance_type, |
| 94 const base::Value* value, | 94 const base::Value* value, |
| 95 std::string* error, | 95 std::string* error, |
| 96 bool* bad_message); | 96 bool* bad_message); |
| 97 | 97 |
| 98 // Implementation of WebRequestConditionAttribute: | 98 // Implementation of WebRequestConditionAttribute: |
| 99 virtual int GetStages() const override; | 99 int GetStages() const override; |
| 100 virtual bool IsFulfilled( | 100 bool IsFulfilled(const WebRequestData& request_data) const override; |
| 101 const WebRequestData& request_data) const override; | 101 Type GetType() const override; |
| 102 virtual Type GetType() const override; | 102 std::string GetName() const override; |
| 103 virtual std::string GetName() const override; | 103 bool Equals(const WebRequestConditionAttribute* other) const override; |
| 104 virtual bool Equals(const WebRequestConditionAttribute* other) const override; | |
| 105 | 104 |
| 106 private: | 105 private: |
| 107 explicit WebRequestConditionAttributeResourceType( | 106 explicit WebRequestConditionAttributeResourceType( |
| 108 const std::vector<content::ResourceType>& types); | 107 const std::vector<content::ResourceType>& types); |
| 109 virtual ~WebRequestConditionAttributeResourceType(); | 108 ~WebRequestConditionAttributeResourceType() override; |
| 110 | 109 |
| 111 const std::vector<content::ResourceType> types_; | 110 const std::vector<content::ResourceType> types_; |
| 112 | 111 |
| 113 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeResourceType); | 112 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeResourceType); |
| 114 }; | 113 }; |
| 115 | 114 |
| 116 // Condition that checks whether a response's Content-Type header has a | 115 // Condition that checks whether a response's Content-Type header has a |
| 117 // certain MIME media type. | 116 // certain MIME media type. |
| 118 class WebRequestConditionAttributeContentType | 117 class WebRequestConditionAttributeContentType |
| 119 : public WebRequestConditionAttribute { | 118 : public WebRequestConditionAttribute { |
| 120 public: | 119 public: |
| 121 // Factory method, see WebRequestConditionAttribute::Create. | 120 // Factory method, see WebRequestConditionAttribute::Create. |
| 122 static scoped_refptr<const WebRequestConditionAttribute> Create( | 121 static scoped_refptr<const WebRequestConditionAttribute> Create( |
| 123 const std::string& name, | 122 const std::string& name, |
| 124 const base::Value* value, | 123 const base::Value* value, |
| 125 std::string* error, | 124 std::string* error, |
| 126 bool* bad_message); | 125 bool* bad_message); |
| 127 | 126 |
| 128 // Implementation of WebRequestConditionAttribute: | 127 // Implementation of WebRequestConditionAttribute: |
| 129 virtual int GetStages() const override; | 128 int GetStages() const override; |
| 130 virtual bool IsFulfilled( | 129 bool IsFulfilled(const WebRequestData& request_data) const override; |
| 131 const WebRequestData& request_data) const override; | 130 Type GetType() const override; |
| 132 virtual Type GetType() const override; | 131 std::string GetName() const override; |
| 133 virtual std::string GetName() const override; | 132 bool Equals(const WebRequestConditionAttribute* other) const override; |
| 134 virtual bool Equals(const WebRequestConditionAttribute* other) const override; | |
| 135 | 133 |
| 136 private: | 134 private: |
| 137 explicit WebRequestConditionAttributeContentType( | 135 explicit WebRequestConditionAttributeContentType( |
| 138 const std::vector<std::string>& include_content_types, | 136 const std::vector<std::string>& include_content_types, |
| 139 bool inclusive); | 137 bool inclusive); |
| 140 virtual ~WebRequestConditionAttributeContentType(); | 138 ~WebRequestConditionAttributeContentType() override; |
| 141 | 139 |
| 142 const std::vector<std::string> content_types_; | 140 const std::vector<std::string> content_types_; |
| 143 const bool inclusive_; | 141 const bool inclusive_; |
| 144 | 142 |
| 145 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeContentType); | 143 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeContentType); |
| 146 }; | 144 }; |
| 147 | 145 |
| 148 // Condition attribute for matching against request headers. Uses HeaderMatcher | 146 // Condition attribute for matching against request headers. Uses HeaderMatcher |
| 149 // to handle the actual tests, in connection with a boolean positiveness | 147 // to handle the actual tests, in connection with a boolean positiveness |
| 150 // flag. If that flag is set to true, then IsFulfilled() returns true iff | 148 // flag. If that flag is set to true, then IsFulfilled() returns true iff |
| 151 // |header_matcher_| matches at least one header. Otherwise IsFulfilled() | 149 // |header_matcher_| matches at least one header. Otherwise IsFulfilled() |
| 152 // returns true iff the |header_matcher_| matches no header. | 150 // returns true iff the |header_matcher_| matches no header. |
| 153 class WebRequestConditionAttributeRequestHeaders | 151 class WebRequestConditionAttributeRequestHeaders |
| 154 : public WebRequestConditionAttribute { | 152 : public WebRequestConditionAttribute { |
| 155 public: | 153 public: |
| 156 // Factory method, see WebRequestConditionAttribute::Create. | 154 // Factory method, see WebRequestConditionAttribute::Create. |
| 157 static scoped_refptr<const WebRequestConditionAttribute> Create( | 155 static scoped_refptr<const WebRequestConditionAttribute> Create( |
| 158 const std::string& name, | 156 const std::string& name, |
| 159 const base::Value* value, | 157 const base::Value* value, |
| 160 std::string* error, | 158 std::string* error, |
| 161 bool* bad_message); | 159 bool* bad_message); |
| 162 | 160 |
| 163 // Implementation of WebRequestConditionAttribute: | 161 // Implementation of WebRequestConditionAttribute: |
| 164 virtual int GetStages() const override; | 162 int GetStages() const override; |
| 165 virtual bool IsFulfilled( | 163 bool IsFulfilled(const WebRequestData& request_data) const override; |
| 166 const WebRequestData& request_data) const override; | 164 Type GetType() const override; |
| 167 virtual Type GetType() const override; | 165 std::string GetName() const override; |
| 168 virtual std::string GetName() const override; | 166 bool Equals(const WebRequestConditionAttribute* other) const override; |
| 169 virtual bool Equals(const WebRequestConditionAttribute* other) const override; | |
| 170 | 167 |
| 171 private: | 168 private: |
| 172 WebRequestConditionAttributeRequestHeaders( | 169 WebRequestConditionAttributeRequestHeaders( |
| 173 scoped_ptr<const HeaderMatcher> header_matcher, bool positive); | 170 scoped_ptr<const HeaderMatcher> header_matcher, bool positive); |
| 174 virtual ~WebRequestConditionAttributeRequestHeaders(); | 171 ~WebRequestConditionAttributeRequestHeaders() override; |
| 175 | 172 |
| 176 const scoped_ptr<const HeaderMatcher> header_matcher_; | 173 const scoped_ptr<const HeaderMatcher> header_matcher_; |
| 177 const bool positive_; | 174 const bool positive_; |
| 178 | 175 |
| 179 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeRequestHeaders); | 176 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeRequestHeaders); |
| 180 }; | 177 }; |
| 181 | 178 |
| 182 // Condition attribute for matching against response headers. Uses HeaderMatcher | 179 // Condition attribute for matching against response headers. Uses HeaderMatcher |
| 183 // to handle the actual tests, in connection with a boolean positiveness | 180 // to handle the actual tests, in connection with a boolean positiveness |
| 184 // flag. If that flag is set to true, then IsFulfilled() returns true iff | 181 // flag. If that flag is set to true, then IsFulfilled() returns true iff |
| 185 // |header_matcher_| matches at least one header. Otherwise IsFulfilled() | 182 // |header_matcher_| matches at least one header. Otherwise IsFulfilled() |
| 186 // returns true iff the |header_matcher_| matches no header. | 183 // returns true iff the |header_matcher_| matches no header. |
| 187 class WebRequestConditionAttributeResponseHeaders | 184 class WebRequestConditionAttributeResponseHeaders |
| 188 : public WebRequestConditionAttribute { | 185 : public WebRequestConditionAttribute { |
| 189 public: | 186 public: |
| 190 // Factory method, see WebRequestConditionAttribute::Create. | 187 // Factory method, see WebRequestConditionAttribute::Create. |
| 191 static scoped_refptr<const WebRequestConditionAttribute> Create( | 188 static scoped_refptr<const WebRequestConditionAttribute> Create( |
| 192 const std::string& name, | 189 const std::string& name, |
| 193 const base::Value* value, | 190 const base::Value* value, |
| 194 std::string* error, | 191 std::string* error, |
| 195 bool* bad_message); | 192 bool* bad_message); |
| 196 | 193 |
| 197 // Implementation of WebRequestConditionAttribute: | 194 // Implementation of WebRequestConditionAttribute: |
| 198 virtual int GetStages() const override; | 195 int GetStages() const override; |
| 199 virtual bool IsFulfilled( | 196 bool IsFulfilled(const WebRequestData& request_data) const override; |
| 200 const WebRequestData& request_data) const override; | 197 Type GetType() const override; |
| 201 virtual Type GetType() const override; | 198 std::string GetName() const override; |
| 202 virtual std::string GetName() const override; | 199 bool Equals(const WebRequestConditionAttribute* other) const override; |
| 203 virtual bool Equals(const WebRequestConditionAttribute* other) const override; | |
| 204 | 200 |
| 205 private: | 201 private: |
| 206 WebRequestConditionAttributeResponseHeaders( | 202 WebRequestConditionAttributeResponseHeaders( |
| 207 scoped_ptr<const HeaderMatcher> header_matcher, bool positive); | 203 scoped_ptr<const HeaderMatcher> header_matcher, bool positive); |
| 208 virtual ~WebRequestConditionAttributeResponseHeaders(); | 204 ~WebRequestConditionAttributeResponseHeaders() override; |
| 209 | 205 |
| 210 const scoped_ptr<const HeaderMatcher> header_matcher_; | 206 const scoped_ptr<const HeaderMatcher> header_matcher_; |
| 211 const bool positive_; | 207 const bool positive_; |
| 212 | 208 |
| 213 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeResponseHeaders); | 209 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeResponseHeaders); |
| 214 }; | 210 }; |
| 215 | 211 |
| 216 // This condition tests whether the request origin is third-party. | 212 // This condition tests whether the request origin is third-party. |
| 217 class WebRequestConditionAttributeThirdParty | 213 class WebRequestConditionAttributeThirdParty |
| 218 : public WebRequestConditionAttribute { | 214 : public WebRequestConditionAttribute { |
| 219 public: | 215 public: |
| 220 // Factory method, see WebRequestConditionAttribute::Create. | 216 // Factory method, see WebRequestConditionAttribute::Create. |
| 221 static scoped_refptr<const WebRequestConditionAttribute> Create( | 217 static scoped_refptr<const WebRequestConditionAttribute> Create( |
| 222 const std::string& name, | 218 const std::string& name, |
| 223 const base::Value* value, | 219 const base::Value* value, |
| 224 std::string* error, | 220 std::string* error, |
| 225 bool* bad_message); | 221 bool* bad_message); |
| 226 | 222 |
| 227 // Implementation of WebRequestConditionAttribute: | 223 // Implementation of WebRequestConditionAttribute: |
| 228 virtual int GetStages() const override; | 224 int GetStages() const override; |
| 229 virtual bool IsFulfilled( | 225 bool IsFulfilled(const WebRequestData& request_data) const override; |
| 230 const WebRequestData& request_data) const override; | 226 Type GetType() const override; |
| 231 virtual Type GetType() const override; | 227 std::string GetName() const override; |
| 232 virtual std::string GetName() const override; | 228 bool Equals(const WebRequestConditionAttribute* other) const override; |
| 233 virtual bool Equals(const WebRequestConditionAttribute* other) const override; | |
| 234 | 229 |
| 235 private: | 230 private: |
| 236 explicit WebRequestConditionAttributeThirdParty(bool match_third_party); | 231 explicit WebRequestConditionAttributeThirdParty(bool match_third_party); |
| 237 virtual ~WebRequestConditionAttributeThirdParty(); | 232 ~WebRequestConditionAttributeThirdParty() override; |
| 238 | 233 |
| 239 const bool match_third_party_; | 234 const bool match_third_party_; |
| 240 | 235 |
| 241 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeThirdParty); | 236 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeThirdParty); |
| 242 }; | 237 }; |
| 243 | 238 |
| 244 // This condition is used as a filter for request stages. It is true exactly in | 239 // This condition is used as a filter for request stages. It is true exactly in |
| 245 // stages specified on construction. | 240 // stages specified on construction. |
| 246 class WebRequestConditionAttributeStages | 241 class WebRequestConditionAttributeStages |
| 247 : public WebRequestConditionAttribute { | 242 : public WebRequestConditionAttribute { |
| 248 public: | 243 public: |
| 249 // Factory method, see WebRequestConditionAttribute::Create. | 244 // Factory method, see WebRequestConditionAttribute::Create. |
| 250 static scoped_refptr<const WebRequestConditionAttribute> Create( | 245 static scoped_refptr<const WebRequestConditionAttribute> Create( |
| 251 const std::string& name, | 246 const std::string& name, |
| 252 const base::Value* value, | 247 const base::Value* value, |
| 253 std::string* error, | 248 std::string* error, |
| 254 bool* bad_message); | 249 bool* bad_message); |
| 255 | 250 |
| 256 // Implementation of WebRequestConditionAttribute: | 251 // Implementation of WebRequestConditionAttribute: |
| 257 virtual int GetStages() const override; | 252 int GetStages() const override; |
| 258 virtual bool IsFulfilled( | 253 bool IsFulfilled(const WebRequestData& request_data) const override; |
| 259 const WebRequestData& request_data) const override; | 254 Type GetType() const override; |
| 260 virtual Type GetType() const override; | 255 std::string GetName() const override; |
| 261 virtual std::string GetName() const override; | 256 bool Equals(const WebRequestConditionAttribute* other) const override; |
| 262 virtual bool Equals(const WebRequestConditionAttribute* other) const override; | |
| 263 | 257 |
| 264 private: | 258 private: |
| 265 explicit WebRequestConditionAttributeStages(int allowed_stages); | 259 explicit WebRequestConditionAttributeStages(int allowed_stages); |
| 266 virtual ~WebRequestConditionAttributeStages(); | 260 ~WebRequestConditionAttributeStages() override; |
| 267 | 261 |
| 268 const int allowed_stages_; // Composition of RequestStage values. | 262 const int allowed_stages_; // Composition of RequestStage values. |
| 269 | 263 |
| 270 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeStages); | 264 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeStages); |
| 271 }; | 265 }; |
| 272 | 266 |
| 273 } // namespace extensions | 267 } // namespace extensions |
| 274 | 268 |
| 275 #endif // EXTENSIONS_BROWSER_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITION_AT
TRIBUTE_H_ | 269 #endif // EXTENSIONS_BROWSER_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITION_AT
TRIBUTE_H_ |
| OLD | NEW |