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" |
11 #include "content/browser/appcache/appcache_navigation_handle.h" | 11 #include "content/browser/appcache/appcache_navigation_handle.h" |
12 #include "content/browser/appcache/appcache_service_impl.h" | 12 #include "content/browser/appcache/appcache_service_impl.h" |
13 #include "content/browser/browsing_data/clear_site_data_throttle.h" | 13 #include "content/browser/browsing_data/clear_site_data_throttle.h" |
14 #include "content/browser/child_process_security_policy_impl.h" | 14 #include "content/browser/child_process_security_policy_impl.h" |
15 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 15 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
16 #include "content/browser/frame_host/ancestor_throttle.h" | 16 #include "content/browser/frame_host/ancestor_throttle.h" |
17 #include "content/browser/frame_host/debug_urls.h" | 17 #include "content/browser/frame_host/debug_urls.h" |
| 18 #include "content/browser/frame_host/form_submission_throttle.h" |
18 #include "content/browser/frame_host/frame_tree_node.h" | 19 #include "content/browser/frame_host/frame_tree_node.h" |
19 #include "content/browser/frame_host/mixed_content_navigation_throttle.h" | 20 #include "content/browser/frame_host/mixed_content_navigation_throttle.h" |
20 #include "content/browser/frame_host/navigation_controller_impl.h" | 21 #include "content/browser/frame_host/navigation_controller_impl.h" |
21 #include "content/browser/frame_host/navigation_entry_impl.h" | 22 #include "content/browser/frame_host/navigation_entry_impl.h" |
22 #include "content/browser/frame_host/navigator.h" | 23 #include "content/browser/frame_host/navigator.h" |
23 #include "content/browser/frame_host/navigator_delegate.h" | 24 #include "content/browser/frame_host/navigator_delegate.h" |
24 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 25 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
25 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 26 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
26 #include "content/browser/service_worker/service_worker_navigation_handle.h" | 27 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
27 #include "content/common/frame_messages.h" | 28 #include "content/common/frame_messages.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // static | 60 // static |
60 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( | 61 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( |
61 const GURL& url, | 62 const GURL& url, |
62 const std::vector<GURL>& redirect_chain, | 63 const std::vector<GURL>& redirect_chain, |
63 FrameTreeNode* frame_tree_node, | 64 FrameTreeNode* frame_tree_node, |
64 bool is_renderer_initiated, | 65 bool is_renderer_initiated, |
65 bool is_same_page, | 66 bool is_same_page, |
66 const base::TimeTicks& navigation_start, | 67 const base::TimeTicks& navigation_start, |
67 int pending_nav_entry_id, | 68 int pending_nav_entry_id, |
68 bool started_from_context_menu, | 69 bool started_from_context_menu, |
69 bool should_bypass_main_world_csp) { | 70 bool should_bypass_main_world_csp, |
| 71 bool is_form_submission) { |
70 return std::unique_ptr<NavigationHandleImpl>(new NavigationHandleImpl( | 72 return std::unique_ptr<NavigationHandleImpl>(new NavigationHandleImpl( |
71 url, redirect_chain, frame_tree_node, is_renderer_initiated, is_same_page, | 73 url, redirect_chain, frame_tree_node, is_renderer_initiated, is_same_page, |
72 navigation_start, pending_nav_entry_id, started_from_context_menu, | 74 navigation_start, pending_nav_entry_id, started_from_context_menu, |
73 should_bypass_main_world_csp)); | 75 should_bypass_main_world_csp, is_form_submission)); |
74 } | 76 } |
75 | 77 |
76 NavigationHandleImpl::NavigationHandleImpl( | 78 NavigationHandleImpl::NavigationHandleImpl( |
77 const GURL& url, | 79 const GURL& url, |
78 const std::vector<GURL>& redirect_chain, | 80 const std::vector<GURL>& redirect_chain, |
79 FrameTreeNode* frame_tree_node, | 81 FrameTreeNode* frame_tree_node, |
80 bool is_renderer_initiated, | 82 bool is_renderer_initiated, |
81 bool is_same_page, | 83 bool is_same_page, |
82 const base::TimeTicks& navigation_start, | 84 const base::TimeTicks& navigation_start, |
83 int pending_nav_entry_id, | 85 int pending_nav_entry_id, |
84 bool started_from_context_menu, | 86 bool started_from_context_menu, |
85 bool should_bypass_main_world_csp) | 87 bool should_bypass_main_world_csp, |
| 88 bool is_form_submission) |
86 : url_(url), | 89 : url_(url), |
87 has_user_gesture_(false), | 90 has_user_gesture_(false), |
88 transition_(ui::PAGE_TRANSITION_LINK), | 91 transition_(ui::PAGE_TRANSITION_LINK), |
89 is_external_protocol_(false), | 92 is_external_protocol_(false), |
90 net_error_code_(net::OK), | 93 net_error_code_(net::OK), |
91 render_frame_host_(nullptr), | 94 render_frame_host_(nullptr), |
92 is_renderer_initiated_(is_renderer_initiated), | 95 is_renderer_initiated_(is_renderer_initiated), |
93 is_same_page_(is_same_page), | 96 is_same_page_(is_same_page), |
94 was_redirected_(false), | 97 was_redirected_(false), |
95 did_replace_entry_(false), | 98 did_replace_entry_(false), |
(...skipping 10 matching lines...) Expand all Loading... |
106 mixed_content_context_type_(blink::WebMixedContentContextType::Blockable), | 109 mixed_content_context_type_(blink::WebMixedContentContextType::Blockable), |
107 should_replace_current_entry_(false), | 110 should_replace_current_entry_(false), |
108 redirect_chain_(redirect_chain), | 111 redirect_chain_(redirect_chain), |
109 is_download_(false), | 112 is_download_(false), |
110 is_stream_(false), | 113 is_stream_(false), |
111 started_from_context_menu_(started_from_context_menu), | 114 started_from_context_menu_(started_from_context_menu), |
112 reload_type_(ReloadType::NONE), | 115 reload_type_(ReloadType::NONE), |
113 restore_type_(RestoreType::NONE), | 116 restore_type_(RestoreType::NONE), |
114 navigation_type_(NAVIGATION_TYPE_UNKNOWN), | 117 navigation_type_(NAVIGATION_TYPE_UNKNOWN), |
115 should_bypass_main_world_csp_(should_bypass_main_world_csp), | 118 should_bypass_main_world_csp_(should_bypass_main_world_csp), |
| 119 is_form_submission_(is_form_submission), |
116 weak_factory_(this) { | 120 weak_factory_(this) { |
117 DCHECK(!navigation_start.is_null()); | 121 DCHECK(!navigation_start.is_null()); |
118 if (redirect_chain_.empty()) | 122 if (redirect_chain_.empty()) |
119 redirect_chain_.push_back(url); | 123 redirect_chain_.push_back(url); |
120 | 124 |
121 starting_site_instance_ = | 125 starting_site_instance_ = |
122 frame_tree_node_->current_frame_host()->GetSiteInstance(); | 126 frame_tree_node_->current_frame_host()->GetSiteInstance(); |
123 | 127 |
124 if (pending_nav_entry_id_) { | 128 if (pending_nav_entry_id_) { |
125 NavigationControllerImpl* nav_controller = | 129 NavigationControllerImpl* nav_controller = |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 463 } |
460 | 464 |
461 RestoreType NavigationHandleImpl::GetRestoreType() { | 465 RestoreType NavigationHandleImpl::GetRestoreType() { |
462 return restore_type_; | 466 return restore_type_; |
463 } | 467 } |
464 | 468 |
465 NavigationData* NavigationHandleImpl::GetNavigationData() { | 469 NavigationData* NavigationHandleImpl::GetNavigationData() { |
466 return navigation_data_.get(); | 470 return navigation_data_.get(); |
467 } | 471 } |
468 | 472 |
| 473 bool NavigationHandleImpl::is_form_submission() const { |
| 474 DCHECK(IsBrowserSideNavigationEnabled()) |
| 475 << "This method is implemented only with PlzNavigate"; |
| 476 return is_form_submission_; |
| 477 } |
| 478 |
469 const GlobalRequestID& NavigationHandleImpl::GetGlobalRequestID() { | 479 const GlobalRequestID& NavigationHandleImpl::GetGlobalRequestID() { |
470 DCHECK(state_ == WILL_PROCESS_RESPONSE || state_ == DEFERRING_RESPONSE || | 480 DCHECK(state_ == WILL_PROCESS_RESPONSE || state_ == DEFERRING_RESPONSE || |
471 state_ == READY_TO_COMMIT); | 481 state_ == READY_TO_COMMIT); |
472 return request_id_; | 482 return request_id_; |
473 } | 483 } |
474 | 484 |
475 void NavigationHandleImpl::InitServiceWorkerHandle( | 485 void NavigationHandleImpl::InitServiceWorkerHandle( |
476 ServiceWorkerContextWrapper* service_worker_context) { | 486 ServiceWorkerContextWrapper* service_worker_context) { |
477 DCHECK(IsBrowserSideNavigationEnabled()); | 487 DCHECK(IsBrowserSideNavigationEnabled()); |
478 service_worker_handle_.reset( | 488 service_worker_handle_.reset( |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 std::unique_ptr<NavigationThrottle> clear_site_data_throttle = | 918 std::unique_ptr<NavigationThrottle> clear_site_data_throttle = |
909 ClearSiteDataThrottle::CreateThrottleForNavigation(this); | 919 ClearSiteDataThrottle::CreateThrottleForNavigation(this); |
910 if (clear_site_data_throttle) | 920 if (clear_site_data_throttle) |
911 throttles_to_register.push_back(std::move(clear_site_data_throttle)); | 921 throttles_to_register.push_back(std::move(clear_site_data_throttle)); |
912 | 922 |
913 std::unique_ptr<content::NavigationThrottle> ancestor_throttle = | 923 std::unique_ptr<content::NavigationThrottle> ancestor_throttle = |
914 content::AncestorThrottle::MaybeCreateThrottleFor(this); | 924 content::AncestorThrottle::MaybeCreateThrottleFor(this); |
915 if (ancestor_throttle) | 925 if (ancestor_throttle) |
916 throttles_.push_back(std::move(ancestor_throttle)); | 926 throttles_.push_back(std::move(ancestor_throttle)); |
917 | 927 |
| 928 std::unique_ptr<content::NavigationThrottle> form_submission_throttle = |
| 929 content::FormSubmissionThrottle::MaybeCreateThrottleFor(this); |
| 930 if (form_submission_throttle) |
| 931 throttles_.push_back(std::move(form_submission_throttle)); |
| 932 |
918 throttles_.insert(throttles_.begin(), | 933 throttles_.insert(throttles_.begin(), |
919 std::make_move_iterator(throttles_to_register.begin()), | 934 std::make_move_iterator(throttles_to_register.begin()), |
920 std::make_move_iterator(throttles_to_register.end())); | 935 std::make_move_iterator(throttles_to_register.end())); |
921 } | 936 } |
922 | 937 |
923 bool NavigationHandleImpl::IsSelfReferentialURL() { | 938 bool NavigationHandleImpl::IsSelfReferentialURL() { |
924 // about: URLs should be exempted since they are reserved for other purposes | 939 // about: URLs should be exempted since they are reserved for other purposes |
925 // and cannot be the source of infinite recursion. See | 940 // and cannot be the source of infinite recursion. See |
926 // https://crbug.com/341858 . | 941 // https://crbug.com/341858 . |
927 if (url_.SchemeIs("about")) | 942 if (url_.SchemeIs("about")) |
(...skipping 11 matching lines...) Expand all Loading... |
939 if (node->current_url().EqualsIgnoringRef(url_)) { | 954 if (node->current_url().EqualsIgnoringRef(url_)) { |
940 if (found_self_reference) | 955 if (found_self_reference) |
941 return true; | 956 return true; |
942 found_self_reference = true; | 957 found_self_reference = true; |
943 } | 958 } |
944 } | 959 } |
945 return false; | 960 return false; |
946 } | 961 } |
947 | 962 |
948 } // namespace content | 963 } // namespace content |
OLD | NEW |