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 EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_H_ |
6 #define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_H_ | 6 #define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <list> | 10 #include <list> |
11 #include <map> | 11 #include <map> |
12 #include <set> | 12 #include <set> |
13 #include <string> | 13 #include <string> |
14 #include <utility> | 14 #include <utility> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/memory/singleton.h" | 19 #include "base/memory/singleton.h" |
20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
21 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
23 #include "content/public/common/resource_type.h" | |
24 #include "extensions/browser/api/declarative/rules_registry.h" | 23 #include "extensions/browser/api/declarative/rules_registry.h" |
25 #include "extensions/browser/api/declarative_webrequest/request_stage.h" | 24 #include "extensions/browser/api/declarative_webrequest/request_stage.h" |
26 #include "extensions/browser/api/web_request/web_request_api_helpers.h" | 25 #include "extensions/browser/api/web_request/web_request_api_helpers.h" |
27 #include "extensions/browser/api/web_request/web_request_permissions.h" | 26 #include "extensions/browser/api/web_request/web_request_permissions.h" |
28 #include "extensions/browser/browser_context_keyed_api_factory.h" | 27 #include "extensions/browser/browser_context_keyed_api_factory.h" |
29 #include "extensions/browser/event_router.h" | 28 #include "extensions/browser/event_router.h" |
30 #include "extensions/browser/extension_function.h" | 29 #include "extensions/browser/extension_function.h" |
31 #include "extensions/common/url_pattern_set.h" | 30 #include "extensions/common/url_pattern_set.h" |
32 #include "ipc/ipc_sender.h" | 31 #include "ipc/ipc_sender.h" |
33 #include "net/base/completion_callback.h" | 32 #include "net/base/completion_callback.h" |
(...skipping 13 matching lines...) Expand all Loading... |
47 | 46 |
48 namespace net { | 47 namespace net { |
49 class AuthChallengeInfo; | 48 class AuthChallengeInfo; |
50 class AuthCredentials; | 49 class AuthCredentials; |
51 class HttpRequestHeaders; | 50 class HttpRequestHeaders; |
52 class HttpResponseHeaders; | 51 class HttpResponseHeaders; |
53 class URLRequest; | 52 class URLRequest; |
54 } | 53 } |
55 | 54 |
56 namespace extensions { | 55 namespace extensions { |
| 56 |
| 57 enum class WebRequestResourceType : uint8_t; |
| 58 |
57 class ExtensionNavigationUIData; | 59 class ExtensionNavigationUIData; |
58 class InfoMap; | 60 class InfoMap; |
59 class WebRequestEventDetails; | 61 class WebRequestEventDetails; |
60 class WebRequestRulesRegistry; | 62 class WebRequestRulesRegistry; |
61 class WebRequestEventRouterDelegate; | 63 class WebRequestEventRouterDelegate; |
62 | 64 |
63 // Support class for the WebRequest API. Lives on the UI thread. Most of the | 65 // Support class for the WebRequest API. Lives on the UI thread. Most of the |
64 // work is done by ExtensionWebRequestEventRouter below. This class observes | 66 // work is done by ExtensionWebRequestEventRouter below. This class observes |
65 // extensions::EventRouter to deal with event listeners. There is one instance | 67 // extensions::EventRouter to deal with event listeners. There is one instance |
66 // per BrowserContext which is shared with incognito. | 68 // per BrowserContext which is shared with incognito. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 RequestFilter(); | 118 RequestFilter(); |
117 RequestFilter(const RequestFilter& other); | 119 RequestFilter(const RequestFilter& other); |
118 ~RequestFilter(); | 120 ~RequestFilter(); |
119 | 121 |
120 // Returns false if there was an error initializing. If it is a user error, | 122 // Returns false if there was an error initializing. If it is a user error, |
121 // an error message is provided, otherwise the error is internal (and | 123 // an error message is provided, otherwise the error is internal (and |
122 // unexpected). | 124 // unexpected). |
123 bool InitFromValue(const base::DictionaryValue& value, std::string* error); | 125 bool InitFromValue(const base::DictionaryValue& value, std::string* error); |
124 | 126 |
125 extensions::URLPatternSet urls; | 127 extensions::URLPatternSet urls; |
126 std::vector<content::ResourceType> types; | 128 std::vector<WebRequestResourceType> types; |
127 int tab_id; | 129 int tab_id; |
128 int window_id; | 130 int window_id; |
129 }; | 131 }; |
130 | 132 |
131 // Contains an extension's response to a blocking event. | 133 // Contains an extension's response to a blocking event. |
132 struct EventResponse { | 134 struct EventResponse { |
133 EventResponse(const std::string& extension_id, | 135 EventResponse(const std::string& extension_id, |
134 const base::Time& extension_install_time); | 136 const base::Time& extension_install_time); |
135 ~EventResponse(); | 137 ~EventResponse(); |
136 | 138 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 // normal browser_context, or vice versa). | 434 // normal browser_context, or vice versa). |
433 void GetMatchingListenersImpl(void* browser_context, | 435 void GetMatchingListenersImpl(void* browser_context, |
434 const net::URLRequest* request, | 436 const net::URLRequest* request, |
435 const extensions::InfoMap* extension_info_map, | 437 const extensions::InfoMap* extension_info_map, |
436 ExtensionNavigationUIData* navigation_ui_data, | 438 ExtensionNavigationUIData* navigation_ui_data, |
437 bool crosses_incognito, | 439 bool crosses_incognito, |
438 const std::string& event_name, | 440 const std::string& event_name, |
439 const GURL& url, | 441 const GURL& url, |
440 int render_process_host_id, | 442 int render_process_host_id, |
441 int routing_id, | 443 int routing_id, |
442 content::ResourceType resource_type, | 444 WebRequestResourceType resource_type, |
443 bool is_async_request, | 445 bool is_async_request, |
444 bool is_request_from_extension, | 446 bool is_request_from_extension, |
445 int* extra_info_spec, | 447 int* extra_info_spec, |
446 RawListeners* matching_listeners); | 448 RawListeners* matching_listeners); |
447 | 449 |
448 // Decrements the count of event handlers blocking the given request. When the | 450 // Decrements the count of event handlers blocking the given request. When the |
449 // count reaches 0, we stop blocking the request and proceed it using the | 451 // count reaches 0, we stop blocking the request and proceed it using the |
450 // method requested by the extension with the highest precedence. Precedence | 452 // method requested by the extension with the highest precedence. Precedence |
451 // is decided by extension install time. If |response| is non-NULL, this | 453 // is decided by extension install time. If |response| is non-NULL, this |
452 // method assumes ownership. | 454 // method assumes ownership. |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 extensions::QuotaLimitHeuristics* heuristics) const override; | 627 extensions::QuotaLimitHeuristics* heuristics) const override; |
626 // Handle quota exceeded gracefully: Only warn the user but still execute the | 628 // Handle quota exceeded gracefully: Only warn the user but still execute the |
627 // function. | 629 // function. |
628 void OnQuotaExceeded(const std::string& error) override; | 630 void OnQuotaExceeded(const std::string& error) override; |
629 ResponseAction Run() override; | 631 ResponseAction Run() override; |
630 }; | 632 }; |
631 | 633 |
632 } // namespace extensions | 634 } // namespace extensions |
633 | 635 |
634 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_H_ | 636 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_H_ |
OLD | NEW |