OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_BROWSER_DEVTOOLS_PROTOCOL_NETWORK_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_NETWORK_HANDLER_H_ |
6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_NETWORK_HANDLER_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_NETWORK_HANDLER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/synchronization/lock.h" |
11 #include "content/browser/devtools/protocol/devtools_domain_handler.h" | 12 #include "content/browser/devtools/protocol/devtools_domain_handler.h" |
12 #include "content/browser/devtools/protocol/network.h" | 13 #include "content/browser/devtools/protocol/network.h" |
13 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
14 #include "net/cookies/canonical_cookie.h" | 15 #include "net/cookies/canonical_cookie.h" |
15 | 16 |
| 17 namespace net { |
| 18 class URLRequest; |
| 19 } // namespace net |
| 20 |
16 namespace content { | 21 namespace content { |
17 | 22 |
18 class DevToolsSession; | 23 class DevToolsSession; |
| 24 class DevToolsURLInterceptorRequestJob; |
19 class RenderFrameHostImpl; | 25 class RenderFrameHostImpl; |
20 struct BeginNavigationParams; | 26 struct BeginNavigationParams; |
21 struct CommonNavigationParams; | 27 struct CommonNavigationParams; |
22 struct ResourceRequest; | 28 struct ResourceRequest; |
23 struct ResourceRequestCompletionStatus; | 29 struct ResourceRequestCompletionStatus; |
24 struct ResourceResponseHead; | 30 struct ResourceResponseHead; |
25 | 31 |
26 namespace protocol { | 32 namespace protocol { |
27 | 33 |
28 class NetworkHandler : public DevToolsDomainHandler, | 34 class NetworkHandler : public DevToolsDomainHandler, |
(...skipping 28 matching lines...) Expand all Loading... |
57 Maybe<std::string> path, | 63 Maybe<std::string> path, |
58 Maybe<bool> secure, | 64 Maybe<bool> secure, |
59 Maybe<bool> http_only, | 65 Maybe<bool> http_only, |
60 Maybe<std::string> same_site, | 66 Maybe<std::string> same_site, |
61 Maybe<double> expires, | 67 Maybe<double> expires, |
62 std::unique_ptr<SetCookieCallback> callback) override; | 68 std::unique_ptr<SetCookieCallback> callback) override; |
63 | 69 |
64 Response SetUserAgentOverride(const std::string& user_agent) override; | 70 Response SetUserAgentOverride(const std::string& user_agent) override; |
65 Response CanEmulateNetworkConditions(bool* result) override; | 71 Response CanEmulateNetworkConditions(bool* result) override; |
66 | 72 |
| 73 DispatchResponse EnableFetchInterception(bool enabled) override; |
| 74 DispatchResponse AllowRequest(const String& intercept_id) override; |
| 75 DispatchResponse BlockRequest(const String& intercept_id, |
| 76 const std::string& error_reason) override; |
| 77 DispatchResponse ModifyRequest( |
| 78 const String& intercept_id, |
| 79 Maybe<String> url, |
| 80 Maybe<String> method, |
| 81 Maybe<String> post_data, |
| 82 Maybe<protocol::Network::Headers> headers) override; |
| 83 DispatchResponse MockResponse(const String& intercept_id, |
| 84 const String& raw_response) override; |
| 85 |
67 void NavigationPreloadRequestSent(int worker_version_id, | 86 void NavigationPreloadRequestSent(int worker_version_id, |
68 const std::string& request_id, | 87 const std::string& request_id, |
69 const ResourceRequest& request); | 88 const ResourceRequest& request); |
70 void NavigationPreloadResponseReceived(int worker_version_id, | 89 void NavigationPreloadResponseReceived(int worker_version_id, |
71 const std::string& request_id, | 90 const std::string& request_id, |
72 const GURL& url, | 91 const GURL& url, |
73 const ResourceResponseHead& head); | 92 const ResourceResponseHead& head); |
74 void NavigationPreloadCompleted( | 93 void NavigationPreloadCompleted( |
75 const std::string& request_id, | 94 const std::string& request_id, |
76 const ResourceRequestCompletionStatus& completion_status); | 95 const ResourceRequestCompletionStatus& completion_status); |
77 void NavigationFailed(const CommonNavigationParams& common_params, | 96 void NavigationFailed(const CommonNavigationParams& common_params, |
78 const BeginNavigationParams& begin_params, | 97 const BeginNavigationParams& begin_params, |
79 net::Error error_code); | 98 net::Error error_code); |
80 | 99 |
81 bool enabled() const { return enabled_; } | 100 bool enabled() const { return enabled_; } |
| 101 bool interception_enabled() const; |
82 std::string UserAgentOverride() const; | 102 std::string UserAgentOverride() const; |
83 | 103 |
| 104 Network::Frontend* frontend() const { return frontend_.get(); } |
| 105 |
| 106 void RegisterURLInterceptor(const std::string& intercept_id, |
| 107 DevToolsURLInterceptorRequestJob* interceptor); |
| 108 |
| 109 void UnregisterURLInterceptor(const std::string& intercept_id, |
| 110 DevToolsURLInterceptorRequestJob* interceptor); |
| 111 |
| 112 static std::unique_ptr<Network::Request> CreateRequestFromURLRequest( |
| 113 const net::URLRequest* request); |
| 114 |
84 private: | 115 private: |
85 std::unique_ptr<Network::Frontend> frontend_; | 116 std::unique_ptr<Network::Frontend> frontend_; |
86 RenderFrameHostImpl* host_; | 117 RenderFrameHostImpl* host_; |
87 bool enabled_; | 118 bool enabled_; |
88 std::string user_agent_; | 119 std::string user_agent_; |
89 | 120 |
| 121 mutable base::Lock interception_lock_; // Protects members below |
| 122 std::unordered_map<std::string, DevToolsURLInterceptorRequestJob*> |
| 123 interceptor_map_; |
| 124 bool interception_enabled_; |
| 125 |
90 DISALLOW_COPY_AND_ASSIGN(NetworkHandler); | 126 DISALLOW_COPY_AND_ASSIGN(NetworkHandler); |
91 }; | 127 }; |
92 | 128 |
93 } // namespace protocol | 129 } // namespace protocol |
94 } // namespace content | 130 } // namespace content |
95 | 131 |
96 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_NETWORK_HANDLER_H_ | 132 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_NETWORK_HANDLER_H_ |
OLD | NEW |