| 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 <utility> | 7 #include <utility> |
| 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 28 matching lines...) Expand all Loading... |
| 39 *to_update = result; | 39 *to_update = result; |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 // static | 44 // static |
| 45 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( | 45 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( |
| 46 const GURL& url, | 46 const GURL& url, |
| 47 FrameTreeNode* frame_tree_node, | 47 FrameTreeNode* frame_tree_node, |
| 48 bool is_renderer_initiated, | 48 bool is_renderer_initiated, |
| 49 bool is_synchronous, | 49 bool is_same_page, |
| 50 bool is_srcdoc, | 50 bool is_srcdoc, |
| 51 const base::TimeTicks& navigation_start, | 51 const base::TimeTicks& navigation_start, |
| 52 int pending_nav_entry_id, | 52 int pending_nav_entry_id, |
| 53 bool started_from_context_menu) { | 53 bool started_from_context_menu) { |
| 54 return std::unique_ptr<NavigationHandleImpl>(new NavigationHandleImpl( | 54 return std::unique_ptr<NavigationHandleImpl>(new NavigationHandleImpl( |
| 55 url, frame_tree_node, is_renderer_initiated, is_synchronous, is_srcdoc, | 55 url, frame_tree_node, is_renderer_initiated, is_same_page, is_srcdoc, |
| 56 navigation_start, pending_nav_entry_id, started_from_context_menu)); | 56 navigation_start, pending_nav_entry_id, started_from_context_menu)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 NavigationHandleImpl::NavigationHandleImpl( | 59 NavigationHandleImpl::NavigationHandleImpl( |
| 60 const GURL& url, | 60 const GURL& url, |
| 61 FrameTreeNode* frame_tree_node, | 61 FrameTreeNode* frame_tree_node, |
| 62 bool is_renderer_initiated, | 62 bool is_renderer_initiated, |
| 63 bool is_synchronous, | 63 bool is_same_page, |
| 64 bool is_srcdoc, | 64 bool is_srcdoc, |
| 65 const base::TimeTicks& navigation_start, | 65 const base::TimeTicks& navigation_start, |
| 66 int pending_nav_entry_id, | 66 int pending_nav_entry_id, |
| 67 bool started_from_context_menu) | 67 bool started_from_context_menu) |
| 68 : url_(url), | 68 : url_(url), |
| 69 has_user_gesture_(false), | 69 has_user_gesture_(false), |
| 70 transition_(ui::PAGE_TRANSITION_LINK), | 70 transition_(ui::PAGE_TRANSITION_LINK), |
| 71 is_external_protocol_(false), | 71 is_external_protocol_(false), |
| 72 net_error_code_(net::OK), | 72 net_error_code_(net::OK), |
| 73 render_frame_host_(nullptr), | 73 render_frame_host_(nullptr), |
| 74 is_renderer_initiated_(is_renderer_initiated), | 74 is_renderer_initiated_(is_renderer_initiated), |
| 75 is_same_page_(false), | 75 is_same_page_(is_same_page), |
| 76 is_synchronous_(is_synchronous), | |
| 77 is_srcdoc_(is_srcdoc), | 76 is_srcdoc_(is_srcdoc), |
| 78 was_redirected_(false), | 77 was_redirected_(false), |
| 79 original_url_(url), | 78 original_url_(url), |
| 80 state_(INITIAL), | 79 state_(INITIAL), |
| 81 is_transferring_(false), | 80 is_transferring_(false), |
| 82 frame_tree_node_(frame_tree_node), | 81 frame_tree_node_(frame_tree_node), |
| 83 next_index_(0), | 82 next_index_(0), |
| 84 navigation_start_(navigation_start), | 83 navigation_start_(navigation_start), |
| 85 pending_nav_entry_id_(pending_nav_entry_id), | 84 pending_nav_entry_id_(pending_nav_entry_id), |
| 86 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED), | 85 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED), |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 if (frame_tree_node_->parent()) | 143 if (frame_tree_node_->parent()) |
| 145 return frame_tree_node_->parent()->IsMainFrame(); | 144 return frame_tree_node_->parent()->IsMainFrame(); |
| 146 | 145 |
| 147 return false; | 146 return false; |
| 148 } | 147 } |
| 149 | 148 |
| 150 bool NavigationHandleImpl::IsRendererInitiated() { | 149 bool NavigationHandleImpl::IsRendererInitiated() { |
| 151 return is_renderer_initiated_; | 150 return is_renderer_initiated_; |
| 152 } | 151 } |
| 153 | 152 |
| 154 bool NavigationHandleImpl::IsSynchronousNavigation() { | |
| 155 return is_synchronous_; | |
| 156 } | |
| 157 | |
| 158 bool NavigationHandleImpl::IsSrcdoc() { | 153 bool NavigationHandleImpl::IsSrcdoc() { |
| 159 return is_srcdoc_; | 154 return is_srcdoc_; |
| 160 } | 155 } |
| 161 | 156 |
| 162 bool NavigationHandleImpl::WasServerRedirect() { | 157 bool NavigationHandleImpl::WasServerRedirect() { |
| 163 return was_redirected_; | 158 return was_redirected_; |
| 164 } | 159 } |
| 165 | 160 |
| 166 int NavigationHandleImpl::GetFrameTreeNodeId() { | 161 int NavigationHandleImpl::GetFrameTreeNodeId() { |
| 167 return frame_tree_node_->frame_tree_node_id(); | 162 return frame_tree_node_->frame_tree_node_id(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 // TODO(mkwst): Change this to check against 'READY_TO_COMMIT' once | 211 // TODO(mkwst): Change this to check against 'READY_TO_COMMIT' once |
| 217 // ReadyToCommitNavigation is available whether or not PlzNavigate is | 212 // ReadyToCommitNavigation is available whether or not PlzNavigate is |
| 218 // enabled. https://crbug.com/621856 | 213 // enabled. https://crbug.com/621856 |
| 219 CHECK_GE(state_, WILL_PROCESS_RESPONSE) | 214 CHECK_GE(state_, WILL_PROCESS_RESPONSE) |
| 220 << "This accessor should only be called after a response has been " | 215 << "This accessor should only be called after a response has been " |
| 221 "delivered for processing."; | 216 "delivered for processing."; |
| 222 return render_frame_host_; | 217 return render_frame_host_; |
| 223 } | 218 } |
| 224 | 219 |
| 225 bool NavigationHandleImpl::IsSamePage() { | 220 bool NavigationHandleImpl::IsSamePage() { |
| 226 DCHECK(state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE) | |
| 227 << "This accessor should not be called before the navigation has " | |
| 228 "committed."; | |
| 229 return is_same_page_; | 221 return is_same_page_; |
| 230 } | 222 } |
| 231 | 223 |
| 232 const net::HttpResponseHeaders* NavigationHandleImpl::GetResponseHeaders() { | 224 const net::HttpResponseHeaders* NavigationHandleImpl::GetResponseHeaders() { |
| 233 return response_headers_.get(); | 225 return response_headers_.get(); |
| 234 } | 226 } |
| 235 | 227 |
| 236 bool NavigationHandleImpl::HasCommitted() { | 228 bool NavigationHandleImpl::HasCommitted() { |
| 237 return state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE; | 229 return state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE; |
| 238 } | 230 } |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 bool same_page, | 492 bool same_page, |
| 501 RenderFrameHostImpl* render_frame_host) { | 493 RenderFrameHostImpl* render_frame_host) { |
| 502 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 494 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 503 DCHECK_EQ(frame_tree_node_, render_frame_host->frame_tree_node()); | 495 DCHECK_EQ(frame_tree_node_, render_frame_host->frame_tree_node()); |
| 504 CHECK_EQ(url_, params.url); | 496 CHECK_EQ(url_, params.url); |
| 505 | 497 |
| 506 method_ = params.method; | 498 method_ = params.method; |
| 507 has_user_gesture_ = (params.gesture == NavigationGestureUser); | 499 has_user_gesture_ = (params.gesture == NavigationGestureUser); |
| 508 transition_ = params.transition; | 500 transition_ = params.transition; |
| 509 render_frame_host_ = render_frame_host; | 501 render_frame_host_ = render_frame_host; |
| 510 is_same_page_ = same_page; | |
| 511 | 502 |
| 512 // If an error page reloads, net_error_code might be 200 but we still want to | 503 // If an error page reloads, net_error_code might be 200 but we still want to |
| 513 // count it as an error page. | 504 // count it as an error page. |
| 514 if (params.base_url.spec() == kUnreachableWebDataURL || | 505 if (params.base_url.spec() == kUnreachableWebDataURL || |
| 515 net_error_code_ != net::OK) { | 506 net_error_code_ != net::OK) { |
| 516 state_ = DID_COMMIT_ERROR_PAGE; | 507 state_ = DID_COMMIT_ERROR_PAGE; |
| 517 } else { | 508 } else { |
| 518 state_ = DID_COMMIT; | 509 state_ = DID_COMMIT; |
| 519 } | 510 } |
| 520 } | 511 } |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 throttles_to_register.end()); | 743 throttles_to_register.end()); |
| 753 throttles_to_register.weak_clear(); | 744 throttles_to_register.weak_clear(); |
| 754 } | 745 } |
| 755 } | 746 } |
| 756 | 747 |
| 757 bool NavigationHandleImpl::WasStartedFromContextMenu() const { | 748 bool NavigationHandleImpl::WasStartedFromContextMenu() const { |
| 758 return started_from_context_menu_; | 749 return started_from_context_menu_; |
| 759 } | 750 } |
| 760 | 751 |
| 761 } // namespace content | 752 } // namespace content |
| OLD | NEW |