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

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

Issue 2488743003: (Re-)introduce AncestorThrottle to handle 'X-Frame-Options'. (Closed)
Patch Set: Addressed comments (@alexmos #2) Created 3 years, 12 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 #include "content/browser/frame_host/navigation_handle_impl.h" 5 #include "content/browser/frame_host/navigation_handle_impl.h"
6 6
7 #include "base/debug/dump_without_crashing.h" 7 #include "base/debug/dump_without_crashing.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "content/browser/appcache/appcache_navigation_handle.h" 9 #include "content/browser/appcache/appcache_navigation_handle.h"
10 #include "content/browser/appcache/appcache_service_impl.h" 10 #include "content/browser/appcache/appcache_service_impl.h"
11 #include "content/browser/browsing_data/clear_site_data_throttle.h" 11 #include "content/browser/browsing_data/clear_site_data_throttle.h"
12 #include "content/browser/child_process_security_policy_impl.h" 12 #include "content/browser/child_process_security_policy_impl.h"
13 #include "content/browser/devtools/render_frame_devtools_agent_host.h" 13 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
14 #include "content/browser/frame_host/ancestor_throttle.h"
14 #include "content/browser/frame_host/debug_urls.h" 15 #include "content/browser/frame_host/debug_urls.h"
15 #include "content/browser/frame_host/frame_tree_node.h" 16 #include "content/browser/frame_host/frame_tree_node.h"
16 #include "content/browser/frame_host/navigator.h" 17 #include "content/browser/frame_host/navigator.h"
17 #include "content/browser/frame_host/navigator_delegate.h" 18 #include "content/browser/frame_host/navigator_delegate.h"
18 #include "content/browser/loader/resource_dispatcher_host_impl.h" 19 #include "content/browser/loader/resource_dispatcher_host_impl.h"
19 #include "content/browser/service_worker/service_worker_context_wrapper.h" 20 #include "content/browser/service_worker/service_worker_context_wrapper.h"
20 #include "content/browser/service_worker/service_worker_navigation_handle.h" 21 #include "content/browser/service_worker/service_worker_navigation_handle.h"
21 #include "content/common/frame_messages.h" 22 #include "content/common/frame_messages.h"
22 #include "content/common/resource_request_body_impl.h" 23 #include "content/common/resource_request_body_impl.h"
23 #include "content/common/site_isolation_policy.h" 24 #include "content/common/site_isolation_policy.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 if (result == NavigationThrottle::PROCEED && !MaybeTransferAndProceed()) 271 if (result == NavigationThrottle::PROCEED && !MaybeTransferAndProceed())
271 return; 272 return;
272 } 273 }
273 274
274 if (result != NavigationThrottle::DEFER) 275 if (result != NavigationThrottle::DEFER)
275 RunCompleteCallback(result); 276 RunCompleteCallback(result);
276 } 277 }
277 278
278 void NavigationHandleImpl::CancelDeferredNavigation( 279 void NavigationHandleImpl::CancelDeferredNavigation(
279 NavigationThrottle::ThrottleCheckResult result) { 280 NavigationThrottle::ThrottleCheckResult result) {
280 DCHECK(state_ == DEFERRING_START || state_ == DEFERRING_REDIRECT); 281 DCHECK(state_ == DEFERRING_START ||
282 state_ == DEFERRING_REDIRECT ||
283 state_ == DEFERRING_RESPONSE);
281 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || 284 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE ||
282 result == NavigationThrottle::CANCEL); 285 result == NavigationThrottle::CANCEL);
283 state_ = CANCELING; 286 state_ = CANCELING;
284 RunCompleteCallback(result); 287 RunCompleteCallback(result);
285 } 288 }
286 289
287 void NavigationHandleImpl::RegisterThrottleForTesting( 290 void NavigationHandleImpl::RegisterThrottleForTesting(
288 std::unique_ptr<NavigationThrottle> navigation_throttle) { 291 std::unique_ptr<NavigationThrottle> navigation_throttle) {
289 throttles_.push_back(std::move(navigation_throttle)); 292 throttles_.push_back(std::move(navigation_throttle));
290 } 293 }
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 case NavigationThrottle::CANCEL: 581 case NavigationThrottle::CANCEL:
579 case NavigationThrottle::CANCEL_AND_IGNORE: 582 case NavigationThrottle::CANCEL_AND_IGNORE:
580 case NavigationThrottle::BLOCK_REQUEST: 583 case NavigationThrottle::BLOCK_REQUEST:
581 state_ = CANCELING; 584 state_ = CANCELING;
582 return result; 585 return result;
583 586
584 case NavigationThrottle::DEFER: 587 case NavigationThrottle::DEFER:
585 state_ = DEFERRING_START; 588 state_ = DEFERRING_START;
586 next_index_ = i + 1; 589 next_index_ = i + 1;
587 return result; 590 return result;
591
592 case NavigationThrottle::BLOCK_RESPONSE:
593 NOTREACHED();
588 } 594 }
589 } 595 }
590 next_index_ = 0; 596 next_index_ = 0;
591 state_ = WILL_SEND_REQUEST; 597 state_ = WILL_SEND_REQUEST;
592 return NavigationThrottle::PROCEED; 598 return NavigationThrottle::PROCEED;
593 } 599 }
594 600
595 NavigationThrottle::ThrottleCheckResult 601 NavigationThrottle::ThrottleCheckResult
596 NavigationHandleImpl::CheckWillRedirectRequest() { 602 NavigationHandleImpl::CheckWillRedirectRequest() {
597 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT); 603 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT);
(...skipping 10 matching lines...) Expand all
608 case NavigationThrottle::CANCEL_AND_IGNORE: 614 case NavigationThrottle::CANCEL_AND_IGNORE:
609 state_ = CANCELING; 615 state_ = CANCELING;
610 return result; 616 return result;
611 617
612 case NavigationThrottle::DEFER: 618 case NavigationThrottle::DEFER:
613 state_ = DEFERRING_REDIRECT; 619 state_ = DEFERRING_REDIRECT;
614 next_index_ = i + 1; 620 next_index_ = i + 1;
615 return result; 621 return result;
616 622
617 case NavigationThrottle::BLOCK_REQUEST: 623 case NavigationThrottle::BLOCK_REQUEST:
624 case NavigationThrottle::BLOCK_RESPONSE:
618 NOTREACHED(); 625 NOTREACHED();
619 } 626 }
620 } 627 }
621 next_index_ = 0; 628 next_index_ = 0;
622 state_ = WILL_REDIRECT_REQUEST; 629 state_ = WILL_REDIRECT_REQUEST;
623 630
624 // Notify the delegate that a redirect was encountered and will be followed. 631 // Notify the delegate that a redirect was encountered and will be followed.
625 if (GetDelegate()) 632 if (GetDelegate())
626 GetDelegate()->DidRedirectNavigation(this); 633 GetDelegate()->DidRedirectNavigation(this);
627 634
628 return NavigationThrottle::PROCEED; 635 return NavigationThrottle::PROCEED;
629 } 636 }
630 637
631 NavigationThrottle::ThrottleCheckResult 638 NavigationThrottle::ThrottleCheckResult
632 NavigationHandleImpl::CheckWillProcessResponse() { 639 NavigationHandleImpl::CheckWillProcessResponse() {
633 DCHECK(state_ == WILL_PROCESS_RESPONSE || state_ == DEFERRING_RESPONSE); 640 DCHECK(state_ == WILL_PROCESS_RESPONSE || state_ == DEFERRING_RESPONSE);
634 DCHECK(state_ != WILL_PROCESS_RESPONSE || next_index_ == 0); 641 DCHECK(state_ != WILL_PROCESS_RESPONSE || next_index_ == 0);
635 DCHECK(state_ != DEFERRING_RESPONSE || next_index_ != 0); 642 DCHECK(state_ != DEFERRING_RESPONSE || next_index_ != 0);
636 for (size_t i = next_index_; i < throttles_.size(); ++i) { 643 for (size_t i = next_index_; i < throttles_.size(); ++i) {
637 NavigationThrottle::ThrottleCheckResult result = 644 NavigationThrottle::ThrottleCheckResult result =
638 throttles_[i]->WillProcessResponse(); 645 throttles_[i]->WillProcessResponse();
639 switch (result) { 646 switch (result) {
640 case NavigationThrottle::PROCEED: 647 case NavigationThrottle::PROCEED:
641 continue; 648 continue;
642 649
643 case NavigationThrottle::CANCEL: 650 case NavigationThrottle::CANCEL:
644 case NavigationThrottle::CANCEL_AND_IGNORE: 651 case NavigationThrottle::CANCEL_AND_IGNORE:
652 case NavigationThrottle::BLOCK_RESPONSE:
645 state_ = CANCELING; 653 state_ = CANCELING;
646 return result; 654 return result;
647 655
648 case NavigationThrottle::DEFER: 656 case NavigationThrottle::DEFER:
649 state_ = DEFERRING_RESPONSE; 657 state_ = DEFERRING_RESPONSE;
650 next_index_ = i + 1; 658 next_index_ = i + 1;
651 return result; 659 return result;
652 660
653 case NavigationThrottle::BLOCK_REQUEST: 661 case NavigationThrottle::BLOCK_REQUEST:
654 NOTREACHED(); 662 NOTREACHED();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 std::unique_ptr<NavigationThrottle> devtools_throttle = 781 std::unique_ptr<NavigationThrottle> devtools_throttle =
774 RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(this); 782 RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(this);
775 if (devtools_throttle) 783 if (devtools_throttle)
776 throttles_to_register.push_back(std::move(devtools_throttle)); 784 throttles_to_register.push_back(std::move(devtools_throttle));
777 785
778 std::unique_ptr<NavigationThrottle> clear_site_data_throttle = 786 std::unique_ptr<NavigationThrottle> clear_site_data_throttle =
779 ClearSiteDataThrottle::CreateThrottleForNavigation(this); 787 ClearSiteDataThrottle::CreateThrottleForNavigation(this);
780 if (clear_site_data_throttle) 788 if (clear_site_data_throttle)
781 throttles_to_register.push_back(std::move(clear_site_data_throttle)); 789 throttles_to_register.push_back(std::move(clear_site_data_throttle));
782 790
791 std::unique_ptr<content::NavigationThrottle> ancestor_throttle =
792 content::AncestorThrottle::MaybeCreateThrottleFor(this);
793 if (ancestor_throttle)
794 throttles_.push_back(std::move(ancestor_throttle));
795
783 if (throttles_to_register.size() > 0) { 796 if (throttles_to_register.size() > 0) {
784 throttles_.insert(throttles_.begin(), throttles_to_register.begin(), 797 throttles_.insert(throttles_.begin(), throttles_to_register.begin(),
785 throttles_to_register.end()); 798 throttles_to_register.end());
786 throttles_to_register.weak_clear(); 799 throttles_to_register.weak_clear();
787 } 800 }
788 } 801 }
789 802
790 } // namespace content 803 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698