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