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

Side by Side Diff: content/browser/frame_host/navigation_request.cc

Issue 2488743003: (Re-)introduce AncestorThrottle to handle 'X-Frame-Options'. (Closed)
Patch Set: Addressed comments (@clamy). Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "content/browser/frame_host/navigation_request.h" 5 #include "content/browser/frame_host/navigation_request.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "content/browser/child_process_security_policy_impl.h" 9 #include "content/browser/child_process_security_policy_impl.h"
10 #include "content/browser/devtools/render_frame_devtools_agent_host.h" 10 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 render_frame_host, response->head.headers.get(), 439 render_frame_host, response->head.headers.get(),
440 response->head.connection_info, ssl_status, request_id, 440 response->head.connection_info, ssl_status, request_id,
441 common_params_.should_replace_current_entry, is_download, is_stream, 441 common_params_.should_replace_current_entry, is_download, is_stream,
442 base::Closure(), 442 base::Closure(),
443 base::Bind(&NavigationRequest::OnWillProcessResponseChecksComplete, 443 base::Bind(&NavigationRequest::OnWillProcessResponseChecksComplete,
444 base::Unretained(this))); 444 base::Unretained(this)));
445 } 445 }
446 446
447 void NavigationRequest::OnRequestFailed(bool has_stale_copy_in_cache, 447 void NavigationRequest::OnRequestFailed(bool has_stale_copy_in_cache,
448 int net_error) { 448 int net_error) {
449 DCHECK(state_ == STARTED); 449 DCHECK(state_ == STARTED || state_ == RESPONSE_STARTED);
450 state_ = FAILED; 450 state_ = FAILED;
451 navigation_handle_->set_net_error_code(static_cast<net::Error>(net_error)); 451 navigation_handle_->set_net_error_code(static_cast<net::Error>(net_error));
452 frame_tree_node_->navigator()->FailedNavigation( 452 frame_tree_node_->navigator()->FailedNavigation(
453 frame_tree_node_, has_stale_copy_in_cache, net_error); 453 frame_tree_node_, has_stale_copy_in_cache, net_error);
454 } 454 }
455 455
456 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { 456 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) {
457 if (frame_tree_node_->IsMainFrame()) { 457 if (frame_tree_node_->IsMainFrame()) {
458 TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP0( 458 TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP0(
459 "navigation", "Navigation timeToNetworkStack", navigation_handle_.get(), 459 "navigation", "Navigation timeToNetworkStack", navigation_handle_.get(),
460 timestamp); 460 timestamp);
461 } 461 }
462 462
463 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, 463 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp,
464 common_params_.url); 464 common_params_.url);
465 } 465 }
466 466
467 void NavigationRequest::OnStartChecksComplete( 467 void NavigationRequest::OnStartChecksComplete(
468 NavigationThrottle::ThrottleCheckResult result) { 468 NavigationThrottle::ThrottleCheckResult result) {
469 CHECK(result != NavigationThrottle::DEFER); 469 CHECK(result != NavigationThrottle::DEFER);
470 CHECK(result != NavigationThrottle::BLOCK_RESPONSE);
clamy 2016/12/09 17:14:01 nit: this should be changed to DCHECK. Same below.
470 471
471 // Abort the request if needed. This will destroy the NavigationRequest. 472 // Abort the request if needed. This will destroy the NavigationRequest.
472 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 473 if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
473 result == NavigationThrottle::CANCEL) { 474 result == NavigationThrottle::CANCEL) {
474 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 475 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
475 frame_tree_node_->ResetNavigationRequest(false); 476 frame_tree_node_->ResetNavigationRequest(false);
476 return; 477 return;
477 } 478 }
478 479
479 if (result == NavigationThrottle::BLOCK_REQUEST) { 480 if (result == NavigationThrottle::BLOCK_REQUEST) {
480 OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT); 481 OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT);
482 // DO NOT ADD CODE after this. The previous call to OnRequestFailed have
clamy 2016/12/09 17:14:01 nit:s/have/has
arthursonzogni 2016/12/13 15:32:13 Done
483 // destroyed the NavigationRequest.
481 return; 484 return;
482 } 485 }
483 486
484 // Use the SiteInstance of the navigating RenderFrameHost to get access to 487 // Use the SiteInstance of the navigating RenderFrameHost to get access to
485 // the StoragePartition. Using the url of the navigation will result in a 488 // the StoragePartition. Using the url of the navigation will result in a
486 // wrong StoragePartition being picked when a WebView is navigating. 489 // wrong StoragePartition being picked when a WebView is navigating.
487 DCHECK_NE(AssociatedSiteInstanceType::NONE, associated_site_instance_type_); 490 DCHECK_NE(AssociatedSiteInstanceType::NONE, associated_site_instance_type_);
488 RenderFrameHostImpl* navigating_frame_host = 491 RenderFrameHostImpl* navigating_frame_host =
489 associated_site_instance_type_ == AssociatedSiteInstanceType::SPECULATIVE 492 associated_site_instance_type_ == AssociatedSiteInstanceType::SPECULATIVE
490 ? frame_tree_node_->render_manager()->speculative_frame_host() 493 ? frame_tree_node_->render_manager()->speculative_frame_host()
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 parent_is_main_frame, IsSecureFrame(frame_tree_node_->parent()), 547 parent_is_main_frame, IsSecureFrame(frame_tree_node_->parent()),
545 frame_tree_node_->frame_tree_node_id(), is_for_guests_only, 548 frame_tree_node_->frame_tree_node_id(), is_for_guests_only,
546 report_raw_headers), 549 report_raw_headers),
547 std::move(navigation_ui_data), 550 std::move(navigation_ui_data),
548 navigation_handle_->service_worker_handle(), this); 551 navigation_handle_->service_worker_handle(), this);
549 } 552 }
550 553
551 void NavigationRequest::OnRedirectChecksComplete( 554 void NavigationRequest::OnRedirectChecksComplete(
552 NavigationThrottle::ThrottleCheckResult result) { 555 NavigationThrottle::ThrottleCheckResult result) {
553 CHECK(result != NavigationThrottle::DEFER); 556 CHECK(result != NavigationThrottle::DEFER);
557 CHECK(result != NavigationThrottle::BLOCK_RESPONSE);
554 558
555 // Abort the request if needed. This will destroy the NavigationRequest. 559 // Abort the request if needed. This will destroy the NavigationRequest.
556 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 560 if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
557 result == NavigationThrottle::CANCEL) { 561 result == NavigationThrottle::CANCEL) {
558 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 562 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
559 frame_tree_node_->ResetNavigationRequest(false); 563 frame_tree_node_->ResetNavigationRequest(false);
560 return; 564 return;
561 } 565 }
562 566
563 loader_->FollowRedirect(); 567 loader_->FollowRedirect();
564 } 568 }
565 569
566 void NavigationRequest::OnWillProcessResponseChecksComplete( 570 void NavigationRequest::OnWillProcessResponseChecksComplete(
567 NavigationThrottle::ThrottleCheckResult result) { 571 NavigationThrottle::ThrottleCheckResult result) {
568 CHECK(result != NavigationThrottle::DEFER); 572 CHECK(result != NavigationThrottle::DEFER);
569 573
570 // Abort the request if needed. This will destroy the NavigationRequest. 574 // Abort the request if needed. This will destroy the NavigationRequest.
571 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 575 if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
572 result == NavigationThrottle::CANCEL) { 576 result == NavigationThrottle::CANCEL) {
573 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 577 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
574 frame_tree_node_->ResetNavigationRequest(false); 578 frame_tree_node_->ResetNavigationRequest(false);
575 return; 579 return;
576 } 580 }
577 581
582 if (result == NavigationThrottle::BLOCK_RESPONSE) {
583 OnRequestFailed(false, net::ERR_BLOCKED_BY_RESPONSE);
584 // DO NOT ADD CODE after this. The previous call to OnRequestFailed have
clamy 2016/12/09 17:14:01 nit:s/have/has
arthursonzogni 2016/12/13 15:32:13 Done.
585 // destroyed the NavigationRequest.
586 return;
587 }
588
578 // Have the processing of the response resume in the network stack. 589 // Have the processing of the response resume in the network stack.
579 loader_->ProceedWithResponse(); 590 loader_->ProceedWithResponse();
580 591
581 CommitNavigation(); 592 CommitNavigation();
582 593
583 // DO NOT ADD CODE after this. The previous call to CommitNavigation caused 594 // DO NOT ADD CODE after this. The previous call to CommitNavigation caused
584 // the destruction of the NavigationRequest. 595 // the destruction of the NavigationRequest.
585 } 596 }
586 597
587 void NavigationRequest::CommitNavigation() { 598 void NavigationRequest::CommitNavigation() {
(...skipping 11 matching lines...) Expand all
599 TransferNavigationHandleOwnership(render_frame_host); 610 TransferNavigationHandleOwnership(render_frame_host);
600 611
601 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 612 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
602 common_params_, request_params_, 613 common_params_, request_params_,
603 is_view_source_); 614 is_view_source_);
604 615
605 frame_tree_node_->ResetNavigationRequest(true); 616 frame_tree_node_->ResetNavigationRequest(true);
606 } 617 }
607 618
608 } // namespace content 619 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698