| 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 21 matching lines...) Expand all Loading... |
| 32 class WebContents; | 32 class WebContents; |
| 33 | 33 |
| 34 // A NavigationHandle tracks information related to a single navigation. | 34 // A NavigationHandle tracks information related to a single navigation. |
| 35 // NavigationHandles are provided to several WebContentsObserver methods to | 35 // NavigationHandles are provided to several WebContentsObserver methods to |
| 36 // allow observers to track specific navigations. Observers should clear any | 36 // allow observers to track specific navigations. Observers should clear any |
| 37 // references to a NavigationHandle at the time of | 37 // references to a NavigationHandle at the time of |
| 38 // WebContentsObserver::DidFinishNavigation, just before the handle is | 38 // WebContentsObserver::DidFinishNavigation, just before the handle is |
| 39 // destroyed. | 39 // destroyed. |
| 40 class CONTENT_EXPORT NavigationHandle { | 40 class CONTENT_EXPORT NavigationHandle { |
| 41 public: | 41 public: |
| 42 typedef base::Callback<void(NavigationThrottle::ThrottleCheckResult)> |
| 43 ThrottleChecksFinishedCallback; |
| 44 |
| 42 virtual ~NavigationHandle() {} | 45 virtual ~NavigationHandle() {} |
| 43 | 46 |
| 44 // Parameters available at navigation start time ----------------------------- | 47 // Parameters available at navigation start time ----------------------------- |
| 45 // | 48 // |
| 46 // These parameters are always available during the navigation. Note that | 49 // These parameters are always available during the navigation. Note that |
| 47 // some may change during navigation (e.g. due to server redirects). | 50 // some may change during navigation (e.g. due to server redirects). |
| 48 | 51 |
| 49 // The URL the frame is navigating to. This may change during the navigation | 52 // The URL the frame is navigating to. This may change during the navigation |
| 50 // when encountering a server redirect. | 53 // when encountering a server redirect. |
| 51 // This URL may not be the same as the virtual URL returned from | 54 // This URL may not be the same as the virtual URL returned from |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 // Registers a NavigationThrottle for tests. The throttle can | 246 // Registers a NavigationThrottle for tests. The throttle can |
| 244 // modify the request, pause the request or cancel the request. This will | 247 // modify the request, pause the request or cancel the request. This will |
| 245 // take ownership of the NavigationThrottle. | 248 // take ownership of the NavigationThrottle. |
| 246 // Note: in non-test cases, NavigationThrottles should not be added directly | 249 // Note: in non-test cases, NavigationThrottles should not be added directly |
| 247 // but returned by the implementation of | 250 // but returned by the implementation of |
| 248 // ContentBrowserClient::CreateThrottlesForNavigation. This ensures proper | 251 // ContentBrowserClient::CreateThrottlesForNavigation. This ensures proper |
| 249 // ordering of the throttles. | 252 // ordering of the throttles. |
| 250 virtual void RegisterThrottleForTesting( | 253 virtual void RegisterThrottleForTesting( |
| 251 std::unique_ptr<NavigationThrottle> navigation_throttle) = 0; | 254 std::unique_ptr<NavigationThrottle> navigation_throttle) = 0; |
| 252 | 255 |
| 256 // The Call*ForTesting methods return the synchronous throttle check result |
| 257 // and DEFER if the checks are completing asynchronously. To observe async |
| 258 // checks, use the optionally null |complete_callback|, which will be called |
| 259 // whenever the checks are completely finished. |
| 260 |
| 253 // Simulates the network request starting. | 261 // Simulates the network request starting. |
| 254 virtual NavigationThrottle::ThrottleCheckResult | 262 virtual NavigationThrottle::ThrottleCheckResult |
| 255 CallWillStartRequestForTesting(bool is_post, | 263 CallWillStartRequestForTesting( |
| 256 const Referrer& sanitized_referrer, | 264 bool is_post, |
| 257 bool has_user_gesture, | 265 const Referrer& sanitized_referrer, |
| 258 ui::PageTransition transition, | 266 bool has_user_gesture, |
| 259 bool is_external_protocol) = 0; | 267 ui::PageTransition transition, |
| 268 bool is_external_protocol, |
| 269 const ThrottleChecksFinishedCallback& complete_callback) = 0; |
| 260 | 270 |
| 261 // Simulates the network request being redirected. | 271 // Simulates the network request being redirected. |
| 262 virtual NavigationThrottle::ThrottleCheckResult | 272 virtual NavigationThrottle::ThrottleCheckResult |
| 263 CallWillRedirectRequestForTesting(const GURL& new_url, | 273 CallWillRedirectRequestForTesting( |
| 264 bool new_method_is_post, | 274 const GURL& new_url, |
| 265 const GURL& new_referrer_url, | 275 bool new_method_is_post, |
| 266 bool new_is_external_protocol) = 0; | 276 const GURL& new_referrer_url, |
| 277 bool new_is_external_protocol, |
| 278 const ThrottleChecksFinishedCallback& complete_callback) = 0; |
| 267 | 279 |
| 268 // Simulates the reception of the network response. | 280 // Simulates the reception of the network response. |
| 269 virtual NavigationThrottle::ThrottleCheckResult | 281 virtual NavigationThrottle::ThrottleCheckResult |
| 270 CallWillProcessResponseForTesting( | 282 CallWillProcessResponseForTesting( |
| 271 RenderFrameHost* render_frame_host, | 283 RenderFrameHost* render_frame_host, |
| 272 const std::string& raw_response_headers) = 0; | 284 const std::string& raw_response_headers, |
| 285 const ThrottleChecksFinishedCallback& complete_callback) = 0; |
| 273 | 286 |
| 274 // Simulates the navigation being committed. | 287 // Simulates the navigation being committed. |
| 275 virtual void CallDidCommitNavigationForTesting(const GURL& url) = 0; | 288 virtual void CallDidCommitNavigationForTesting(const GURL& url) = 0; |
| 276 | 289 |
| 277 // The NavigationData that the embedder returned from | 290 // The NavigationData that the embedder returned from |
| 278 // ResourceDispatcherHostDelegate::GetNavigationData during commit. This will | 291 // ResourceDispatcherHostDelegate::GetNavigationData during commit. This will |
| 279 // be a clone of the NavigationData. | 292 // be a clone of the NavigationData. |
| 280 virtual NavigationData* GetNavigationData() = 0; | 293 virtual NavigationData* GetNavigationData() = 0; |
| 281 }; | 294 }; |
| 282 | 295 |
| 283 } // namespace content | 296 } // namespace content |
| 284 | 297 |
| 285 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ | 298 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ |
| OLD | NEW |