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 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "chrome/browser/extensions/api/declarative_webrequest/request_stages.h" | 14 #include "chrome/browser/extensions/api/declarative_webrequest/request_stage.h" |
| 15 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rule.h
" |
15 #include "chrome/common/extensions/api/events.h" | 16 #include "chrome/common/extensions/api/events.h" |
16 #include "webkit/glue/resource_type.h" | 17 #include "webkit/glue/resource_type.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class Value; | 20 class Value; |
20 } | 21 } |
21 | 22 |
22 namespace net { | 23 namespace net { |
23 class URLRequest; | 24 class URLRequest; |
24 } | 25 } |
(...skipping 13 matching lines...) Expand all Loading... |
38 | 39 |
39 // Factory method that creates a WebRequestConditionAttribute for the JSON | 40 // Factory method that creates a WebRequestConditionAttribute for the JSON |
40 // dictionary {|name|: |value|} passed by the extension API. Sets |error| and | 41 // dictionary {|name|: |value|} passed by the extension API. Sets |error| and |
41 // returns NULL if something fails. | 42 // returns NULL if something fails. |
42 // The ownership of |value| remains at the caller. | 43 // The ownership of |value| remains at the caller. |
43 static scoped_ptr<WebRequestConditionAttribute> Create( | 44 static scoped_ptr<WebRequestConditionAttribute> Create( |
44 const std::string& name, | 45 const std::string& name, |
45 const base::Value* value, | 46 const base::Value* value, |
46 std::string* error); | 47 std::string* error); |
47 | 48 |
48 // Returns a bit vector representing extensions::RequestStages. The bit vector | 49 // Returns a bit vector representing extensions::RequestStage. The bit vector |
49 // contains a 1 for each request stage during which the condition attribute | 50 // contains a 1 for each request stage during which the condition attribute |
50 // can be tested. | 51 // can be tested. |
51 virtual int GetStages() const = 0; | 52 virtual int GetStages() const = 0; |
52 | 53 |
53 // Returns whether the condition is fulfilled for this request. | 54 // Returns whether the condition is fulfilled for this request. |
54 virtual bool IsFulfilled(net::URLRequest* request, | 55 virtual bool IsFulfilled(const WebRequestRule::RequestData& request_data) = 0; |
55 RequestStages request_stage) = 0; | |
56 | 56 |
57 virtual Type GetType() const = 0; | 57 virtual Type GetType() const = 0; |
58 | 58 |
59 // Returns whether condition attributes of type |instance_type| are known | 59 // Returns whether condition attributes of type |instance_type| are known |
60 // and can be instantiated by Create(). | 60 // and can be instantiated by Create(). |
61 static bool IsKnownType(const std::string& instance_type); | 61 static bool IsKnownType(const std::string& instance_type); |
62 | 62 |
63 private: | 63 private: |
64 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttribute); | 64 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttribute); |
65 }; | 65 }; |
(...skipping 14 matching lines...) Expand all Loading... |
80 static bool IsMatchingType(const std::string& instance_type); | 80 static bool IsMatchingType(const std::string& instance_type); |
81 | 81 |
82 // Factory method, see WebRequestConditionAttribute::Create. | 82 // Factory method, see WebRequestConditionAttribute::Create. |
83 static scoped_ptr<WebRequestConditionAttribute> Create( | 83 static scoped_ptr<WebRequestConditionAttribute> Create( |
84 const std::string& name, | 84 const std::string& name, |
85 const base::Value* value, | 85 const base::Value* value, |
86 std::string* error); | 86 std::string* error); |
87 | 87 |
88 // Implementation of WebRequestConditionAttribute: | 88 // Implementation of WebRequestConditionAttribute: |
89 virtual int GetStages() const OVERRIDE; | 89 virtual int GetStages() const OVERRIDE; |
90 virtual bool IsFulfilled(net::URLRequest* request, | 90 virtual bool IsFulfilled(const WebRequestRule::RequestData& request_data) |
91 RequestStages request_stage) OVERRIDE; | 91 OVERRIDE; |
92 virtual Type GetType() const OVERRIDE; | 92 virtual Type GetType() const OVERRIDE; |
93 | 93 |
94 private: | 94 private: |
95 explicit WebRequestConditionAttributeResourceType( | 95 explicit WebRequestConditionAttributeResourceType( |
96 const std::vector<ResourceType::Type>& types); | 96 const std::vector<ResourceType::Type>& types); |
97 | 97 |
98 std::vector<ResourceType::Type> types_; | 98 std::vector<ResourceType::Type> types_; |
99 | 99 |
100 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeResourceType); | 100 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeResourceType); |
101 }; | 101 }; |
102 | 102 |
103 } // namespace extensions | 103 } // namespace extensions |
104 | 104 |
105 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDI
TION_ATTRIBUTE_H_ | 105 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDI
TION_ATTRIBUTE_H_ |
OLD | NEW |