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_RULE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULE_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "chrome/browser/extensions/api/declarative/rules_registry.h" | 13 #include "chrome/browser/extensions/api/declarative/rules_registry.h" |
14 #include "chrome/browser/extensions/api/declarative_webrequest/request_stages.h" | 14 #include "chrome/browser/extensions/api/declarative_webrequest/request_stages.h" |
15 | 15 |
| 16 class ExtensionInfoMap; |
| 17 class WebRequestPermissions; |
| 18 |
16 namespace extensions { | 19 namespace extensions { |
17 class Extension; | 20 class Extension; |
18 class URLMatcherConditionFactory; | 21 class URLMatcherConditionFactory; |
| 22 class WebRequestActionSet; |
19 class WebRequestConditionSet; | 23 class WebRequestConditionSet; |
20 class WebRequestActionSet; | |
21 } | 24 } |
22 | 25 |
23 namespace extension_web_request_api_helpers { | 26 namespace extension_web_request_api_helpers { |
24 struct EventResponseDelta; | 27 struct EventResponseDelta; |
25 } | 28 } |
26 | 29 |
27 namespace net { | 30 namespace net { |
28 class HttpResponseHeaders; | 31 class HttpResponseHeaders; |
29 class URLRequest; | 32 class URLRequest; |
30 } | 33 } |
(...skipping 28 matching lines...) Expand all Loading... |
59 // If |error| is empty, the translation was successful and the returned | 62 // If |error| is empty, the translation was successful and the returned |
60 // rule is internally consistent. | 63 // rule is internally consistent. |
61 static scoped_ptr<WebRequestRule> Create( | 64 static scoped_ptr<WebRequestRule> Create( |
62 URLMatcherConditionFactory* url_matcher_condition_factory, | 65 URLMatcherConditionFactory* url_matcher_condition_factory, |
63 const std::string& extension_id, | 66 const std::string& extension_id, |
64 base::Time extension_installation_time, | 67 base::Time extension_installation_time, |
65 linked_ptr<RulesRegistry::Rule> rule, | 68 linked_ptr<RulesRegistry::Rule> rule, |
66 std::string* error); | 69 std::string* error); |
67 | 70 |
68 const GlobalRuleId& id() const { return id_; } | 71 const GlobalRuleId& id() const { return id_; } |
| 72 const std::string& extension_id() const { return id_.first; } |
69 const WebRequestConditionSet& conditions() const { return *conditions_; } | 73 const WebRequestConditionSet& conditions() const { return *conditions_; } |
70 const WebRequestActionSet& actions() const { return *actions_; } | 74 const WebRequestActionSet& actions() const { return *actions_; } |
71 Priority priority() const { return priority_; } | 75 Priority priority() const { return priority_; } |
72 | 76 |
73 // Creates all deltas resulting from the ActionSet. This function should | 77 // Creates all deltas resulting from the ActionSet. This function should |
74 // only be called when the conditions_ are fulfilled (from a semantic point | 78 // only be called when the conditions_ are fulfilled (from a semantic point |
75 // of view; no harm is done if this function is called at other times for | 79 // of view; no harm is done if this function is called at other times for |
76 // testing purposes). | 80 // testing purposes). |
77 // If |extension| is set, deltas are suppressed if the |extension| does not | 81 // If |extension| is set, deltas are suppressed if the |extension| does not |
78 // have have sufficient permissions to modify the |request|. The returned list | 82 // have have sufficient permissions to modify the |request|. The returned list |
79 // may be empty in this case. | 83 // may be empty in this case. |
80 std::list<LinkedPtrEventResponseDelta> CreateDeltas( | 84 std::list<LinkedPtrEventResponseDelta> CreateDeltas( |
81 const extensions::Extension* extension, | 85 const ExtensionInfoMap* extension_info_map, |
82 net::URLRequest* request, | 86 net::URLRequest* request, |
| 87 bool crosses_incognito, |
83 RequestStages request_stage, | 88 RequestStages request_stage, |
84 const OptionalRequestData& optional_request_data) const; | 89 const OptionalRequestData& optional_request_data) const; |
85 | 90 |
86 // Returns the minimum priority of rules that may be evaluated after | 91 // Returns the minimum priority of rules that may be evaluated after |
87 // this rule. Defaults to MAX_INT. Only valid if the conditions of this rule | 92 // this rule. Defaults to MAX_INT. Only valid if the conditions of this rule |
88 // are fulfilled. | 93 // are fulfilled. |
89 Priority GetMinimumPriority() const; | 94 Priority GetMinimumPriority() const; |
90 | 95 |
91 private: | 96 private: |
92 // Checks whether the set of |conditions| and |actions| are consistent, | 97 // Checks whether the set of |conditions| and |actions| are consistent, |
93 // meaning for example that we do not allow combining an |action| that needs | 98 // meaning for example that we do not allow combining an |action| that needs |
94 // to be executed before the |condition| can be fulfilled. | 99 // to be executed before the |condition| can be fulfilled. |
95 // Returns true in case of consistency and MUST set |error| otherwise. | 100 // Returns true in case of consistency and MUST set |error| otherwise. |
96 static bool CheckConsistency(WebRequestConditionSet* conditions, | 101 static bool CheckConsistency(WebRequestConditionSet* conditions, |
97 WebRequestActionSet* actions, | 102 WebRequestActionSet* actions, |
98 std::string* error); | 103 std::string* error); |
99 | 104 |
100 GlobalRuleId id_; | 105 GlobalRuleId id_; |
101 base::Time extension_installation_time_; // For precedences of rules. | 106 base::Time extension_installation_time_; // For precedences of rules. |
102 scoped_ptr<WebRequestConditionSet> conditions_; | 107 scoped_ptr<WebRequestConditionSet> conditions_; |
103 scoped_ptr<WebRequestActionSet> actions_; | 108 scoped_ptr<WebRequestActionSet> actions_; |
104 Priority priority_; | 109 Priority priority_; |
105 | 110 |
106 DISALLOW_COPY_AND_ASSIGN(WebRequestRule); | 111 DISALLOW_COPY_AND_ASSIGN(WebRequestRule); |
107 }; | 112 }; |
108 | 113 |
109 } // namespace extensions | 114 } // namespace extensions |
110 | 115 |
111 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULE_
H_ | 116 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULE_
H_ |
OLD | NEW |