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 <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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 52 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 53 if (ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get()) | 53 if (ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get()) |
| 54 rdh->CancelRequest(id.child_id, id.request_id); | 54 rdh->CancelRequest(id.child_id, id.request_id); |
| 55 } | 55 } |
| 56 | 56 |
| 57 } // namespace | 57 } // namespace |
| 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 FrameTreeNode* frame_tree_node, | 63 FrameTreeNode* frame_tree_node, |
| 63 bool is_renderer_initiated, | 64 bool is_renderer_initiated, |
| 64 bool is_same_page, | 65 bool is_same_page, |
| 65 const base::TimeTicks& navigation_start, | 66 const base::TimeTicks& navigation_start, |
| 66 int pending_nav_entry_id, | 67 int pending_nav_entry_id, |
| 67 bool started_from_context_menu) { | 68 bool started_from_context_menu) { |
| 68 return std::unique_ptr<NavigationHandleImpl>(new NavigationHandleImpl( | 69 return std::unique_ptr<NavigationHandleImpl>(new NavigationHandleImpl( |
| 69 url, frame_tree_node, is_renderer_initiated, is_same_page, | 70 url, redirect_chain, frame_tree_node, is_renderer_initiated, is_same_page, |
| 70 navigation_start, pending_nav_entry_id, | 71 navigation_start, pending_nav_entry_id, |
| 71 started_from_context_menu)); | 72 started_from_context_menu)); |
| 72 } | 73 } |
| 73 | 74 |
| 74 NavigationHandleImpl::NavigationHandleImpl( | 75 NavigationHandleImpl::NavigationHandleImpl( |
| 75 const GURL& url, | 76 const GURL& url, |
| 77 const std::vector<GURL>& redirect_chain, | |
| 76 FrameTreeNode* frame_tree_node, | 78 FrameTreeNode* frame_tree_node, |
| 77 bool is_renderer_initiated, | 79 bool is_renderer_initiated, |
| 78 bool is_same_page, | 80 bool is_same_page, |
| 79 const base::TimeTicks& navigation_start, | 81 const base::TimeTicks& navigation_start, |
| 80 int pending_nav_entry_id, | 82 int pending_nav_entry_id, |
| 81 bool started_from_context_menu) | 83 bool started_from_context_menu) |
| 82 : url_(url), | 84 : url_(url), |
| 83 has_user_gesture_(false), | 85 has_user_gesture_(false), |
| 84 transition_(ui::PAGE_TRANSITION_LINK), | 86 transition_(ui::PAGE_TRANSITION_LINK), |
| 85 is_external_protocol_(false), | 87 is_external_protocol_(false), |
| 86 net_error_code_(net::OK), | 88 net_error_code_(net::OK), |
| 87 render_frame_host_(nullptr), | 89 render_frame_host_(nullptr), |
| 88 is_renderer_initiated_(is_renderer_initiated), | 90 is_renderer_initiated_(is_renderer_initiated), |
| 89 is_same_page_(is_same_page), | 91 is_same_page_(is_same_page), |
| 90 was_redirected_(false), | 92 was_redirected_(false), |
| 93 did_replace_entry_(false), | |
| 94 should_update_history_(false), | |
| 91 connection_info_(net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN), | 95 connection_info_(net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN), |
| 92 original_url_(url), | 96 original_url_(url), |
| 93 state_(INITIAL), | 97 state_(INITIAL), |
| 94 is_transferring_(false), | 98 is_transferring_(false), |
| 95 frame_tree_node_(frame_tree_node), | 99 frame_tree_node_(frame_tree_node), |
| 96 next_index_(0), | 100 next_index_(0), |
| 97 navigation_start_(navigation_start), | 101 navigation_start_(navigation_start), |
| 98 pending_nav_entry_id_(pending_nav_entry_id), | 102 pending_nav_entry_id_(pending_nav_entry_id), |
| 99 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED), | 103 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED), |
| 100 mixed_content_context_type_(blink::WebMixedContentContextType::Blockable), | 104 mixed_content_context_type_(blink::WebMixedContentContextType::Blockable), |
| 101 should_replace_current_entry_(false), | 105 should_replace_current_entry_(false), |
| 106 redirect_chain_(redirect_chain), | |
| 102 is_download_(false), | 107 is_download_(false), |
| 103 is_stream_(false), | 108 is_stream_(false), |
| 104 started_from_context_menu_(started_from_context_menu), | 109 started_from_context_menu_(started_from_context_menu), |
| 105 reload_type_(ReloadType::NONE), | 110 reload_type_(ReloadType::NONE), |
| 106 weak_factory_(this) { | 111 weak_factory_(this) { |
| 107 DCHECK(!navigation_start.is_null()); | 112 DCHECK(!navigation_start.is_null()); |
| 108 redirect_chain_.push_back(url); | 113 if (redirect_chain_.empty()) |
| 114 redirect_chain_.push_back(url); | |
| 109 | 115 |
| 110 starting_site_instance_ = | 116 starting_site_instance_ = |
| 111 frame_tree_node_->current_frame_host()->GetSiteInstance(); | 117 frame_tree_node_->current_frame_host()->GetSiteInstance(); |
| 112 | 118 |
| 113 if (pending_nav_entry_id_) { | 119 if (pending_nav_entry_id_) { |
| 114 NavigationControllerImpl* nav_controller = | 120 NavigationControllerImpl* nav_controller = |
| 115 static_cast<NavigationControllerImpl*>( | 121 static_cast<NavigationControllerImpl*>( |
| 116 frame_tree_node_->navigator()->GetController()); | 122 frame_tree_node_->navigator()->GetController()); |
| 117 NavigationEntryImpl* nav_entry = | 123 NavigationEntryImpl* nav_entry = |
| 118 nav_controller->GetEntryWithUniqueID(pending_nav_entry_id_); | 124 nav_controller->GetEntryWithUniqueID(pending_nav_entry_id_); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 } | 276 } |
| 271 | 277 |
| 272 bool NavigationHandleImpl::HasCommitted() { | 278 bool NavigationHandleImpl::HasCommitted() { |
| 273 return state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE; | 279 return state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE; |
| 274 } | 280 } |
| 275 | 281 |
| 276 bool NavigationHandleImpl::IsErrorPage() { | 282 bool NavigationHandleImpl::IsErrorPage() { |
| 277 return state_ == DID_COMMIT_ERROR_PAGE; | 283 return state_ == DID_COMMIT_ERROR_PAGE; |
| 278 } | 284 } |
| 279 | 285 |
| 286 bool NavigationHandleImpl::DidReplaceEntry() { | |
| 287 DCHECK(state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE); | |
| 288 return did_replace_entry_; | |
| 289 } | |
| 290 | |
| 291 bool NavigationHandleImpl::ShouldUpdateHistory() { | |
| 292 DCHECK(state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE); | |
| 293 return should_update_history_; | |
| 294 } | |
| 295 | |
| 280 void NavigationHandleImpl::Resume() { | 296 void NavigationHandleImpl::Resume() { |
| 281 if (state_ != DEFERRING_START && state_ != DEFERRING_REDIRECT && | 297 if (state_ != DEFERRING_START && state_ != DEFERRING_REDIRECT && |
| 282 state_ != DEFERRING_RESPONSE) { | 298 state_ != DEFERRING_RESPONSE) { |
| 283 return; | 299 return; |
| 284 } | 300 } |
| 285 | 301 |
| 286 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; | 302 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; |
| 287 if (state_ == DEFERRING_START) { | 303 if (state_ == DEFERRING_START) { |
| 288 result = CheckWillStartRequest(); | 304 result = CheckWillStartRequest(); |
| 289 } else if (state_ == DEFERRING_REDIRECT) { | 305 } else if (state_ == DEFERRING_REDIRECT) { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 RequestContextType request_context_type, | 473 RequestContextType request_context_type, |
| 458 blink::WebMixedContentContextType mixed_content_context_type, | 474 blink::WebMixedContentContextType mixed_content_context_type, |
| 459 const ThrottleChecksFinishedCallback& callback) { | 475 const ThrottleChecksFinishedCallback& callback) { |
| 460 if (method != "POST") | 476 if (method != "POST") |
| 461 DCHECK(!resource_request_body); | 477 DCHECK(!resource_request_body); |
| 462 | 478 |
| 463 // Update the navigation parameters. | 479 // Update the navigation parameters. |
| 464 method_ = method; | 480 method_ = method; |
| 465 if (method_ == "POST") | 481 if (method_ == "POST") |
| 466 resource_request_body_ = resource_request_body; | 482 resource_request_body_ = resource_request_body; |
| 467 sanitized_referrer_ = sanitized_referrer; | |
| 468 has_user_gesture_ = has_user_gesture; | 483 has_user_gesture_ = has_user_gesture; |
| 469 transition_ = transition; | 484 transition_ = transition; |
| 485 if (transition_ & ui::PAGE_TRANSITION_CLIENT_REDIRECT) { | |
|
jam
2017/01/31 20:24:23
this mirrors the logic in RenderFrameImpl::SendDid
| |
| 486 // If the page contained a client redirect (meta refresh, document.loc...), | |
|
nasko
2017/02/06 19:07:52
nit: Don't use ..., spell out the whole word.
| |
| 487 // set the referrer appropriately. | |
| 488 sanitized_referrer_ = | |
| 489 Referrer(redirect_chain_[0], sanitized_referrer.policy); | |
| 490 } else { | |
| 491 sanitized_referrer_ = sanitized_referrer; | |
| 492 } | |
| 470 is_external_protocol_ = is_external_protocol; | 493 is_external_protocol_ = is_external_protocol; |
| 471 request_context_type_ = request_context_type; | 494 request_context_type_ = request_context_type; |
| 472 mixed_content_context_type_ = mixed_content_context_type; | 495 mixed_content_context_type_ = mixed_content_context_type; |
| 473 state_ = WILL_SEND_REQUEST; | 496 state_ = WILL_SEND_REQUEST; |
| 474 complete_callback_ = callback; | 497 complete_callback_ = callback; |
| 475 | 498 |
| 476 RegisterNavigationThrottles(); | 499 RegisterNavigationThrottles(); |
| 477 | 500 |
| 478 if (IsBrowserSideNavigationEnabled()) | 501 if (IsBrowserSideNavigationEnabled()) |
| 479 navigation_ui_data_ = GetDelegate()->GetNavigationUIData(this); | 502 navigation_ui_data_ = GetDelegate()->GetNavigationUIData(this); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 490 const GURL& new_url, | 513 const GURL& new_url, |
| 491 const std::string& new_method, | 514 const std::string& new_method, |
| 492 const GURL& new_referrer_url, | 515 const GURL& new_referrer_url, |
| 493 bool new_is_external_protocol, | 516 bool new_is_external_protocol, |
| 494 scoped_refptr<net::HttpResponseHeaders> response_headers, | 517 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 495 net::HttpResponseInfo::ConnectionInfo connection_info, | 518 net::HttpResponseInfo::ConnectionInfo connection_info, |
| 496 const ThrottleChecksFinishedCallback& callback) { | 519 const ThrottleChecksFinishedCallback& callback) { |
| 497 // Update the navigation parameters. | 520 // Update the navigation parameters. |
| 498 url_ = new_url; | 521 url_ = new_url; |
| 499 method_ = new_method; | 522 method_ = new_method; |
| 500 sanitized_referrer_.url = new_referrer_url; | 523 |
| 501 sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_); | 524 if (!(transition_ & ui::PAGE_TRANSITION_CLIENT_REDIRECT)) { |
| 525 sanitized_referrer_.url = new_referrer_url; | |
| 526 sanitized_referrer_ = | |
| 527 Referrer::SanitizeForRequest(url_, sanitized_referrer_); | |
| 528 } | |
| 529 | |
| 502 is_external_protocol_ = new_is_external_protocol; | 530 is_external_protocol_ = new_is_external_protocol; |
| 503 response_headers_ = response_headers; | 531 response_headers_ = response_headers; |
| 504 connection_info_ = connection_info; | 532 connection_info_ = connection_info; |
| 505 was_redirected_ = true; | 533 was_redirected_ = true; |
| 506 redirect_chain_.push_back(new_url); | 534 redirect_chain_.push_back(new_url); |
| 507 if (new_method != "POST") | 535 if (new_method != "POST") |
| 508 resource_request_body_ = nullptr; | 536 resource_request_body_ = nullptr; |
| 509 | 537 |
| 510 state_ = WILL_REDIRECT_REQUEST; | 538 state_ = WILL_REDIRECT_REQUEST; |
| 511 complete_callback_ = callback; | 539 complete_callback_ = callback; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 563 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 591 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 564 render_frame_host_ = render_frame_host; | 592 render_frame_host_ = render_frame_host; |
| 565 state_ = READY_TO_COMMIT; | 593 state_ = READY_TO_COMMIT; |
| 566 | 594 |
| 567 if (!IsRendererDebugURL(url_)) | 595 if (!IsRendererDebugURL(url_)) |
| 568 GetDelegate()->ReadyToCommitNavigation(this); | 596 GetDelegate()->ReadyToCommitNavigation(this); |
| 569 } | 597 } |
| 570 | 598 |
| 571 void NavigationHandleImpl::DidCommitNavigation( | 599 void NavigationHandleImpl::DidCommitNavigation( |
| 572 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, | 600 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
| 573 bool same_page, | 601 bool did_replace_entry, |
| 574 RenderFrameHostImpl* render_frame_host) { | 602 RenderFrameHostImpl* render_frame_host) { |
| 575 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 603 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 576 DCHECK_EQ(frame_tree_node_, render_frame_host->frame_tree_node()); | 604 DCHECK_EQ(frame_tree_node_, render_frame_host->frame_tree_node()); |
| 577 CHECK_EQ(url_, params.url); | 605 CHECK_EQ(url_, params.url); |
| 578 | 606 |
| 607 did_replace_entry_ = did_replace_entry; | |
| 579 method_ = params.method; | 608 method_ = params.method; |
| 580 has_user_gesture_ = (params.gesture == NavigationGestureUser); | 609 has_user_gesture_ = (params.gesture == NavigationGestureUser); |
| 581 transition_ = params.transition; | 610 transition_ = params.transition; |
| 611 should_update_history_ = params.should_update_history; | |
| 582 render_frame_host_ = render_frame_host; | 612 render_frame_host_ = render_frame_host; |
| 583 | 613 |
| 584 // If an error page reloads, net_error_code might be 200 but we still want to | 614 // If an error page reloads, net_error_code might be 200 but we still want to |
| 585 // count it as an error page. | 615 // count it as an error page. |
| 586 if (params.base_url.spec() == kUnreachableWebDataURL || | 616 if (params.base_url.spec() == kUnreachableWebDataURL || |
| 587 net_error_code_ != net::OK) { | 617 net_error_code_ != net::OK) { |
| 588 state_ = DID_COMMIT_ERROR_PAGE; | 618 state_ = DID_COMMIT_ERROR_PAGE; |
| 589 } else { | 619 } else { |
| 590 state_ = DID_COMMIT; | 620 state_ = DID_COMMIT; |
| 591 } | 621 } |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 834 content::AncestorThrottle::MaybeCreateThrottleFor(this); | 864 content::AncestorThrottle::MaybeCreateThrottleFor(this); |
| 835 if (ancestor_throttle) | 865 if (ancestor_throttle) |
| 836 throttles_.push_back(std::move(ancestor_throttle)); | 866 throttles_.push_back(std::move(ancestor_throttle)); |
| 837 | 867 |
| 838 throttles_.insert(throttles_.begin(), | 868 throttles_.insert(throttles_.begin(), |
| 839 std::make_move_iterator(throttles_to_register.begin()), | 869 std::make_move_iterator(throttles_to_register.begin()), |
| 840 std::make_move_iterator(throttles_to_register.end())); | 870 std::make_move_iterator(throttles_to_register.end())); |
| 841 } | 871 } |
| 842 | 872 |
| 843 } // namespace content | 873 } // namespace content |
| OLD | NEW |