| 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 "base/memory/scoped_ptr.h" | 8 #include <memory> |
| 9 |
| 9 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 10 #include "content/public/browser/navigation_throttle.h" | 11 #include "content/public/browser/navigation_throttle.h" |
| 11 #include "content/public/common/referrer.h" | 12 #include "content/public/common/referrer.h" |
| 12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 13 #include "ui/base/page_transition_types.h" | 14 #include "ui/base/page_transition_types.h" |
| 14 | 15 |
| 15 class GURL; | 16 class GURL; |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 class NavigationThrottle; | 19 class NavigationThrottle; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // Cancels a navigation that was previously deferred by a NavigationThrottle. | 133 // Cancels a navigation that was previously deferred by a NavigationThrottle. |
| 133 // |result| should be equal to NavigationThrottle::CANCEL or | 134 // |result| should be equal to NavigationThrottle::CANCEL or |
| 134 // NavigationThrottle::CANCEL_AND_IGNORE. | 135 // NavigationThrottle::CANCEL_AND_IGNORE. |
| 135 virtual void CancelDeferredNavigation( | 136 virtual void CancelDeferredNavigation( |
| 136 NavigationThrottle::ThrottleCheckResult result) = 0; | 137 NavigationThrottle::ThrottleCheckResult result) = 0; |
| 137 | 138 |
| 138 // Testing methods ---------------------------------------------------------- | 139 // Testing methods ---------------------------------------------------------- |
| 139 // | 140 // |
| 140 // The following methods should be used exclusively for writing unit tests. | 141 // The following methods should be used exclusively for writing unit tests. |
| 141 | 142 |
| 142 static scoped_ptr<NavigationHandle> CreateNavigationHandleForTesting( | 143 static std::unique_ptr<NavigationHandle> CreateNavigationHandleForTesting( |
| 143 const GURL& url, | 144 const GURL& url, |
| 144 RenderFrameHost* render_frame_host); | 145 RenderFrameHost* render_frame_host); |
| 145 | 146 |
| 146 // Registers a NavigationThrottle for tests. The throttle can | 147 // Registers a NavigationThrottle for tests. The throttle can |
| 147 // modify the request, pause the request or cancel the request. This will | 148 // modify the request, pause the request or cancel the request. This will |
| 148 // take ownership of the NavigationThrottle. | 149 // take ownership of the NavigationThrottle. |
| 149 // Note: in non-test cases, NavigationThrottles should not be added directly | 150 // Note: in non-test cases, NavigationThrottles should not be added directly |
| 150 // but returned by the implementation of | 151 // but returned by the implementation of |
| 151 // ContentBrowserClient::CreateThrottlesForNavigation. This ensures proper | 152 // ContentBrowserClient::CreateThrottlesForNavigation. This ensures proper |
| 152 // ordering of the throttles. | 153 // ordering of the throttles. |
| 153 virtual void RegisterThrottleForTesting( | 154 virtual void RegisterThrottleForTesting( |
| 154 scoped_ptr<NavigationThrottle> navigation_throttle) = 0; | 155 std::unique_ptr<NavigationThrottle> navigation_throttle) = 0; |
| 155 | 156 |
| 156 // Simulates the network request starting. | 157 // Simulates the network request starting. |
| 157 virtual NavigationThrottle::ThrottleCheckResult | 158 virtual NavigationThrottle::ThrottleCheckResult |
| 158 CallWillStartRequestForTesting(bool is_post, | 159 CallWillStartRequestForTesting(bool is_post, |
| 159 const Referrer& sanitized_referrer, | 160 const Referrer& sanitized_referrer, |
| 160 bool has_user_gesture, | 161 bool has_user_gesture, |
| 161 ui::PageTransition transition, | 162 ui::PageTransition transition, |
| 162 bool is_external_protocol) = 0; | 163 bool is_external_protocol) = 0; |
| 163 | 164 |
| 164 // Simulates the network request being redirected. | 165 // Simulates the network request being redirected. |
| 165 virtual NavigationThrottle::ThrottleCheckResult | 166 virtual NavigationThrottle::ThrottleCheckResult |
| 166 CallWillRedirectRequestForTesting(const GURL& new_url, | 167 CallWillRedirectRequestForTesting(const GURL& new_url, |
| 167 bool new_method_is_post, | 168 bool new_method_is_post, |
| 168 const GURL& new_referrer_url, | 169 const GURL& new_referrer_url, |
| 169 bool new_is_external_protocol) = 0; | 170 bool new_is_external_protocol) = 0; |
| 170 }; | 171 }; |
| 171 | 172 |
| 172 } // namespace content | 173 } // namespace content |
| 173 | 174 |
| 174 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ | 175 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ |
| OLD | NEW |