| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace | 59 } // namespace |
| 60 | 60 |
| 61 // static | 61 // static |
| 62 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( | 62 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( |
| 63 const GURL& url, | 63 const GURL& url, |
| 64 const std::vector<GURL>& redirect_chain, | 64 const std::vector<GURL>& redirect_chain, |
| 65 FrameTreeNode* frame_tree_node, | 65 FrameTreeNode* frame_tree_node, |
| 66 bool is_renderer_initiated, | 66 bool is_renderer_initiated, |
| 67 bool is_same_page, | 67 bool is_same_document, |
| 68 const base::TimeTicks& navigation_start, | 68 const base::TimeTicks& navigation_start, |
| 69 int pending_nav_entry_id, | 69 int pending_nav_entry_id, |
| 70 bool started_from_context_menu, | 70 bool started_from_context_menu, |
| 71 CSPDisposition should_check_main_world_csp, | 71 CSPDisposition should_check_main_world_csp, |
| 72 bool is_form_submission) { | 72 bool is_form_submission) { |
| 73 return std::unique_ptr<NavigationHandleImpl>(new NavigationHandleImpl( | 73 return std::unique_ptr<NavigationHandleImpl>(new NavigationHandleImpl( |
| 74 url, redirect_chain, frame_tree_node, is_renderer_initiated, is_same_page, | 74 url, redirect_chain, frame_tree_node, is_renderer_initiated, |
| 75 navigation_start, pending_nav_entry_id, started_from_context_menu, | 75 is_same_document, navigation_start, pending_nav_entry_id, |
| 76 should_check_main_world_csp, is_form_submission)); | 76 started_from_context_menu, should_check_main_world_csp, |
| 77 is_form_submission)); |
| 77 } | 78 } |
| 78 | 79 |
| 79 NavigationHandleImpl::NavigationHandleImpl( | 80 NavigationHandleImpl::NavigationHandleImpl( |
| 80 const GURL& url, | 81 const GURL& url, |
| 81 const std::vector<GURL>& redirect_chain, | 82 const std::vector<GURL>& redirect_chain, |
| 82 FrameTreeNode* frame_tree_node, | 83 FrameTreeNode* frame_tree_node, |
| 83 bool is_renderer_initiated, | 84 bool is_renderer_initiated, |
| 84 bool is_same_page, | 85 bool is_same_document, |
| 85 const base::TimeTicks& navigation_start, | 86 const base::TimeTicks& navigation_start, |
| 86 int pending_nav_entry_id, | 87 int pending_nav_entry_id, |
| 87 bool started_from_context_menu, | 88 bool started_from_context_menu, |
| 88 CSPDisposition should_check_main_world_csp, | 89 CSPDisposition should_check_main_world_csp, |
| 89 bool is_form_submission) | 90 bool is_form_submission) |
| 90 : url_(url), | 91 : url_(url), |
| 91 has_user_gesture_(false), | 92 has_user_gesture_(false), |
| 92 transition_(ui::PAGE_TRANSITION_LINK), | 93 transition_(ui::PAGE_TRANSITION_LINK), |
| 93 is_external_protocol_(false), | 94 is_external_protocol_(false), |
| 94 net_error_code_(net::OK), | 95 net_error_code_(net::OK), |
| 95 render_frame_host_(nullptr), | 96 render_frame_host_(nullptr), |
| 96 is_renderer_initiated_(is_renderer_initiated), | 97 is_renderer_initiated_(is_renderer_initiated), |
| 97 is_same_page_(is_same_page), | 98 is_same_document_(is_same_document), |
| 98 was_redirected_(false), | 99 was_redirected_(false), |
| 99 did_replace_entry_(false), | 100 did_replace_entry_(false), |
| 100 should_update_history_(false), | 101 should_update_history_(false), |
| 101 subframe_entry_committed_(false), | 102 subframe_entry_committed_(false), |
| 102 connection_info_(net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN), | 103 connection_info_(net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN), |
| 103 original_url_(url), | 104 original_url_(url), |
| 104 state_(INITIAL), | 105 state_(INITIAL), |
| 105 is_transferring_(false), | 106 is_transferring_(false), |
| 106 frame_tree_node_(frame_tree_node), | 107 frame_tree_node_(frame_tree_node), |
| 107 next_index_(0), | 108 next_index_(0), |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 160 |
| 160 if (!IsRendererDebugURL(url_)) | 161 if (!IsRendererDebugURL(url_)) |
| 161 GetDelegate()->DidStartNavigation(this); | 162 GetDelegate()->DidStartNavigation(this); |
| 162 | 163 |
| 163 if (IsInMainFrame()) { | 164 if (IsInMainFrame()) { |
| 164 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( | 165 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( |
| 165 "navigation", "Navigation StartToCommit", this, | 166 "navigation", "Navigation StartToCommit", this, |
| 166 navigation_start, "Initial URL", url_.spec()); | 167 navigation_start, "Initial URL", url_.spec()); |
| 167 } | 168 } |
| 168 | 169 |
| 169 if (is_same_page_) { | 170 if (is_same_document_) { |
| 170 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, | 171 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, |
| 171 "Same document"); | 172 "Same document"); |
| 172 } | 173 } |
| 173 } | 174 } |
| 174 | 175 |
| 175 NavigationHandleImpl::~NavigationHandleImpl() { | 176 NavigationHandleImpl::~NavigationHandleImpl() { |
| 176 // Inform the RenderProcessHost to no longer expect a navigation. | 177 // Inform the RenderProcessHost to no longer expect a navigation. |
| 177 if (expected_render_process_host_id_ != ChildProcessHost::kInvalidUniqueID) { | 178 if (expected_render_process_host_id_ != ChildProcessHost::kInvalidUniqueID) { |
| 178 RenderProcessHost* process = | 179 RenderProcessHost* process = |
| 179 RenderProcessHost::FromID(expected_render_process_host_id_); | 180 RenderProcessHost::FromID(expected_render_process_host_id_); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 // TODO(mkwst): Change this to check against 'READY_TO_COMMIT' once | 298 // TODO(mkwst): Change this to check against 'READY_TO_COMMIT' once |
| 298 // ReadyToCommitNavigation is available whether or not PlzNavigate is | 299 // ReadyToCommitNavigation is available whether or not PlzNavigate is |
| 299 // enabled. https://crbug.com/621856 | 300 // enabled. https://crbug.com/621856 |
| 300 CHECK_GE(state_, WILL_PROCESS_RESPONSE) | 301 CHECK_GE(state_, WILL_PROCESS_RESPONSE) |
| 301 << "This accessor should only be called after a response has been " | 302 << "This accessor should only be called after a response has been " |
| 302 "delivered for processing."; | 303 "delivered for processing."; |
| 303 return render_frame_host_; | 304 return render_frame_host_; |
| 304 } | 305 } |
| 305 | 306 |
| 306 bool NavigationHandleImpl::IsSameDocument() { | 307 bool NavigationHandleImpl::IsSameDocument() { |
| 307 return is_same_page_; | 308 return is_same_document_; |
| 308 } | 309 } |
| 309 | 310 |
| 310 const net::HttpResponseHeaders* NavigationHandleImpl::GetResponseHeaders() { | 311 const net::HttpResponseHeaders* NavigationHandleImpl::GetResponseHeaders() { |
| 311 return response_headers_.get(); | 312 return response_headers_.get(); |
| 312 } | 313 } |
| 313 | 314 |
| 314 net::HttpResponseInfo::ConnectionInfo | 315 net::HttpResponseInfo::ConnectionInfo |
| 315 NavigationHandleImpl::GetConnectionInfo() { | 316 NavigationHandleImpl::GetConnectionInfo() { |
| 316 return connection_info_; | 317 return connection_info_; |
| 317 } | 318 } |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, | 773 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, |
| 773 "DidCommitNavigation"); | 774 "DidCommitNavigation"); |
| 774 state_ = DID_COMMIT; | 775 state_ = DID_COMMIT; |
| 775 | 776 |
| 776 // Getting this far means that the navigation was not blocked, and neither | 777 // Getting this far means that the navigation was not blocked, and neither |
| 777 // is this the error page navigation following a blocked navigation. Ensure | 778 // is this the error page navigation following a blocked navigation. Ensure |
| 778 // the frame owner element is no longer collapsed as a result of a prior | 779 // the frame owner element is no longer collapsed as a result of a prior |
| 779 // navigation having been blocked with BLOCK_REQUEST_AND_COLLAPSE. | 780 // navigation having been blocked with BLOCK_REQUEST_AND_COLLAPSE. |
| 780 if (!frame_tree_node()->IsMainFrame()) { | 781 if (!frame_tree_node()->IsMainFrame()) { |
| 781 // The last committed load in collapsed frames will be an error page with | 782 // The last committed load in collapsed frames will be an error page with |
| 782 // |kUnreachableWebDataURL|. Same-page navigation should not be possible. | 783 // |kUnreachableWebDataURL|. Same-document navigation should not be |
| 783 DCHECK(!is_same_page_ || !frame_tree_node()->is_collapsed()); | 784 // possible. |
| 785 DCHECK(!is_same_document_ || !frame_tree_node()->is_collapsed()); |
| 784 frame_tree_node()->SetCollapsed(false); | 786 frame_tree_node()->SetCollapsed(false); |
| 785 } | 787 } |
| 786 } | 788 } |
| 787 } | 789 } |
| 788 | 790 |
| 789 void NavigationHandleImpl::SetExpectedProcess( | 791 void NavigationHandleImpl::SetExpectedProcess( |
| 790 RenderProcessHost* expected_process) { | 792 RenderProcessHost* expected_process) { |
| 791 if (expected_process && | 793 if (expected_process && |
| 792 expected_process->GetID() == expected_render_process_host_id_) { | 794 expected_process->GetID() == expected_render_process_host_id_) { |
| 793 // This |expected_process| has already been informed of the navigation, | 795 // This |expected_process| has already been informed of the navigation, |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 if (new_site_url == site_url_) | 1155 if (new_site_url == site_url_) |
| 1154 return; | 1156 return; |
| 1155 | 1157 |
| 1156 // When redirecting cross-site, stop telling the speculative | 1158 // When redirecting cross-site, stop telling the speculative |
| 1157 // RenderProcessHost to expect a navigation commit. | 1159 // RenderProcessHost to expect a navigation commit. |
| 1158 SetExpectedProcess(nullptr); | 1160 SetExpectedProcess(nullptr); |
| 1159 site_url_ = new_site_url; | 1161 site_url_ = new_site_url; |
| 1160 } | 1162 } |
| 1161 | 1163 |
| 1162 } // namespace content | 1164 } // namespace content |
| OLD | NEW |