| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // Whether the navigation has encountered a server redirect or not. | 145 // Whether the navigation has encountered a server redirect or not. |
| 146 virtual bool WasServerRedirect() = 0; | 146 virtual bool WasServerRedirect() = 0; |
| 147 | 147 |
| 148 // Whether the navigation has committed. This returns true for either | 148 // Whether the navigation has committed. This returns true for either |
| 149 // successful commits or error pages that replace the previous page | 149 // successful commits or error pages that replace the previous page |
| 150 // (distinguished by |IsErrorPage|), and false for errors that leave the user | 150 // (distinguished by |IsErrorPage|), and false for errors that leave the user |
| 151 // on the previous page. | 151 // on the previous page. |
| 152 virtual bool HasCommitted() = 0; | 152 virtual bool HasCommitted() = 0; |
| 153 | 153 |
| 154 // Whether the navigation resulted in an error page. | 154 // Whether the navigation resulted in an error page. |
| 155 // Note that if an error page reloads, this will return true even though |
| 156 // GetNetErrorCode will be net::OK. |
| 155 virtual bool IsErrorPage() = 0; | 157 virtual bool IsErrorPage() = 0; |
| 156 | 158 |
| 157 // Returns the response headers for the request or nullptr if there are none. | 159 // Returns the response headers for the request or nullptr if there are none. |
| 158 // This should only be accessed after a redirect was encountered or after the | 160 // This should only be accessed after a redirect was encountered or after the |
| 159 // navigation is ready to commit. The headers returned should not be modified, | 161 // navigation is ready to commit. The headers returned should not be modified, |
| 160 // as modifications will not be reflected in the network stack. | 162 // as modifications will not be reflected in the network stack. |
| 161 virtual const net::HttpResponseHeaders* GetResponseHeaders() = 0; | 163 virtual const net::HttpResponseHeaders* GetResponseHeaders() = 0; |
| 162 | 164 |
| 163 // Resumes a navigation that was previously deferred by a NavigationThrottle. | 165 // Resumes a navigation that was previously deferred by a NavigationThrottle. |
| 164 virtual void Resume() = 0; | 166 virtual void Resume() = 0; |
| 165 | 167 |
| 166 // Cancels a navigation that was previously deferred by a NavigationThrottle. | 168 // Cancels a navigation that was previously deferred by a NavigationThrottle. |
| 167 // |result| should be equal to NavigationThrottle::CANCEL or | 169 // |result| should be equal to NavigationThrottle::CANCEL or |
| 168 // NavigationThrottle::CANCEL_AND_IGNORE. | 170 // NavigationThrottle::CANCEL_AND_IGNORE. |
| 169 virtual void CancelDeferredNavigation( | 171 virtual void CancelDeferredNavigation( |
| 170 NavigationThrottle::ThrottleCheckResult result) = 0; | 172 NavigationThrottle::ThrottleCheckResult result) = 0; |
| 171 | 173 |
| 172 // Testing methods ---------------------------------------------------------- | 174 // Testing methods ---------------------------------------------------------- |
| 173 // | 175 // |
| 174 // The following methods should be used exclusively for writing unit tests. | 176 // The following methods should be used exclusively for writing unit tests. |
| 175 | 177 |
| 176 static std::unique_ptr<NavigationHandle> CreateNavigationHandleForTesting( | 178 static std::unique_ptr<NavigationHandle> CreateNavigationHandleForTesting( |
| 177 const GURL& url, | 179 const GURL& url, |
| 178 RenderFrameHost* render_frame_host); | 180 RenderFrameHost* render_frame_host, |
| 181 bool committed = false, |
| 182 net::Error error = net::OK); |
| 179 | 183 |
| 180 // Registers a NavigationThrottle for tests. The throttle can | 184 // Registers a NavigationThrottle for tests. The throttle can |
| 181 // modify the request, pause the request or cancel the request. This will | 185 // modify the request, pause the request or cancel the request. This will |
| 182 // take ownership of the NavigationThrottle. | 186 // take ownership of the NavigationThrottle. |
| 183 // Note: in non-test cases, NavigationThrottles should not be added directly | 187 // Note: in non-test cases, NavigationThrottles should not be added directly |
| 184 // but returned by the implementation of | 188 // but returned by the implementation of |
| 185 // ContentBrowserClient::CreateThrottlesForNavigation. This ensures proper | 189 // ContentBrowserClient::CreateThrottlesForNavigation. This ensures proper |
| 186 // ordering of the throttles. | 190 // ordering of the throttles. |
| 187 virtual void RegisterThrottleForTesting( | 191 virtual void RegisterThrottleForTesting( |
| 188 std::unique_ptr<NavigationThrottle> navigation_throttle) = 0; | 192 std::unique_ptr<NavigationThrottle> navigation_throttle) = 0; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 213 | 217 |
| 214 // The NavigationData that the embedder returned from | 218 // The NavigationData that the embedder returned from |
| 215 // ResourceDispatcherHostDelegate::GetNavigationData during commit. This will | 219 // ResourceDispatcherHostDelegate::GetNavigationData during commit. This will |
| 216 // be a clone of the NavigationData. | 220 // be a clone of the NavigationData. |
| 217 virtual NavigationData* GetNavigationData() = 0; | 221 virtual NavigationData* GetNavigationData() = 0; |
| 218 }; | 222 }; |
| 219 | 223 |
| 220 } // namespace content | 224 } // namespace content |
| 221 | 225 |
| 222 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ | 226 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ |
| OLD | NEW |