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_RULES_RE
GISTRY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES_RE
GISTRY_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES_RE
GISTRY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES_RE
GISTRY_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/time.h" | 13 #include "base/time.h" |
14 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "chrome/browser/extensions/api/declarative/rules_registry_with_cache.h" | 16 #include "chrome/browser/extensions/api/declarative/rules_registry_with_cache.h" |
17 #include "chrome/browser/extensions/api/declarative_webrequest/request_stages.h" | 17 #include "chrome/browser/extensions/api/declarative_webrequest/request_stage.h" |
18 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rule.h
" | 18 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rule.h
" |
19 #include "chrome/browser/extensions/extension_info_map.h" | 19 #include "chrome/browser/extensions/extension_info_map.h" |
20 #include "chrome/common/extensions/matcher/url_matcher.h" | 20 #include "chrome/common/extensions/matcher/url_matcher.h" |
21 | 21 |
22 class Profile; | 22 class Profile; |
23 class WebRequestPermissions; | 23 class WebRequestPermissions; |
24 | 24 |
25 namespace extension_web_request_api_helpers { | 25 namespace extension_web_request_api_helpers { |
26 struct EventResponseDelta; | 26 struct EventResponseDelta; |
27 } | 27 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // will respond with the URLMatcherConditionSet::ID. We can map this | 62 // will respond with the URLMatcherConditionSet::ID. We can map this |
63 // to the WebRequestRule and check whether also the other conditions (in this | 63 // to the WebRequestRule and check whether also the other conditions (in this |
64 // example 'scheme': 'http') are fulfilled. | 64 // example 'scheme': 'http') are fulfilled. |
65 class WebRequestRulesRegistry : public RulesRegistryWithCache { | 65 class WebRequestRulesRegistry : public RulesRegistryWithCache { |
66 public: | 66 public: |
67 WebRequestRulesRegistry(Profile* profile, Delegate* delegate); | 67 WebRequestRulesRegistry(Profile* profile, Delegate* delegate); |
68 | 68 |
69 // TODO(battre): This will become an implementation detail, because we need | 69 // TODO(battre): This will become an implementation detail, because we need |
70 // a way to also execute the actions of the rules. | 70 // a way to also execute the actions of the rules. |
71 std::set<WebRequestRule::GlobalRuleId> GetMatches( | 71 std::set<WebRequestRule::GlobalRuleId> GetMatches( |
72 net::URLRequest* request, | 72 const WebRequestRule::RequestData& request_data); |
73 RequestStages request_stage); | |
74 | 73 |
75 // Returns which modifications should be executed on the network request | 74 // Returns which modifications should be executed on the network request |
76 // according to the rules registered in this registry. | 75 // according to the rules registered in this registry. |
77 std::list<LinkedPtrEventResponseDelta> CreateDeltas( | 76 std::list<LinkedPtrEventResponseDelta> CreateDeltas( |
78 const ExtensionInfoMap* extension_info_map, | 77 const ExtensionInfoMap* extension_info_map, |
79 net::URLRequest* request, | 78 const WebRequestRule::RequestData& request_data, |
80 bool crosses_incognito, | 79 bool crosses_incognito); |
81 RequestStages request_stage, | |
82 const WebRequestRule::OptionalRequestData& optional_request_data); | |
83 | 80 |
84 // Implementation of RulesRegistryWithCache: | 81 // Implementation of RulesRegistryWithCache: |
85 virtual std::string AddRulesImpl( | 82 virtual std::string AddRulesImpl( |
86 const std::string& extension_id, | 83 const std::string& extension_id, |
87 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) OVERRIDE; | 84 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) OVERRIDE; |
88 virtual std::string RemoveRulesImpl( | 85 virtual std::string RemoveRulesImpl( |
89 const std::string& extension_id, | 86 const std::string& extension_id, |
90 const std::vector<std::string>& rule_identifiers) OVERRIDE; | 87 const std::vector<std::string>& rule_identifiers) OVERRIDE; |
91 virtual std::string RemoveAllRulesImpl( | 88 virtual std::string RemoveAllRulesImpl( |
92 const std::string& extension_id) OVERRIDE; | 89 const std::string& extension_id) OVERRIDE; |
(...skipping 19 matching lines...) Expand all Loading... |
112 RulesMap webrequest_rules_; | 109 RulesMap webrequest_rules_; |
113 | 110 |
114 URLMatcher url_matcher_; | 111 URLMatcher url_matcher_; |
115 | 112 |
116 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 113 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
117 }; | 114 }; |
118 | 115 |
119 } // namespace extensions | 116 } // namespace extensions |
120 | 117 |
121 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES
_REGISTRY_H_ | 118 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES
_REGISTRY_H_ |
OLD | NEW |