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 <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/memory/linked_ptr.h" | 15 #include "base/memory/linked_ptr.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "chrome/browser/extensions/api/declarative/declarative_rule.h" | 19 #include "chrome/browser/extensions/api/declarative/declarative_rule.h" |
20 #include "chrome/browser/extensions/api/declarative/rules_registry.h" | 20 #include "chrome/browser/extensions/api/declarative/rules_registry.h" |
21 #include "chrome/browser/extensions/api/declarative_webrequest/request_stage.h" | 21 #include "chrome/browser/extensions/api/declarative_webrequest/request_stage.h" |
22 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_action
.h" | 22 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_action
.h" |
23 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit
ion.h" | 23 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit
ion.h" |
24 #include "components/url_matcher/url_matcher.h" | 24 #include "components/url_matcher/url_matcher.h" |
25 #include "extensions/browser/info_map.h" | 25 #include "extensions/browser/info_map.h" |
26 | 26 |
27 class Profile; | |
28 class WebRequestPermissions; | 27 class WebRequestPermissions; |
29 | 28 |
| 29 namespace content { |
| 30 class BrowserContext; |
| 31 } |
| 32 |
30 namespace extension_web_request_api_helpers { | 33 namespace extension_web_request_api_helpers { |
31 struct EventResponseDelta; | 34 struct EventResponseDelta; |
32 } | 35 } |
33 | 36 |
34 namespace net { | 37 namespace net { |
35 class URLRequest; | 38 class URLRequest; |
36 } | 39 } |
37 | 40 |
38 namespace extensions { | 41 namespace extensions { |
39 | 42 |
(...skipping 28 matching lines...) Expand all Loading... |
68 // represents the {'host_suffix': 'example.com', 'path_prefix': '/query'} part. | 71 // represents the {'host_suffix': 'example.com', 'path_prefix': '/query'} part. |
69 // We will then ask the URLMatcher, whether a given URL | 72 // We will then ask the URLMatcher, whether a given URL |
70 // "http://www.example.com/query/" has any matches, and the URLMatcher | 73 // "http://www.example.com/query/" has any matches, and the URLMatcher |
71 // will respond with the URLMatcherConditionSet::ID. We can map this | 74 // will respond with the URLMatcherConditionSet::ID. We can map this |
72 // to the WebRequestRule and check whether also the other conditions (in this | 75 // to the WebRequestRule and check whether also the other conditions (in this |
73 // example 'scheme': 'http') are fulfilled. | 76 // example 'scheme': 'http') are fulfilled. |
74 class WebRequestRulesRegistry : public RulesRegistry { | 77 class WebRequestRulesRegistry : public RulesRegistry { |
75 public: | 78 public: |
76 // |cache_delegate| can be NULL. In that case it constructs the registry with | 79 // |cache_delegate| can be NULL. In that case it constructs the registry with |
77 // storage functionality suspended. | 80 // storage functionality suspended. |
78 WebRequestRulesRegistry(Profile* profile, | 81 WebRequestRulesRegistry(content::BrowserContext* browser_context, |
79 RulesCacheDelegate* cache_delegate, | 82 RulesCacheDelegate* cache_delegate, |
80 const WebViewKey& webview_key); | 83 const WebViewKey& webview_key); |
81 | 84 |
82 // TODO(battre): This will become an implementation detail, because we need | 85 // TODO(battre): This will become an implementation detail, because we need |
83 // a way to also execute the actions of the rules. | 86 // a way to also execute the actions of the rules. |
84 std::set<const WebRequestRule*> GetMatches( | 87 std::set<const WebRequestRule*> GetMatches( |
85 const WebRequestData& request_data_without_ids) const; | 88 const WebRequestData& request_data_without_ids) const; |
86 | 89 |
87 // Returns which modifications should be executed on the network request | 90 // Returns which modifications should be executed on the network request |
88 // according to the rules registered in this registry. | 91 // according to the rules registered in this registry. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 179 |
177 // These rules contain condition sets with conditions without URL attributes. | 180 // These rules contain condition sets with conditions without URL attributes. |
178 // Such conditions are not triggered by URL matcher, so we need to test them | 181 // Such conditions are not triggered by URL matcher, so we need to test them |
179 // separately. | 182 // separately. |
180 std::set<const WebRequestRule*> rules_with_untriggered_conditions_; | 183 std::set<const WebRequestRule*> rules_with_untriggered_conditions_; |
181 | 184 |
182 std::map<WebRequestRule::ExtensionId, RulesMap> webrequest_rules_; | 185 std::map<WebRequestRule::ExtensionId, RulesMap> webrequest_rules_; |
183 | 186 |
184 url_matcher::URLMatcher url_matcher_; | 187 url_matcher::URLMatcher url_matcher_; |
185 | 188 |
186 void* profile_id_; | 189 content::BrowserContext* browser_context_; |
187 scoped_refptr<InfoMap> extension_info_map_; | 190 scoped_refptr<InfoMap> extension_info_map_; |
188 | 191 |
189 DISALLOW_COPY_AND_ASSIGN(WebRequestRulesRegistry); | 192 DISALLOW_COPY_AND_ASSIGN(WebRequestRulesRegistry); |
190 }; | 193 }; |
191 | 194 |
192 } // namespace extensions | 195 } // namespace extensions |
193 | 196 |
194 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES
_REGISTRY_H_ | 197 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES
_REGISTRY_H_ |
OLD | NEW |