| OLD | NEW |
| 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 <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/debug/dump_without_crashing.h" | 9 #include "base/debug/dump_without_crashing.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 // static | 59 // static |
| 60 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( | 60 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( |
| 61 const GURL& url, | 61 const GURL& url, |
| 62 const std::vector<GURL>& redirect_chain, | 62 const std::vector<GURL>& redirect_chain, |
| 63 FrameTreeNode* frame_tree_node, | 63 FrameTreeNode* frame_tree_node, |
| 64 bool is_renderer_initiated, | 64 bool is_renderer_initiated, |
| 65 bool is_same_page, | 65 bool is_same_page, |
| 66 const base::TimeTicks& navigation_start, | 66 const base::TimeTicks& navigation_start, |
| 67 int pending_nav_entry_id, | 67 int pending_nav_entry_id, |
| 68 bool started_from_context_menu) { | 68 bool started_from_context_menu, |
| 69 bool should_bypass_main_world_csp) { |
| 69 return std::unique_ptr<NavigationHandleImpl>(new NavigationHandleImpl( | 70 return std::unique_ptr<NavigationHandleImpl>(new NavigationHandleImpl( |
| 70 url, redirect_chain, frame_tree_node, is_renderer_initiated, is_same_page, | 71 url, redirect_chain, frame_tree_node, is_renderer_initiated, is_same_page, |
| 71 navigation_start, pending_nav_entry_id, | 72 navigation_start, pending_nav_entry_id, started_from_context_menu, |
| 72 started_from_context_menu)); | 73 should_bypass_main_world_csp)); |
| 73 } | 74 } |
| 74 | 75 |
| 75 NavigationHandleImpl::NavigationHandleImpl( | 76 NavigationHandleImpl::NavigationHandleImpl( |
| 76 const GURL& url, | 77 const GURL& url, |
| 77 const std::vector<GURL>& redirect_chain, | 78 const std::vector<GURL>& redirect_chain, |
| 78 FrameTreeNode* frame_tree_node, | 79 FrameTreeNode* frame_tree_node, |
| 79 bool is_renderer_initiated, | 80 bool is_renderer_initiated, |
| 80 bool is_same_page, | 81 bool is_same_page, |
| 81 const base::TimeTicks& navigation_start, | 82 const base::TimeTicks& navigation_start, |
| 82 int pending_nav_entry_id, | 83 int pending_nav_entry_id, |
| 83 bool started_from_context_menu) | 84 bool started_from_context_menu, |
| 85 bool should_bypass_main_world_csp) |
| 84 : url_(url), | 86 : url_(url), |
| 85 has_user_gesture_(false), | 87 has_user_gesture_(false), |
| 86 transition_(ui::PAGE_TRANSITION_LINK), | 88 transition_(ui::PAGE_TRANSITION_LINK), |
| 87 is_external_protocol_(false), | 89 is_external_protocol_(false), |
| 88 net_error_code_(net::OK), | 90 net_error_code_(net::OK), |
| 89 render_frame_host_(nullptr), | 91 render_frame_host_(nullptr), |
| 90 is_renderer_initiated_(is_renderer_initiated), | 92 is_renderer_initiated_(is_renderer_initiated), |
| 91 is_same_page_(is_same_page), | 93 is_same_page_(is_same_page), |
| 92 was_redirected_(false), | 94 was_redirected_(false), |
| 93 did_replace_entry_(false), | 95 did_replace_entry_(false), |
| 94 should_update_history_(false), | 96 should_update_history_(false), |
| 95 connection_info_(net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN), | 97 connection_info_(net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN), |
| 96 original_url_(url), | 98 original_url_(url), |
| 97 state_(INITIAL), | 99 state_(INITIAL), |
| 98 is_transferring_(false), | 100 is_transferring_(false), |
| 99 frame_tree_node_(frame_tree_node), | 101 frame_tree_node_(frame_tree_node), |
| 100 next_index_(0), | 102 next_index_(0), |
| 101 navigation_start_(navigation_start), | 103 navigation_start_(navigation_start), |
| 102 pending_nav_entry_id_(pending_nav_entry_id), | 104 pending_nav_entry_id_(pending_nav_entry_id), |
| 103 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED), | 105 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED), |
| 104 mixed_content_context_type_(blink::WebMixedContentContextType::Blockable), | 106 mixed_content_context_type_(blink::WebMixedContentContextType::Blockable), |
| 105 should_replace_current_entry_(false), | 107 should_replace_current_entry_(false), |
| 106 redirect_chain_(redirect_chain), | 108 redirect_chain_(redirect_chain), |
| 107 is_download_(false), | 109 is_download_(false), |
| 108 is_stream_(false), | 110 is_stream_(false), |
| 109 started_from_context_menu_(started_from_context_menu), | 111 started_from_context_menu_(started_from_context_menu), |
| 110 reload_type_(ReloadType::NONE), | 112 reload_type_(ReloadType::NONE), |
| 111 navigation_type_(NAVIGATION_TYPE_UNKNOWN), | 113 navigation_type_(NAVIGATION_TYPE_UNKNOWN), |
| 114 should_bypass_main_world_csp_(should_bypass_main_world_csp), |
| 112 weak_factory_(this) { | 115 weak_factory_(this) { |
| 113 DCHECK(!navigation_start.is_null()); | 116 DCHECK(!navigation_start.is_null()); |
| 114 if (redirect_chain_.empty()) | 117 if (redirect_chain_.empty()) |
| 115 redirect_chain_.push_back(url); | 118 redirect_chain_.push_back(url); |
| 116 | 119 |
| 117 starting_site_instance_ = | 120 starting_site_instance_ = |
| 118 frame_tree_node_->current_frame_host()->GetSiteInstance(); | 121 frame_tree_node_->current_frame_host()->GetSiteInstance(); |
| 119 | 122 |
| 120 if (pending_nav_entry_id_) { | 123 if (pending_nav_entry_id_) { |
| 121 NavigationControllerImpl* nav_controller = | 124 NavigationControllerImpl* nav_controller = |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 } | 452 } |
| 450 | 453 |
| 451 ReloadType NavigationHandleImpl::GetReloadType() { | 454 ReloadType NavigationHandleImpl::GetReloadType() { |
| 452 return reload_type_; | 455 return reload_type_; |
| 453 } | 456 } |
| 454 | 457 |
| 455 NavigationData* NavigationHandleImpl::GetNavigationData() { | 458 NavigationData* NavigationHandleImpl::GetNavigationData() { |
| 456 return navigation_data_.get(); | 459 return navigation_data_.get(); |
| 457 } | 460 } |
| 458 | 461 |
| 462 bool NavigationHandleImpl::should_bypass_main_world_csp() const { |
| 463 return should_bypass_main_world_csp_; |
| 464 } |
| 465 |
| 459 const GlobalRequestID& NavigationHandleImpl::GetGlobalRequestID() { | 466 const GlobalRequestID& NavigationHandleImpl::GetGlobalRequestID() { |
| 460 DCHECK(state_ == WILL_PROCESS_RESPONSE || state_ == DEFERRING_RESPONSE || | 467 DCHECK(state_ == WILL_PROCESS_RESPONSE || state_ == DEFERRING_RESPONSE || |
| 461 state_ == READY_TO_COMMIT); | 468 state_ == READY_TO_COMMIT); |
| 462 return request_id_; | 469 return request_id_; |
| 463 } | 470 } |
| 464 | 471 |
| 465 void NavigationHandleImpl::InitServiceWorkerHandle( | 472 void NavigationHandleImpl::InitServiceWorkerHandle( |
| 466 ServiceWorkerContextWrapper* service_worker_context) { | 473 ServiceWorkerContextWrapper* service_worker_context) { |
| 467 DCHECK(IsBrowserSideNavigationEnabled()); | 474 DCHECK(IsBrowserSideNavigationEnabled()); |
| 468 service_worker_handle_.reset( | 475 service_worker_handle_.reset( |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); | 675 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); |
| 669 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); | 676 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); |
| 670 DCHECK(state_ != DEFERRING_START || next_index_ != 0); | 677 DCHECK(state_ != DEFERRING_START || next_index_ != 0); |
| 671 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 678 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
| 672 NavigationThrottle::ThrottleCheckResult result = | 679 NavigationThrottle::ThrottleCheckResult result = |
| 673 throttles_[i]->WillStartRequest(); | 680 throttles_[i]->WillStartRequest(); |
| 674 switch (result) { | 681 switch (result) { |
| 675 case NavigationThrottle::PROCEED: | 682 case NavigationThrottle::PROCEED: |
| 676 continue; | 683 continue; |
| 677 | 684 |
| 685 case NavigationThrottle::BLOCK_REQUEST: |
| 678 case NavigationThrottle::CANCEL: | 686 case NavigationThrottle::CANCEL: |
| 679 case NavigationThrottle::CANCEL_AND_IGNORE: | 687 case NavigationThrottle::CANCEL_AND_IGNORE: |
| 680 case NavigationThrottle::BLOCK_REQUEST: | |
| 681 state_ = CANCELING; | 688 state_ = CANCELING; |
| 682 return result; | 689 return result; |
| 683 | 690 |
| 684 case NavigationThrottle::DEFER: | 691 case NavigationThrottle::DEFER: |
| 685 state_ = DEFERRING_START; | 692 state_ = DEFERRING_START; |
| 686 next_index_ = i + 1; | 693 next_index_ = i + 1; |
| 687 return result; | 694 return result; |
| 688 | 695 |
| 689 case NavigationThrottle::BLOCK_RESPONSE: | 696 case NavigationThrottle::BLOCK_RESPONSE: |
| 690 NOTREACHED(); | 697 NOTREACHED(); |
| 691 } | 698 } |
| 692 } | 699 } |
| 693 next_index_ = 0; | 700 next_index_ = 0; |
| 694 state_ = WILL_SEND_REQUEST; | 701 state_ = WILL_SEND_REQUEST; |
| 695 return NavigationThrottle::PROCEED; | 702 return NavigationThrottle::PROCEED; |
| 696 } | 703 } |
| 697 | 704 |
| 698 NavigationThrottle::ThrottleCheckResult | 705 NavigationThrottle::ThrottleCheckResult |
| 699 NavigationHandleImpl::CheckWillRedirectRequest() { | 706 NavigationHandleImpl::CheckWillRedirectRequest() { |
| 700 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT); | 707 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT); |
| 701 DCHECK(state_ != WILL_REDIRECT_REQUEST || next_index_ == 0); | 708 DCHECK(state_ != WILL_REDIRECT_REQUEST || next_index_ == 0); |
| 702 DCHECK(state_ != DEFERRING_REDIRECT || next_index_ != 0); | 709 DCHECK(state_ != DEFERRING_REDIRECT || next_index_ != 0); |
| 703 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 710 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
| 704 NavigationThrottle::ThrottleCheckResult result = | 711 NavigationThrottle::ThrottleCheckResult result = |
| 705 throttles_[i]->WillRedirectRequest(); | 712 throttles_[i]->WillRedirectRequest(); |
| 706 switch (result) { | 713 switch (result) { |
| 707 case NavigationThrottle::PROCEED: | 714 case NavigationThrottle::PROCEED: |
| 708 continue; | 715 continue; |
| 709 | 716 |
| 717 case NavigationThrottle::BLOCK_REQUEST: |
| 710 case NavigationThrottle::CANCEL: | 718 case NavigationThrottle::CANCEL: |
| 711 case NavigationThrottle::CANCEL_AND_IGNORE: | 719 case NavigationThrottle::CANCEL_AND_IGNORE: |
| 712 state_ = CANCELING; | 720 state_ = CANCELING; |
| 713 return result; | 721 return result; |
| 714 | 722 |
| 715 case NavigationThrottle::DEFER: | 723 case NavigationThrottle::DEFER: |
| 716 state_ = DEFERRING_REDIRECT; | 724 state_ = DEFERRING_REDIRECT; |
| 717 next_index_ = i + 1; | 725 next_index_ = i + 1; |
| 718 return result; | 726 return result; |
| 719 | 727 |
| 720 case NavigationThrottle::BLOCK_REQUEST: | |
| 721 case NavigationThrottle::BLOCK_RESPONSE: | 728 case NavigationThrottle::BLOCK_RESPONSE: |
| 722 NOTREACHED(); | 729 NOTREACHED(); |
| 723 } | 730 } |
| 724 } | 731 } |
| 725 next_index_ = 0; | 732 next_index_ = 0; |
| 726 state_ = WILL_REDIRECT_REQUEST; | 733 state_ = WILL_REDIRECT_REQUEST; |
| 727 | 734 |
| 728 // Notify the delegate that a redirect was encountered and will be followed. | 735 // Notify the delegate that a redirect was encountered and will be followed. |
| 729 if (GetDelegate()) | 736 if (GetDelegate()) |
| 730 GetDelegate()->DidRedirectNavigation(this); | 737 GetDelegate()->DidRedirectNavigation(this); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 if (node->current_url().EqualsIgnoringRef(url_)) { | 936 if (node->current_url().EqualsIgnoringRef(url_)) { |
| 930 if (found_self_reference) | 937 if (found_self_reference) |
| 931 return true; | 938 return true; |
| 932 found_self_reference = true; | 939 found_self_reference = true; |
| 933 } | 940 } |
| 934 } | 941 } |
| 935 return false; | 942 return false; |
| 936 } | 943 } |
| 937 | 944 |
| 938 } // namespace content | 945 } // namespace content |
| OLD | NEW |