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

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

Issue 2488743003: (Re-)introduce AncestorThrottle to handle 'X-Frame-Options'. (Closed)
Patch Set: Rebase 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);
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) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 parent_is_main_frame, IsSecureFrame(frame_tree_node_->parent()), 545 parent_is_main_frame, IsSecureFrame(frame_tree_node_->parent()),
545 frame_tree_node_->frame_tree_node_id(), is_for_guests_only, 546 frame_tree_node_->frame_tree_node_id(), is_for_guests_only,
546 report_raw_headers), 547 report_raw_headers),
547 std::move(navigation_ui_data), 548 std::move(navigation_ui_data),
548 navigation_handle_->service_worker_handle(), this); 549 navigation_handle_->service_worker_handle(), this);
549 } 550 }
550 551
551 void NavigationRequest::OnRedirectChecksComplete( 552 void NavigationRequest::OnRedirectChecksComplete(
552 NavigationThrottle::ThrottleCheckResult result) { 553 NavigationThrottle::ThrottleCheckResult result) {
553 CHECK(result != NavigationThrottle::DEFER); 554 CHECK(result != NavigationThrottle::DEFER);
555 CHECK(result != NavigationThrottle::BLOCK_RESPONSE);
554 556
555 // Abort the request if needed. This will destroy the NavigationRequest. 557 // Abort the request if needed. This will destroy the NavigationRequest.
556 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 558 if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
557 result == NavigationThrottle::CANCEL) { 559 result == NavigationThrottle::CANCEL) {
558 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 560 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
559 frame_tree_node_->ResetNavigationRequest(false); 561 frame_tree_node_->ResetNavigationRequest(false);
560 return; 562 return;
561 } 563 }
562 564
563 loader_->FollowRedirect(); 565 loader_->FollowRedirect();
564 } 566 }
565 567
566 void NavigationRequest::OnWillProcessResponseChecksComplete( 568 void NavigationRequest::OnWillProcessResponseChecksComplete(
567 NavigationThrottle::ThrottleCheckResult result) { 569 NavigationThrottle::ThrottleCheckResult result) {
568 CHECK(result != NavigationThrottle::DEFER); 570 CHECK(result != NavigationThrottle::DEFER);
569 571
570 // Abort the request if needed. This will destroy the NavigationRequest. 572 // Abort the request if needed. This will destroy the NavigationRequest.
571 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 573 if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
572 result == NavigationThrottle::CANCEL) { 574 result == NavigationThrottle::CANCEL) {
573 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 575 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
574 frame_tree_node_->ResetNavigationRequest(false); 576 frame_tree_node_->ResetNavigationRequest(false);
575 return; 577 return;
576 } 578 }
577 579
580 if (result == NavigationThrottle::BLOCK_RESPONSE) {
581 OnRequestFailed(false, net::ERR_BLOCKED_BY_RESPONSE);
clamy 2016/12/06 17:09:44 Please add some comment mentionning not to add cod
arthursonzogni 2016/12/07 16:25:02 Done.
582 return;
583 }
584
578 // Have the processing of the response resume in the network stack. 585 // Have the processing of the response resume in the network stack.
579 loader_->ProceedWithResponse(); 586 loader_->ProceedWithResponse();
580 587
581 CommitNavigation(); 588 CommitNavigation();
582 589
583 // DO NOT ADD CODE after this. The previous call to CommitNavigation caused 590 // DO NOT ADD CODE after this. The previous call to CommitNavigation caused
584 // the destruction of the NavigationRequest. 591 // the destruction of the NavigationRequest.
585 } 592 }
586 593
587 void NavigationRequest::CommitNavigation() { 594 void NavigationRequest::CommitNavigation() {
(...skipping 11 matching lines...) Expand all
599 TransferNavigationHandleOwnership(render_frame_host); 606 TransferNavigationHandleOwnership(render_frame_host);
600 607
601 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 608 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
602 common_params_, request_params_, 609 common_params_, request_params_,
603 is_view_source_); 610 is_view_source_);
604 611
605 frame_tree_node_->ResetNavigationRequest(true); 612 frame_tree_node_->ResetNavigationRequest(true);
606 } 613 }
607 614
608 } // namespace content 615 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698