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