OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ |
6 #define CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 virtual const GlobalRequestID& GetGlobalRequestID() = 0; | 203 virtual const GlobalRequestID& GetGlobalRequestID() = 0; |
204 | 204 |
205 // Testing methods ---------------------------------------------------------- | 205 // Testing methods ---------------------------------------------------------- |
206 // | 206 // |
207 // The following methods should be used exclusively for writing unit tests. | 207 // The following methods should be used exclusively for writing unit tests. |
208 | 208 |
209 static std::unique_ptr<NavigationHandle> CreateNavigationHandleForTesting( | 209 static std::unique_ptr<NavigationHandle> CreateNavigationHandleForTesting( |
210 const GURL& url, | 210 const GURL& url, |
211 RenderFrameHost* render_frame_host, | 211 RenderFrameHost* render_frame_host, |
212 bool committed = false, | 212 bool committed = false, |
213 net::Error error = net::OK); | 213 net::Error error = net::OK, |
| 214 bool has_user_gesture = false); |
214 | 215 |
215 // Registers a NavigationThrottle for tests. The throttle can | 216 // Registers a NavigationThrottle for tests. The throttle can |
216 // modify the request, pause the request or cancel the request. This will | 217 // modify the request, pause the request or cancel the request. This will |
217 // take ownership of the NavigationThrottle. | 218 // take ownership of the NavigationThrottle. |
218 // Note: in non-test cases, NavigationThrottles should not be added directly | 219 // Note: in non-test cases, NavigationThrottles should not be added directly |
219 // but returned by the implementation of | 220 // but returned by the implementation of |
220 // ContentBrowserClient::CreateThrottlesForNavigation. This ensures proper | 221 // ContentBrowserClient::CreateThrottlesForNavigation. This ensures proper |
221 // ordering of the throttles. | 222 // ordering of the throttles. |
222 virtual void RegisterThrottleForTesting( | 223 virtual void RegisterThrottleForTesting( |
223 std::unique_ptr<NavigationThrottle> navigation_throttle) = 0; | 224 std::unique_ptr<NavigationThrottle> navigation_throttle) = 0; |
224 | 225 |
225 // Simulates the network request starting. | 226 // Simulates the network request starting. |
226 virtual NavigationThrottle::ThrottleCheckResult | 227 virtual NavigationThrottle::ThrottleCheckResult |
227 CallWillStartRequestForTesting(bool is_post, | 228 CallWillStartRequestForTesting(bool is_post, |
228 const Referrer& sanitized_referrer, | 229 const Referrer& sanitized_referrer, |
229 bool has_user_gesture, | |
230 ui::PageTransition transition, | 230 ui::PageTransition transition, |
231 bool is_external_protocol) = 0; | 231 bool is_external_protocol) = 0; |
232 | 232 |
233 // Simulates the network request being redirected. | 233 // Simulates the network request being redirected. |
234 virtual NavigationThrottle::ThrottleCheckResult | 234 virtual NavigationThrottle::ThrottleCheckResult |
235 CallWillRedirectRequestForTesting(const GURL& new_url, | 235 CallWillRedirectRequestForTesting(const GURL& new_url, |
236 bool new_method_is_post, | 236 bool new_method_is_post, |
237 const GURL& new_referrer_url, | 237 const GURL& new_referrer_url, |
238 bool new_is_external_protocol) = 0; | 238 bool new_is_external_protocol) = 0; |
239 | 239 |
240 // Simulates the reception of the network response. | 240 // Simulates the reception of the network response. |
241 virtual NavigationThrottle::ThrottleCheckResult | 241 virtual NavigationThrottle::ThrottleCheckResult |
242 CallWillProcessResponseForTesting( | 242 CallWillProcessResponseForTesting( |
243 RenderFrameHost* render_frame_host, | 243 RenderFrameHost* render_frame_host, |
244 const std::string& raw_response_headers) = 0; | 244 const std::string& raw_response_headers) = 0; |
245 | 245 |
246 // Simulates the navigation being committed. | 246 // Simulates the navigation being committed. |
247 virtual void CallDidCommitNavigationForTesting(const GURL& url) = 0; | 247 virtual void CallDidCommitNavigationForTesting(const GURL& url) = 0; |
248 | 248 |
249 // The NavigationData that the embedder returned from | 249 // The NavigationData that the embedder returned from |
250 // ResourceDispatcherHostDelegate::GetNavigationData during commit. This will | 250 // ResourceDispatcherHostDelegate::GetNavigationData during commit. This will |
251 // be a clone of the NavigationData. | 251 // be a clone of the NavigationData. |
252 virtual NavigationData* GetNavigationData() = 0; | 252 virtual NavigationData* GetNavigationData() = 0; |
253 }; | 253 }; |
254 | 254 |
255 } // namespace content | 255 } // namespace content |
256 | 256 |
257 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ | 257 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ |
OLD | NEW |