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