Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.h

Issue 2700553002: Introduce WebRequestResourceType. (Closed)
Patch Set: Make compiler happy; make type<->string mapping self-checking. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // TODO(pkalinnikov): Make this a bitmask.
109 const std::vector<WebRequestResourceType> types_;
107 110
108 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeResourceType); 111 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeResourceType);
109 }; 112 };
110 113
111 // Condition that checks whether a response's Content-Type header has a 114 // Condition that checks whether a response's Content-Type header has a
112 // certain MIME media type. 115 // certain MIME media type.
113 class WebRequestConditionAttributeContentType 116 class WebRequestConditionAttributeContentType
114 : public WebRequestConditionAttribute { 117 : public WebRequestConditionAttribute {
115 public: 118 public:
116 // Factory method, see WebRequestConditionAttribute::Create. 119 // Factory method, see WebRequestConditionAttribute::Create.
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 ~WebRequestConditionAttributeStages() override; 261 ~WebRequestConditionAttributeStages() override;
259 262
260 const int allowed_stages_; // Composition of RequestStage values. 263 const int allowed_stages_; // Composition of RequestStage values.
261 264
262 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeStages); 265 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeStages);
263 }; 266 };
264 267
265 } // namespace extensions 268 } // namespace extensions
266 269
267 #endif // EXTENSIONS_BROWSER_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITION_AT TRIBUTE_H_ 270 #endif // EXTENSIONS_BROWSER_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITION_AT TRIBUTE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698