Chromium Code Reviews| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/browser/browsing_data/clear_site_data_throttle.h" | 10 #include "content/browser/browsing_data/clear_site_data_throttle.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 *to_update = result; | 32 *to_update = result; |
| 33 } | 33 } |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 // static | 37 // static |
| 38 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( | 38 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( |
| 39 const GURL& url, | 39 const GURL& url, |
| 40 FrameTreeNode* frame_tree_node, | 40 FrameTreeNode* frame_tree_node, |
| 41 bool is_renderer_initiated, | 41 bool is_renderer_initiated, |
| 42 bool is_synchronous, | 42 bool is_same_page, |
| 43 bool is_srcdoc, | 43 bool is_srcdoc, |
| 44 const base::TimeTicks& navigation_start, | 44 const base::TimeTicks& navigation_start, |
| 45 int pending_nav_entry_id) { | 45 int pending_nav_entry_id) { |
| 46 return std::unique_ptr<NavigationHandleImpl>( | 46 return std::unique_ptr<NavigationHandleImpl>(new NavigationHandleImpl( |
| 47 new NavigationHandleImpl(url, frame_tree_node, is_renderer_initiated, | 47 url, frame_tree_node, is_renderer_initiated, is_same_page, is_srcdoc, |
| 48 is_synchronous, is_srcdoc, navigation_start, | 48 navigation_start, pending_nav_entry_id)); |
| 49 pending_nav_entry_id)); | |
| 50 } | 49 } |
| 51 | 50 |
| 52 NavigationHandleImpl::NavigationHandleImpl( | 51 NavigationHandleImpl::NavigationHandleImpl( |
| 53 const GURL& url, | 52 const GURL& url, |
| 54 FrameTreeNode* frame_tree_node, | 53 FrameTreeNode* frame_tree_node, |
| 55 bool is_renderer_initiated, | 54 bool is_renderer_initiated, |
| 56 bool is_synchronous, | 55 bool is_same_page, |
| 57 bool is_srcdoc, | 56 bool is_srcdoc, |
| 58 const base::TimeTicks& navigation_start, | 57 const base::TimeTicks& navigation_start, |
| 59 int pending_nav_entry_id) | 58 int pending_nav_entry_id) |
| 60 : url_(url), | 59 : url_(url), |
| 61 has_user_gesture_(false), | 60 has_user_gesture_(false), |
| 62 transition_(ui::PAGE_TRANSITION_LINK), | 61 transition_(ui::PAGE_TRANSITION_LINK), |
| 63 is_external_protocol_(false), | 62 is_external_protocol_(false), |
| 64 net_error_code_(net::OK), | 63 net_error_code_(net::OK), |
| 65 render_frame_host_(nullptr), | 64 render_frame_host_(nullptr), |
| 66 is_renderer_initiated_(is_renderer_initiated), | 65 is_renderer_initiated_(is_renderer_initiated), |
| 67 is_same_page_(false), | 66 is_same_page_(is_same_page), |
| 68 is_synchronous_(is_synchronous), | |
| 69 is_srcdoc_(is_srcdoc), | 67 is_srcdoc_(is_srcdoc), |
| 70 was_redirected_(false), | 68 was_redirected_(false), |
| 71 state_(INITIAL), | 69 state_(INITIAL), |
| 72 is_transferring_(false), | 70 is_transferring_(false), |
| 73 frame_tree_node_(frame_tree_node), | 71 frame_tree_node_(frame_tree_node), |
| 74 next_index_(0), | 72 next_index_(0), |
| 75 navigation_start_(navigation_start), | 73 navigation_start_(navigation_start), |
| 76 pending_nav_entry_id_(pending_nav_entry_id), | 74 pending_nav_entry_id_(pending_nav_entry_id), |
| 77 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED) { | 75 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED) { |
| 78 DCHECK(!navigation_start.is_null()); | 76 DCHECK(!navigation_start.is_null()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 if (frame_tree_node_->parent()) | 119 if (frame_tree_node_->parent()) |
| 122 return frame_tree_node_->parent()->IsMainFrame(); | 120 return frame_tree_node_->parent()->IsMainFrame(); |
| 123 | 121 |
| 124 return false; | 122 return false; |
| 125 } | 123 } |
| 126 | 124 |
| 127 bool NavigationHandleImpl::IsRendererInitiated() { | 125 bool NavigationHandleImpl::IsRendererInitiated() { |
| 128 return is_renderer_initiated_; | 126 return is_renderer_initiated_; |
| 129 } | 127 } |
| 130 | 128 |
| 131 bool NavigationHandleImpl::IsSynchronousNavigation() { | |
| 132 return is_synchronous_; | |
| 133 } | |
| 134 | |
| 135 bool NavigationHandleImpl::IsSrcdoc() { | 129 bool NavigationHandleImpl::IsSrcdoc() { |
| 136 return is_srcdoc_; | 130 return is_srcdoc_; |
| 137 } | 131 } |
| 138 | 132 |
| 139 bool NavigationHandleImpl::WasServerRedirect() { | 133 bool NavigationHandleImpl::WasServerRedirect() { |
| 140 return was_redirected_; | 134 return was_redirected_; |
| 141 } | 135 } |
| 142 | 136 |
| 143 int NavigationHandleImpl::GetFrameTreeNodeId() { | 137 int NavigationHandleImpl::GetFrameTreeNodeId() { |
| 144 return frame_tree_node_->frame_tree_node_id(); | 138 return frame_tree_node_->frame_tree_node_id(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 // TODO(mkwst): Change this to check against 'READY_TO_COMMIT' once | 187 // TODO(mkwst): Change this to check against 'READY_TO_COMMIT' once |
| 194 // ReadyToCommitNavigation is available whether or not PlzNavigate is | 188 // ReadyToCommitNavigation is available whether or not PlzNavigate is |
| 195 // enabled. https://crbug.com/621856 | 189 // enabled. https://crbug.com/621856 |
| 196 CHECK_GE(state_, WILL_PROCESS_RESPONSE) | 190 CHECK_GE(state_, WILL_PROCESS_RESPONSE) |
| 197 << "This accessor should only be called after a response has been " | 191 << "This accessor should only be called after a response has been " |
| 198 "delivered for processing."; | 192 "delivered for processing."; |
| 199 return render_frame_host_; | 193 return render_frame_host_; |
| 200 } | 194 } |
| 201 | 195 |
| 202 bool NavigationHandleImpl::IsSamePage() { | 196 bool NavigationHandleImpl::IsSamePage() { |
| 203 DCHECK(state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE) | 197 return is_same_page_ && url_ != GURL(url::kAboutBlankURL); |
|
Charlie Reis
2016/09/16 22:23:53
Yes, this is exactly what I hoped for. It should
nasko
2016/09/16 23:38:11
Acknowledged.
|
Charlie Reis
2016/09/16 22:23:53
Hmm, I don't think it makes sense for is_same_page
nasko
2016/09/16 23:38:11
After poking at this a bit more, I think I don't n
|
| 204 << "This accessor should not be called before the navigation has " | |
| 205 "committed."; | |
| 206 return is_same_page_; | |
| 207 } | 198 } |
| 208 | 199 |
| 209 const net::HttpResponseHeaders* NavigationHandleImpl::GetResponseHeaders() { | 200 const net::HttpResponseHeaders* NavigationHandleImpl::GetResponseHeaders() { |
| 210 DCHECK_GE(state_, WILL_REDIRECT_REQUEST); | 201 DCHECK_GE(state_, WILL_REDIRECT_REQUEST); |
| 211 return response_headers_.get(); | 202 return response_headers_.get(); |
| 212 } | 203 } |
| 213 | 204 |
| 214 bool NavigationHandleImpl::HasCommitted() { | 205 bool NavigationHandleImpl::HasCommitted() { |
| 215 return state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE; | 206 return state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE; |
| 216 } | 207 } |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 if (IsBrowserSideNavigationEnabled()) | 437 if (IsBrowserSideNavigationEnabled()) |
| 447 GetDelegate()->ReadyToCommitNavigation(this); | 438 GetDelegate()->ReadyToCommitNavigation(this); |
| 448 } | 439 } |
| 449 | 440 |
| 450 void NavigationHandleImpl::DidCommitNavigation( | 441 void NavigationHandleImpl::DidCommitNavigation( |
| 451 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, | 442 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
| 452 bool same_page, | 443 bool same_page, |
| 453 RenderFrameHostImpl* render_frame_host) { | 444 RenderFrameHostImpl* render_frame_host) { |
| 454 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 445 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 455 DCHECK_EQ(frame_tree_node_, render_frame_host->frame_tree_node()); | 446 DCHECK_EQ(frame_tree_node_, render_frame_host->frame_tree_node()); |
| 447 DCHECK_EQ(same_page, IsSamePage()); | |
| 456 CHECK_EQ(url_, params.url); | 448 CHECK_EQ(url_, params.url); |
| 457 | 449 |
| 458 method_ = params.method; | 450 method_ = params.method; |
| 459 has_user_gesture_ = (params.gesture == NavigationGestureUser); | 451 has_user_gesture_ = (params.gesture == NavigationGestureUser); |
| 460 transition_ = params.transition; | 452 transition_ = params.transition; |
| 461 render_frame_host_ = render_frame_host; | 453 render_frame_host_ = render_frame_host; |
| 462 is_same_page_ = same_page; | |
| 463 | 454 |
| 464 state_ = net_error_code_ == net::OK ? DID_COMMIT : DID_COMMIT_ERROR_PAGE; | 455 state_ = net_error_code_ == net::OK ? DID_COMMIT : DID_COMMIT_ERROR_PAGE; |
| 465 } | 456 } |
| 466 | 457 |
| 467 NavigationThrottle::ThrottleCheckResult | 458 NavigationThrottle::ThrottleCheckResult |
| 468 NavigationHandleImpl::CheckWillStartRequest() { | 459 NavigationHandleImpl::CheckWillStartRequest() { |
| 469 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); | 460 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); |
| 470 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); | 461 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); |
| 471 DCHECK(state_ != DEFERRING_START || next_index_ != 0); | 462 DCHECK(state_ != DEFERRING_START || next_index_ != 0); |
| 472 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 463 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 592 throttles_to_register.push_back(std::move(clear_site_data_throttle)); | 583 throttles_to_register.push_back(std::move(clear_site_data_throttle)); |
| 593 | 584 |
| 594 if (throttles_to_register.size() > 0) { | 585 if (throttles_to_register.size() > 0) { |
| 595 throttles_.insert(throttles_.begin(), throttles_to_register.begin(), | 586 throttles_.insert(throttles_.begin(), throttles_to_register.begin(), |
| 596 throttles_to_register.end()); | 587 throttles_to_register.end()); |
| 597 throttles_to_register.weak_clear(); | 588 throttles_to_register.weak_clear(); |
| 598 } | 589 } |
| 599 } | 590 } |
| 600 | 591 |
| 601 } // namespace content | 592 } // namespace content |
| OLD | NEW |