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 |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "content/public/browser/navigation_throttle.h" | 12 #include "content/public/browser/navigation_throttle.h" |
| 13 #include "content/public/common/navigation_gesture.h" |
13 #include "content/public/common/referrer.h" | 14 #include "content/public/common/referrer.h" |
14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
15 #include "net/http/http_response_info.h" | 16 #include "net/http/http_response_info.h" |
16 #include "ui/base/page_transition_types.h" | 17 #include "ui/base/page_transition_types.h" |
17 | 18 |
18 class GURL; | 19 class GURL; |
19 | 20 |
20 namespace net { | 21 namespace net { |
21 class HttpResponseHeaders; | 22 class HttpResponseHeaders; |
22 } // namespace net | 23 } // namespace net |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // | 114 // |
114 // Note: page and frame navigations can only be done using HTTP POST or HTTP | 115 // Note: page and frame navigations can only be done using HTTP POST or HTTP |
115 // GET methods (and using other, scheme-specific protocols for non-http(s) URI | 116 // GET methods (and using other, scheme-specific protocols for non-http(s) URI |
116 // schemes like data: or file:). Therefore //content public API exposes only | 117 // schemes like data: or file:). Therefore //content public API exposes only |
117 // |bool IsPost()| as opposed to |const std::string& GetMethod()| method. | 118 // |bool IsPost()| as opposed to |const std::string& GetMethod()| method. |
118 virtual bool IsPost() = 0; | 119 virtual bool IsPost() = 0; |
119 | 120 |
120 // Returns a sanitized version of the referrer for this request. | 121 // Returns a sanitized version of the referrer for this request. |
121 virtual const Referrer& GetReferrer() = 0; | 122 virtual const Referrer& GetReferrer() = 0; |
122 | 123 |
123 // Whether the navigation was initiated by a user gesture. Note that this | 124 // The type of NavigationGesture that initiated the navigation for this |
124 // will return false for browser-initiated navigations. | 125 // NavigationHandle. Note that this will return NavigationGestureAuto for |
125 // TODO(clamy): when PlzNavigate launches, this should return true for | 126 // browser-initiated navigations. TODO(clamy): when PlzNavigate launches, |
126 // browser-initiated navigations. | 127 // this should return NavigationGestureUser for browser-initiated navigations. |
127 virtual bool HasUserGesture() = 0; | 128 virtual NavigationGesture GetNavigationGesture() = 0; |
128 | 129 |
129 // Returns the page transition type. | 130 // Returns the page transition type. |
130 virtual ui::PageTransition GetPageTransition() = 0; | 131 virtual ui::PageTransition GetPageTransition() = 0; |
131 | 132 |
132 // Whether the target URL cannot be handled by the browser's internal protocol | 133 // Whether the target URL cannot be handled by the browser's internal protocol |
133 // handlers. | 134 // handlers. |
134 virtual bool IsExternalProtocol() = 0; | 135 virtual bool IsExternalProtocol() = 0; |
135 | 136 |
136 // Navigation control flow -------------------------------------------------- | 137 // Navigation control flow -------------------------------------------------- |
137 | 138 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 205 |
205 // Testing methods ---------------------------------------------------------- | 206 // Testing methods ---------------------------------------------------------- |
206 // | 207 // |
207 // The following methods should be used exclusively for writing unit tests. | 208 // The following methods should be used exclusively for writing unit tests. |
208 | 209 |
209 static std::unique_ptr<NavigationHandle> CreateNavigationHandleForTesting( | 210 static std::unique_ptr<NavigationHandle> CreateNavigationHandleForTesting( |
210 const GURL& url, | 211 const GURL& url, |
211 RenderFrameHost* render_frame_host, | 212 RenderFrameHost* render_frame_host, |
212 bool committed = false, | 213 bool committed = false, |
213 net::Error error = net::OK, | 214 net::Error error = net::OK, |
214 bool has_user_gesture = false); | 215 NavigationGesture gesture = NavigationGestureUnknown); |
215 | 216 |
216 // Registers a NavigationThrottle for tests. The throttle can | 217 // Registers a NavigationThrottle for tests. The throttle can |
217 // modify the request, pause the request or cancel the request. This will | 218 // modify the request, pause the request or cancel the request. This will |
218 // take ownership of the NavigationThrottle. | 219 // take ownership of the NavigationThrottle. |
219 // Note: in non-test cases, NavigationThrottles should not be added directly | 220 // Note: in non-test cases, NavigationThrottles should not be added directly |
220 // but returned by the implementation of | 221 // but returned by the implementation of |
221 // ContentBrowserClient::CreateThrottlesForNavigation. This ensures proper | 222 // ContentBrowserClient::CreateThrottlesForNavigation. This ensures proper |
222 // ordering of the throttles. | 223 // ordering of the throttles. |
223 virtual void RegisterThrottleForTesting( | 224 virtual void RegisterThrottleForTesting( |
224 std::unique_ptr<NavigationThrottle> navigation_throttle) = 0; | 225 std::unique_ptr<NavigationThrottle> navigation_throttle) = 0; |
(...skipping 23 matching lines...) Expand all Loading... |
248 | 249 |
249 // The NavigationData that the embedder returned from | 250 // The NavigationData that the embedder returned from |
250 // ResourceDispatcherHostDelegate::GetNavigationData during commit. This will | 251 // ResourceDispatcherHostDelegate::GetNavigationData during commit. This will |
251 // be a clone of the NavigationData. | 252 // be a clone of the NavigationData. |
252 virtual NavigationData* GetNavigationData() = 0; | 253 virtual NavigationData* GetNavigationData() = 0; |
253 }; | 254 }; |
254 | 255 |
255 } // namespace content | 256 } // namespace content |
256 | 257 |
257 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ | 258 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ |
OLD | NEW |