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 <stdint.h> | |
8 #include <memory> | 9 #include <memory> |
9 #include <string> | 10 #include <string> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "content/public/common/resource_type.h" | |
15 #include "extensions/browser/api/declarative_webrequest/request_stage.h" | 15 #include "extensions/browser/api/declarative_webrequest/request_stage.h" |
16 #include "extensions/common/api/events.h" | 16 #include "extensions/common/api/events.h" |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class Value; | 19 class Value; |
20 } | 20 } |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 | 23 |
24 enum class WebRequestResourceType : uint8_t; | |
25 | |
24 class HeaderMatcher; | 26 class HeaderMatcher; |
25 struct WebRequestData; | 27 struct WebRequestData; |
26 | 28 |
27 // Base class for all condition attributes of the declarative Web Request API | 29 // Base class for all condition attributes of the declarative Web Request API |
28 // except for condition attribute to test URLPatterns. | 30 // except for condition attribute to test URLPatterns. |
29 class WebRequestConditionAttribute | 31 class WebRequestConditionAttribute |
30 : public base::RefCounted<WebRequestConditionAttribute> { | 32 : public base::RefCounted<WebRequestConditionAttribute> { |
31 public: | 33 public: |
32 enum Type { | 34 enum Type { |
33 CONDITION_RESOURCE_TYPE, | 35 CONDITION_RESOURCE_TYPE, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 | 95 |
94 // Implementation of WebRequestConditionAttribute: | 96 // Implementation of WebRequestConditionAttribute: |
95 int GetStages() const override; | 97 int GetStages() const override; |
96 bool IsFulfilled(const WebRequestData& request_data) const override; | 98 bool IsFulfilled(const WebRequestData& request_data) const override; |
97 Type GetType() const override; | 99 Type GetType() const override; |
98 std::string GetName() const override; | 100 std::string GetName() const override; |
99 bool Equals(const WebRequestConditionAttribute* other) const override; | 101 bool Equals(const WebRequestConditionAttribute* other) const override; |
100 | 102 |
101 private: | 103 private: |
102 explicit WebRequestConditionAttributeResourceType( | 104 explicit WebRequestConditionAttributeResourceType( |
103 const std::vector<content::ResourceType>& types); | 105 const std::vector<WebRequestResourceType>& types); |
104 ~WebRequestConditionAttributeResourceType() override; | 106 ~WebRequestConditionAttributeResourceType() override; |
105 | 107 |
106 const std::vector<content::ResourceType> types_; | 108 const std::vector<WebRequestResourceType> types_; |
pkalinnikov
2017/02/16 19:43:38
We could make this vector a bitmask easily, but th
pkalinnikov
2017/02/16 21:24:46
Done.
| |
107 | 109 |
108 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeResourceType); | 110 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeResourceType); |
109 }; | 111 }; |
110 | 112 |
111 // Condition that checks whether a response's Content-Type header has a | 113 // Condition that checks whether a response's Content-Type header has a |
112 // certain MIME media type. | 114 // certain MIME media type. |
113 class WebRequestConditionAttributeContentType | 115 class WebRequestConditionAttributeContentType |
114 : public WebRequestConditionAttribute { | 116 : public WebRequestConditionAttribute { |
115 public: | 117 public: |
116 // Factory method, see WebRequestConditionAttribute::Create. | 118 // Factory method, see WebRequestConditionAttribute::Create. |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 ~WebRequestConditionAttributeStages() override; | 260 ~WebRequestConditionAttributeStages() override; |
259 | 261 |
260 const int allowed_stages_; // Composition of RequestStage values. | 262 const int allowed_stages_; // Composition of RequestStage values. |
261 | 263 |
262 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeStages); | 264 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeStages); |
263 }; | 265 }; |
264 | 266 |
265 } // namespace extensions | 267 } // namespace extensions |
266 | 268 |
267 #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 |