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

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

Issue 2655463006: PlzNavigate: Enforce 'frame-src' CSP on the browser. (Closed)
Patch Set: Addressed comments Created 3 years, 9 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 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 "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "content/browser/appcache/appcache_navigation_handle.h" 10 #include "content/browser/appcache/appcache_navigation_handle.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 void NavigationRequest::CreateNavigationHandle(int pending_nav_entry_id) { 387 void NavigationRequest::CreateNavigationHandle(int pending_nav_entry_id) {
388 DCHECK_EQ(frame_tree_node_->navigation_request(), this); 388 DCHECK_EQ(frame_tree_node_->navigation_request(), this);
389 FrameTreeNode* frame_tree_node = frame_tree_node_; 389 FrameTreeNode* frame_tree_node = frame_tree_node_;
390 390
391 std::vector<GURL> redirect_chain; 391 std::vector<GURL> redirect_chain;
392 if (!begin_params_.client_side_redirect_url.is_empty()) 392 if (!begin_params_.client_side_redirect_url.is_empty())
393 redirect_chain.push_back(begin_params_.client_side_redirect_url); 393 redirect_chain.push_back(begin_params_.client_side_redirect_url);
394 redirect_chain.push_back(common_params_.url); 394 redirect_chain.push_back(common_params_.url);
395 395
396 std::unique_ptr<NavigationHandleImpl> navigation_handle = 396 std::unique_ptr<NavigationHandleImpl> navigation_handle =
397 NavigationHandleImpl::Create( 397 NavigationHandleImpl::Create(common_params_.url, redirect_chain,
398 common_params_.url, redirect_chain, frame_tree_node_, 398 frame_tree_node_, !browser_initiated_,
399 !browser_initiated_, FrameMsg_Navigate_Type::IsSameDocument( 399 FrameMsg_Navigate_Type::IsSameDocument(
400 common_params_.navigation_type), 400 common_params_.navigation_type),
401 common_params_.navigation_start, pending_nav_entry_id, 401 common_params_.navigation_start,
402 false); // started_in_context_menu 402 pending_nav_entry_id,
403 false, // started_in_context_menu
404 common_params_.should_bypass_main_world_csp);
403 405
404 if (!frame_tree_node->navigation_request()) { 406 if (!frame_tree_node->navigation_request()) {
405 // A callback could have cancelled this request synchronously in which case 407 // A callback could have cancelled this request synchronously in which case
406 // |this| is deleted. 408 // |this| is deleted.
407 return; 409 return;
408 } 410 }
409 411
410 navigation_handle_ = std::move(navigation_handle); 412 navigation_handle_ = std::move(navigation_handle);
411 413
412 if (!begin_params_.searchable_form_url.is_empty()) { 414 if (!begin_params_.searchable_form_url.is_empty()) {
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 715 if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
714 result == NavigationThrottle::CANCEL) { 716 result == NavigationThrottle::CANCEL) {
715 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 717 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
716 OnRequestFailed(false, net::ERR_ABORTED); 718 OnRequestFailed(false, net::ERR_ABORTED);
717 719
718 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has 720 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has
719 // destroyed the NavigationRequest. 721 // destroyed the NavigationRequest.
720 return; 722 return;
721 } 723 }
722 724
725 if (result == NavigationThrottle::BLOCK_REQUEST) {
726 OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT);
727 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has
728 // destroyed the NavigationRequest.
729 return;
730 }
731
723 loader_->FollowRedirect(); 732 loader_->FollowRedirect();
724 } 733 }
725 734
726 void NavigationRequest::OnWillProcessResponseChecksComplete( 735 void NavigationRequest::OnWillProcessResponseChecksComplete(
727 NavigationThrottle::ThrottleCheckResult result) { 736 NavigationThrottle::ThrottleCheckResult result) {
728 DCHECK(result != NavigationThrottle::DEFER); 737 DCHECK(result != NavigationThrottle::DEFER);
729 738
730 // Abort the request if needed. This includes requests that were blocked by 739 // Abort the request if needed. This includes requests that were blocked by
731 // NavigationThrottles and requests that should not commit (e.g. downloads, 740 // NavigationThrottles and requests that should not commit (e.g. downloads,
732 // 204/205s). This will destroy the NavigationRequest. 741 // 204/205s). This will destroy the NavigationRequest.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); 783 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture);
775 784
776 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 785 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
777 common_params_, request_params_, 786 common_params_, request_params_,
778 is_view_source_); 787 is_view_source_);
779 788
780 frame_tree_node_->ResetNavigationRequest(true); 789 frame_tree_node_->ResetNavigationRequest(true);
781 } 790 }
782 791
783 } // namespace content 792 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698