Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: content/browser/frame_host/navigation_handle_impl.h

Issue 2321543002: Merge CrossSiteResourceHandler and NavigationResourceThrottle (Closed)
Patch Set: Fixed test compilation error Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_ 5 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_
6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_ 6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_
7 7
8 #include "content/public/browser/navigation_handle.h" 8 #include "content/public/browser/navigation_handle.h"
9 9
10 #include <stddef.h> 10 #include <stddef.h>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
16 #include "content/browser/frame_host/frame_tree_node.h" 16 #include "content/browser/frame_host/frame_tree_node.h"
17 #include "content/browser/frame_host/render_frame_host_impl.h" 17 #include "content/browser/frame_host/render_frame_host_impl.h"
18 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
19 #include "content/public/browser/global_request_id.h"
19 #include "content/public/browser/navigation_data.h" 20 #include "content/public/browser/navigation_data.h"
20 #include "content/public/browser/navigation_throttle.h" 21 #include "content/public/browser/navigation_throttle.h"
21 #include "content/public/common/request_context_type.h" 22 #include "content/public/common/request_context_type.h"
22 #include "content/public/common/ssl_status.h" 23 #include "content/public/common/ssl_status.h"
23 #include "url/gurl.h" 24 #include "url/gurl.h"
24 25
25 struct FrameHostMsg_DidCommitProvisionalLoad_Params; 26 struct FrameHostMsg_DidCommitProvisionalLoad_Params;
26 27
27 namespace content { 28 namespace content {
28 29
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 145
145 // Returns whether the navigation is currently being transferred from one 146 // Returns whether the navigation is currently being transferred from one
146 // RenderFrameHost to another. In particular, a DidStartProvisionalLoad IPC 147 // RenderFrameHost to another. In particular, a DidStartProvisionalLoad IPC
147 // for the navigation URL, received in the new RenderFrameHost, should not 148 // for the navigation URL, received in the new RenderFrameHost, should not
148 // indicate the start of a new navigation in that case. 149 // indicate the start of a new navigation in that case.
149 bool is_transferring() const { return is_transferring_; } 150 bool is_transferring() const { return is_transferring_; }
150 void set_is_transferring(bool is_transferring) { 151 void set_is_transferring(bool is_transferring) {
151 is_transferring_ = is_transferring; 152 is_transferring_ = is_transferring;
152 } 153 }
153 154
154 // Updates the RenderFrameHost that is about to commit the navigation. This
155 // is used during transfer navigations.
156 void set_render_frame_host(RenderFrameHostImpl* render_frame_host) {
157 render_frame_host_ = render_frame_host;
158 }
159
160 // Returns the POST body associated with this navigation. This will be 155 // Returns the POST body associated with this navigation. This will be
161 // null for GET and/or other non-POST requests (or if a response to a POST 156 // null for GET and/or other non-POST requests (or if a response to a POST
162 // request was a redirect that changed the method to GET - for example 302). 157 // request was a redirect that changed the method to GET - for example 302).
163 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body() const { 158 const scoped_refptr<ResourceRequestBodyImpl>& resource_request_body() const {
164 return resource_request_body_; 159 return resource_request_body_;
165 } 160 }
166 161
167 typedef base::Callback<void(NavigationThrottle::ThrottleCheckResult)> 162 typedef base::Callback<void(NavigationThrottle::ThrottleCheckResult)>
168 ThrottleChecksFinishedCallback; 163 ThrottleChecksFinishedCallback;
169 164
(...skipping 22 matching lines...) Expand all
192 scoped_refptr<net::HttpResponseHeaders> response_headers, 187 scoped_refptr<net::HttpResponseHeaders> response_headers,
193 const ThrottleChecksFinishedCallback& callback); 188 const ThrottleChecksFinishedCallback& callback);
194 189
195 // Called when the URLRequest has delivered response headers and metadata. 190 // Called when the URLRequest has delivered response headers and metadata.
196 // |callback| will be called when all throttle checks have completed, 191 // |callback| will be called when all throttle checks have completed,
197 // allowing the caller to cancel the navigation or let it proceed. 192 // allowing the caller to cancel the navigation or let it proceed.
198 // NavigationHandle will not call |callback| with a result of DEFER. 193 // NavigationHandle will not call |callback| with a result of DEFER.
199 // If the result is PROCEED, then 'ReadyToCommitNavigation' will be called 194 // If the result is PROCEED, then 'ReadyToCommitNavigation' will be called
200 // with |render_frame_host| and |response_headers| just before calling 195 // with |render_frame_host| and |response_headers| just before calling
201 // |callback|. 196 // |callback|.
197 // Should a transfer navigation happen, |transfer_callback| will be run on
nasko 2016/09/08 00:35:36 nit: Move to previous line.
clamy 2016/09/09 15:06:41 Done.
198 // the IO thread.
199 // PlzNavigate: transfer navigations are not possible.
202 void WillProcessResponse( 200 void WillProcessResponse(
203 RenderFrameHostImpl* render_frame_host, 201 RenderFrameHostImpl* render_frame_host,
204 scoped_refptr<net::HttpResponseHeaders> response_headers, 202 scoped_refptr<net::HttpResponseHeaders> response_headers,
205 const SSLStatus& ssl_status, 203 const SSLStatus& ssl_status,
204 const GlobalRequestID& request_id,
205 bool should_replace_current_entry,
206 bool is_download,
207 bool is_stream,
208 const base::Closure& transfer_callback,
206 const ThrottleChecksFinishedCallback& callback); 209 const ThrottleChecksFinishedCallback& callback);
207 210
208 // Returns the FrameTreeNode this navigation is happening in. 211 // Returns the FrameTreeNode this navigation is happening in.
209 FrameTreeNode* frame_tree_node() { return frame_tree_node_; } 212 FrameTreeNode* frame_tree_node() { return frame_tree_node_; }
210 213
211 // Called when the navigation is ready to be committed in 214 // Called when the navigation is ready to be committed in
212 // |render_frame_host|. This will update the |state_| and inform the 215 // |render_frame_host|. This will update the |state_| and inform the
213 // delegate. 216 // delegate.
214 void ReadyToCommitNavigation(RenderFrameHostImpl* render_frame_host); 217 void ReadyToCommitNavigation(RenderFrameHostImpl* render_frame_host);
215 218
(...skipping 11 matching lines...) Expand all
227 230
228 // Called during commit. Takes ownership of the embedder's NavigationData 231 // Called during commit. Takes ownership of the embedder's NavigationData
229 // instance. This NavigationData may have been cloned prior to being added 232 // instance. This NavigationData may have been cloned prior to being added
230 // here. 233 // here.
231 void set_navigation_data(std::unique_ptr<NavigationData> navigation_data) { 234 void set_navigation_data(std::unique_ptr<NavigationData> navigation_data) {
232 navigation_data_ = std::move(navigation_data); 235 navigation_data_ = std::move(navigation_data);
233 } 236 }
234 237
235 SSLStatus ssl_status() { return ssl_status_; } 238 SSLStatus ssl_status() { return ssl_status_; }
236 239
240 const GlobalRequestID& request_id() const { return request_id_; }
241
242 // Called when the navigation is transferred to a RenderFrameHost.
243 void TransferredToRenderFrameHost(RenderFrameHostImpl* render_frame_host);
nasko 2016/09/08 23:45:39 The name and the comment implies that the transfer
clamy 2016/09/09 15:06:41 Done.
244
237 private: 245 private:
238 friend class NavigationHandleImplTest; 246 friend class NavigationHandleImplTest;
239 247
240 // Used to track the state the navigation is currently in. 248 // Used to track the state the navigation is currently in.
241 enum State { 249 enum State {
242 INITIAL = 0, 250 INITIAL = 0,
243 WILL_SEND_REQUEST, 251 WILL_SEND_REQUEST,
244 DEFERRING_START, 252 DEFERRING_START,
245 WILL_REDIRECT_REQUEST, 253 WILL_REDIRECT_REQUEST,
246 DEFERRING_REDIRECT, 254 DEFERRING_REDIRECT,
(...skipping 10 matching lines...) Expand all
257 bool is_renderer_initiated, 265 bool is_renderer_initiated,
258 bool is_synchronous, 266 bool is_synchronous,
259 bool is_srcdoc, 267 bool is_srcdoc,
260 const base::TimeTicks& navigation_start, 268 const base::TimeTicks& navigation_start,
261 int pending_nav_entry_id); 269 int pending_nav_entry_id);
262 270
263 NavigationThrottle::ThrottleCheckResult CheckWillStartRequest(); 271 NavigationThrottle::ThrottleCheckResult CheckWillStartRequest();
264 NavigationThrottle::ThrottleCheckResult CheckWillRedirectRequest(); 272 NavigationThrottle::ThrottleCheckResult CheckWillRedirectRequest();
265 NavigationThrottle::ThrottleCheckResult CheckWillProcessResponse(); 273 NavigationThrottle::ThrottleCheckResult CheckWillProcessResponse();
266 274
275 // Called when WillProcessResponse checks are done, to find the final
276 // RenderFrameHost for the navigation. Returns true if the navigation should
277 // proceed.
278 bool GetFinalRenderFrameHost();
nasko 2016/09/08 23:45:39 A GetType method should return Type, not bool. Let
clamy 2016/09/09 15:06:41 How about FindFinaleFrameHost?
nasko 2016/09/09 23:30:27 sgtm
279
280 // Check whether the navigation should be transferred. Returns false if the
281 // transfer attempt results in the destruction of this NavigationHandle.
282 bool CheckForTransfer();
nasko 2016/09/08 23:45:39 A bool return value from CheckForTransfer reads to
clamy 2016/09/09 15:06:41 How about MaybeTransferAndProceed? It's not great
nasko 2016/09/09 23:30:27 I think it is definitely better. If I think of any
283
267 // Helper function to run and reset the |complete_callback_|. This marks the 284 // Helper function to run and reset the |complete_callback_|. This marks the
268 // end of a round of NavigationThrottleChecks. 285 // end of a round of NavigationThrottleChecks.
269 void RunCompleteCallback(NavigationThrottle::ThrottleCheckResult result); 286 void RunCompleteCallback(NavigationThrottle::ThrottleCheckResult result);
270 287
271 // Used in tests. 288 // Used in tests.
272 State state() const { return state_; } 289 State state() const { return state_; }
273 290
274 // Populates |throttles_| with the throttles for this navigation. 291 // Populates |throttles_| with the throttles for this navigation.
275 void RegisterNavigationThrottles(); 292 void RegisterNavigationThrottles();
276 293
277 // See NavigationHandle for a description of those member variables. 294 // See NavigationHandle for a description of those member variables.
278 GURL url_; 295 GURL url_;
279 Referrer sanitized_referrer_; 296 Referrer sanitized_referrer_;
280 bool has_user_gesture_; 297 bool has_user_gesture_;
281 ui::PageTransition transition_; 298 ui::PageTransition transition_;
282 bool is_external_protocol_; 299 bool is_external_protocol_;
283 net::Error net_error_code_; 300 net::Error net_error_code_;
284 RenderFrameHostImpl* render_frame_host_; 301 RenderFrameHostImpl* render_frame_host_;
285 const bool is_renderer_initiated_; 302 const bool is_renderer_initiated_;
286 bool is_same_page_; 303 bool is_same_page_;
287 const bool is_synchronous_; 304 const bool is_synchronous_;
288 const bool is_srcdoc_; 305 const bool is_srcdoc_;
289 bool was_redirected_; 306 bool was_redirected_;
290 scoped_refptr<net::HttpResponseHeaders> response_headers_; 307 scoped_refptr<net::HttpResponseHeaders> response_headers_;
291 308
309 // The original url of the navigation. This may differ from |url_| if the
310 // navigation encounters redirects.
311 const GURL original_url_;
312
292 // The HTTP method used for the navigation. 313 // The HTTP method used for the navigation.
293 std::string method_; 314 std::string method_;
294 315
295 // The POST body associated with this navigation. This will be null for GET 316 // The POST body associated with this navigation. This will be null for GET
296 // and/or other non-POST requests (or if a response to a POST request was a 317 // and/or other non-POST requests (or if a response to a POST request was a
297 // redirect that changed the method to GET - for example 302). 318 // redirect that changed the method to GET - for example 302).
298 scoped_refptr<ResourceRequestBodyImpl> resource_request_body_; 319 scoped_refptr<ResourceRequestBodyImpl> resource_request_body_;
299 320
300 // The state the navigation is in. 321 // The state the navigation is in.
301 State state_; 322 State state_;
(...skipping 21 matching lines...) Expand all
323 RequestContextType request_context_type_; 344 RequestContextType request_context_type_;
324 345
325 // This callback will be run when all throttle checks have been performed. 346 // This callback will be run when all throttle checks have been performed.
326 ThrottleChecksFinishedCallback complete_callback_; 347 ThrottleChecksFinishedCallback complete_callback_;
327 348
328 // Embedder data tied to this navigation. 349 // Embedder data tied to this navigation.
329 std::unique_ptr<NavigationData> navigation_data_; 350 std::unique_ptr<NavigationData> navigation_data_;
330 351
331 SSLStatus ssl_status_; 352 SSLStatus ssl_status_;
332 353
354 // The id of the URLRequest tied to this navigation.
355 GlobalRequestID request_id_;
356
357 // Whether the current NavigationEntry should be replaced upon commit.
358 bool should_replace_current_entry_;
359
360 // The chain of redirects.
361 std::vector<GURL> redirect_chain_;
362
363 // A callback to run on the IO thread if the navigation transfers.
364 base::Closure transfer_callback_;
365
366 // Whether the navigation ended up being a download or a stream.
367 bool is_download_;
368 bool is_stream_;
369
370 base::WeakPtrFactory<NavigationHandleImpl> weak_factory_;
371
333 DISALLOW_COPY_AND_ASSIGN(NavigationHandleImpl); 372 DISALLOW_COPY_AND_ASSIGN(NavigationHandleImpl);
334 }; 373 };
335 374
336 } // namespace content 375 } // namespace content
337 376
338 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_ 377 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698