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

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

Issue 2397893002: Revert the merge of CrossSiteResourceHandler and NavigationResourceThrottle. (Closed)
Patch Set: Add back initialization of started_from_context_menu_. Created 4 years, 2 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 #include <string> 11 #include <string>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_vector.h" 16 #include "base/memory/scoped_vector.h"
17 #include "content/browser/frame_host/frame_tree_node.h" 17 #include "content/browser/frame_host/frame_tree_node.h"
18 #include "content/browser/frame_host/render_frame_host_impl.h" 18 #include "content/browser/frame_host/render_frame_host_impl.h"
19 #include "content/common/content_export.h" 19 #include "content/common/content_export.h"
20 #include "content/public/browser/global_request_id.h"
21 #include "content/public/browser/navigation_data.h" 20 #include "content/public/browser/navigation_data.h"
22 #include "content/public/browser/navigation_throttle.h" 21 #include "content/public/browser/navigation_throttle.h"
23 #include "content/public/browser/ssl_status.h" 22 #include "content/public/browser/ssl_status.h"
24 #include "content/public/common/request_context_type.h" 23 #include "content/public/common/request_context_type.h"
25 #include "url/gurl.h" 24 #include "url/gurl.h"
26 25
27 struct FrameHostMsg_DidCommitProvisionalLoad_Params; 26 struct FrameHostMsg_DidCommitProvisionalLoad_Params;
28 27
29 namespace content { 28 namespace content {
30 29
31 class NavigationUIData; 30 class NavigationUIData;
32 class NavigatorDelegate; 31 class NavigatorDelegate;
33 class ResourceRequestBodyImpl; 32 class ResourceRequestBodyImpl;
34 class ServiceWorkerContextWrapper; 33 class ServiceWorkerContextWrapper;
35 class ServiceWorkerNavigationHandle; 34 class ServiceWorkerNavigationHandle;
36 class SiteInstance;
37 35
38 // This class keeps track of a single navigation. It is created upon receipt of 36 // This class keeps track of a single navigation. It is created upon receipt of
39 // a DidStartProvisionalLoad IPC in a RenderFrameHost. The RenderFrameHost owns 37 // a DidStartProvisionalLoad IPC in a RenderFrameHost. The RenderFrameHost owns
40 // the newly created NavigationHandleImpl as long as the navigation is ongoing. 38 // the newly created NavigationHandleImpl as long as the navigation is ongoing.
41 // The NavigationHandleImpl in the RenderFrameHost will be reset when the 39 // The NavigationHandleImpl in the RenderFrameHost will be reset when the
42 // navigation stops, that is if one of the following events happen: 40 // navigation stops, that is if one of the following events happen:
43 // - The RenderFrameHost receives a DidStartProvisionalLoad IPC for a new 41 // - The RenderFrameHost receives a DidStartProvisionalLoad IPC for a new
44 // navigation (see below for special cases where the DidStartProvisionalLoad 42 // navigation (see below for special cases where the DidStartProvisionalLoad
45 // message does not indicate the start of a new navigation). 43 // message does not indicate the start of a new navigation).
46 // - The RenderFrameHost stops loading. 44 // - The RenderFrameHost stops loading.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 bool new_is_external_protocol, 216 bool new_is_external_protocol,
219 scoped_refptr<net::HttpResponseHeaders> response_headers, 217 scoped_refptr<net::HttpResponseHeaders> response_headers,
220 const ThrottleChecksFinishedCallback& callback); 218 const ThrottleChecksFinishedCallback& callback);
221 219
222 // Called when the URLRequest has delivered response headers and metadata. 220 // Called when the URLRequest has delivered response headers and metadata.
223 // |callback| will be called when all throttle checks have completed, 221 // |callback| will be called when all throttle checks have completed,
224 // allowing the caller to cancel the navigation or let it proceed. 222 // allowing the caller to cancel the navigation or let it proceed.
225 // NavigationHandle will not call |callback| with a result of DEFER. 223 // NavigationHandle will not call |callback| with a result of DEFER.
226 // If the result is PROCEED, then 'ReadyToCommitNavigation' will be called 224 // If the result is PROCEED, then 'ReadyToCommitNavigation' will be called
227 // with |render_frame_host| and |response_headers| just before calling 225 // with |render_frame_host| and |response_headers| just before calling
228 // |callback|. Should a transfer navigation happen, |transfer_callback| will 226 // |callback|.
229 // be run on the IO thread.
230 // PlzNavigate: transfer navigations are not possible.
231 void WillProcessResponse( 227 void WillProcessResponse(
232 RenderFrameHostImpl* render_frame_host, 228 RenderFrameHostImpl* render_frame_host,
233 scoped_refptr<net::HttpResponseHeaders> response_headers, 229 scoped_refptr<net::HttpResponseHeaders> response_headers,
234 const SSLStatus& ssl_status, 230 const SSLStatus& ssl_status,
235 const GlobalRequestID& request_id,
236 bool should_replace_current_entry,
237 bool is_download,
238 bool is_stream,
239 const base::Closure& transfer_callback,
240 const ThrottleChecksFinishedCallback& callback); 231 const ThrottleChecksFinishedCallback& callback);
241 232
242 // Returns the FrameTreeNode this navigation is happening in. 233 // Returns the FrameTreeNode this navigation is happening in.
243 FrameTreeNode* frame_tree_node() { return frame_tree_node_; } 234 FrameTreeNode* frame_tree_node() { return frame_tree_node_; }
244 235
245 // Called when the navigation is ready to be committed in 236 // Called when the navigation is ready to be committed in
246 // |render_frame_host|. This will update the |state_| and inform the 237 // |render_frame_host|. This will update the |state_| and inform the
247 // delegate. 238 // delegate.
248 void ReadyToCommitNavigation(RenderFrameHostImpl* render_frame_host); 239 void ReadyToCommitNavigation(RenderFrameHostImpl* render_frame_host);
249 240
250 // Called when the navigation was committed in |render_frame_host|. This will 241 // Called when the navigation was committed in |render_frame_host|. This will
251 // update the |state_|. 242 // update the |state_|.
252 void DidCommitNavigation( 243 void DidCommitNavigation(
253 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, 244 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
254 bool same_page, 245 bool same_page,
255 RenderFrameHostImpl* render_frame_host); 246 RenderFrameHostImpl* render_frame_host);
256 247
257 // Called during commit. Takes ownership of the embedder's NavigationData 248 // Called during commit. Takes ownership of the embedder's NavigationData
258 // instance. This NavigationData may have been cloned prior to being added 249 // instance. This NavigationData may have been cloned prior to being added
259 // here. 250 // here.
260 void set_navigation_data(std::unique_ptr<NavigationData> navigation_data) { 251 void set_navigation_data(std::unique_ptr<NavigationData> navigation_data) {
261 navigation_data_ = std::move(navigation_data); 252 navigation_data_ = std::move(navigation_data);
262 } 253 }
263 254
264 SSLStatus ssl_status() { return ssl_status_; } 255 SSLStatus ssl_status() { return ssl_status_; }
265 256
266 // This is valid after the network response has started.
267 // TODO(clamy): See if this can be initialized earlier if needed by
268 // non-transfer code. There may be some issues in PlzNavigate, where
269 // WillStartRequest will be called before starting a request on the IO thread.
270 const GlobalRequestID& request_id() const {
271 DCHECK_GE(state_, WILL_PROCESS_RESPONSE);
272 return request_id_;
273 }
274
275 // Called when the navigation is transferred to a different renderer.
276 void Transfer();
277
278 NavigationUIData* navigation_ui_data() const { 257 NavigationUIData* navigation_ui_data() const {
279 return navigation_ui_data_.get(); 258 return navigation_ui_data_.get();
280 } 259 }
281 260
282 private: 261 private:
283 friend class NavigationHandleImplTest; 262 friend class NavigationHandleImplTest;
284 263
285 // Used to track the state the navigation is currently in. 264 // Used to track the state the navigation is currently in.
286 enum State { 265 enum State {
287 INITIAL = 0, 266 INITIAL = 0,
(...skipping 15 matching lines...) Expand all
303 bool is_synchronous, 282 bool is_synchronous,
304 bool is_srcdoc, 283 bool is_srcdoc,
305 const base::TimeTicks& navigation_start, 284 const base::TimeTicks& navigation_start,
306 int pending_nav_entry_id, 285 int pending_nav_entry_id,
307 bool started_from_context_menu); 286 bool started_from_context_menu);
308 287
309 NavigationThrottle::ThrottleCheckResult CheckWillStartRequest(); 288 NavigationThrottle::ThrottleCheckResult CheckWillStartRequest();
310 NavigationThrottle::ThrottleCheckResult CheckWillRedirectRequest(); 289 NavigationThrottle::ThrottleCheckResult CheckWillRedirectRequest();
311 NavigationThrottle::ThrottleCheckResult CheckWillProcessResponse(); 290 NavigationThrottle::ThrottleCheckResult CheckWillProcessResponse();
312 291
313 // Called when WillProcessResponse checks are done, to find the final
314 // RenderFrameHost for the navigation. Checks whether the navigation should be
315 // transferred. Returns false if the transfer attempt results in the
316 // destruction of this NavigationHandle and the navigation should no longer
317 // proceed. This can happen when the RenderFrameHostManager determines a
318 // transfer is needed, but WebContentsDelegate::ShouldTransferNavigation
319 // returns false.
320 bool MaybeTransferAndProceed();
321
322 // Helper method for MaybeTransferAndProceed. Returns false if the transfer
323 // attempt results in the destruction of this NavigationHandle.
324 bool MaybeTransferAndProceedInternal();
325
326 // Helper function to run and reset the |complete_callback_|. This marks the 292 // Helper function to run and reset the |complete_callback_|. This marks the
327 // end of a round of NavigationThrottleChecks. 293 // end of a round of NavigationThrottleChecks.
328 void RunCompleteCallback(NavigationThrottle::ThrottleCheckResult result); 294 void RunCompleteCallback(NavigationThrottle::ThrottleCheckResult result);
329 295
330 // Used in tests. 296 // Used in tests.
331 State state() const { return state_; } 297 State state() const { return state_; }
332 298
333 // Populates |throttles_| with the throttles for this navigation. 299 // Populates |throttles_| with the throttles for this navigation.
334 void RegisterNavigationThrottles(); 300 void RegisterNavigationThrottles();
335 301
336 // See NavigationHandle for a description of those member variables. 302 // See NavigationHandle for a description of those member variables.
337 GURL url_; 303 GURL url_;
338 Referrer sanitized_referrer_; 304 Referrer sanitized_referrer_;
339 bool has_user_gesture_; 305 bool has_user_gesture_;
340 ui::PageTransition transition_; 306 ui::PageTransition transition_;
341 bool is_external_protocol_; 307 bool is_external_protocol_;
342 net::Error net_error_code_; 308 net::Error net_error_code_;
343 RenderFrameHostImpl* render_frame_host_; 309 RenderFrameHostImpl* render_frame_host_;
344 const bool is_renderer_initiated_; 310 const bool is_renderer_initiated_;
345 bool is_same_page_; 311 bool is_same_page_;
346 const bool is_synchronous_; 312 const bool is_synchronous_;
347 const bool is_srcdoc_; 313 const bool is_srcdoc_;
348 bool was_redirected_; 314 bool was_redirected_;
349 scoped_refptr<net::HttpResponseHeaders> response_headers_; 315 scoped_refptr<net::HttpResponseHeaders> response_headers_;
350 316
351 // The original url of the navigation. This may differ from |url_| if the
352 // navigation encounters redirects.
353 const GURL original_url_;
354
355 // The HTTP method used for the navigation. 317 // The HTTP method used for the navigation.
356 std::string method_; 318 std::string method_;
357 319
358 // The POST body associated with this navigation. This will be null for GET 320 // The POST body associated with this navigation. This will be null for GET
359 // and/or other non-POST requests (or if a response to a POST request was a 321 // and/or other non-POST requests (or if a response to a POST request was a
360 // redirect that changed the method to GET - for example 302). 322 // redirect that changed the method to GET - for example 302).
361 scoped_refptr<ResourceRequestBodyImpl> resource_request_body_; 323 scoped_refptr<ResourceRequestBodyImpl> resource_request_body_;
362 324
363 // The state the navigation is in. 325 // The state the navigation is in.
364 State state_; 326 State state_;
(...skipping 30 matching lines...) Expand all
395 357
396 // Embedder data from the IO thread tied to this navigation. 358 // Embedder data from the IO thread tied to this navigation.
397 std::unique_ptr<NavigationData> navigation_data_; 359 std::unique_ptr<NavigationData> navigation_data_;
398 360
399 // PlzNavigate 361 // PlzNavigate
400 // Embedder data from the UI thread tied to this navigation. 362 // Embedder data from the UI thread tied to this navigation.
401 std::unique_ptr<NavigationUIData> navigation_ui_data_; 363 std::unique_ptr<NavigationUIData> navigation_ui_data_;
402 364
403 SSLStatus ssl_status_; 365 SSLStatus ssl_status_;
404 366
405 // The id of the URLRequest tied to this navigation.
406 GlobalRequestID request_id_;
407
408 // Whether the current NavigationEntry should be replaced upon commit.
409 bool should_replace_current_entry_;
410
411 // The chain of redirects.
412 std::vector<GURL> redirect_chain_;
413
414 // A callback to run on the IO thread if the navigation transfers.
415 base::Closure transfer_callback_;
416
417 // Whether the navigation ended up being a download or a stream.
418 bool is_download_;
419 bool is_stream_;
420
421 // False by default unless the navigation started within a context menu. 367 // False by default unless the navigation started within a context menu.
422 bool started_from_context_menu_; 368 bool started_from_context_menu_;
423 369
424 base::WeakPtrFactory<NavigationHandleImpl> weak_factory_;
425
426 DISALLOW_COPY_AND_ASSIGN(NavigationHandleImpl); 370 DISALLOW_COPY_AND_ASSIGN(NavigationHandleImpl);
427 }; 371 };
428 372
429 } // namespace content 373 } // namespace content
430 374
431 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_ 375 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698