OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/navigator_impl.h" | 5 #include "content/browser/frame_host/navigator_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 unique_name.size()); | 504 unique_name.size()); |
505 } | 505 } |
506 } | 506 } |
507 | 507 |
508 return NavigateToEntry(render_frame_host->frame_tree_node(), *frame_entry, | 508 return NavigateToEntry(render_frame_host->frame_tree_node(), *frame_entry, |
509 *entry, ReloadType::NONE, false, true, false, nullptr); | 509 *entry, ReloadType::NONE, false, true, false, nullptr); |
510 } | 510 } |
511 | 511 |
512 void NavigatorImpl::DidNavigate( | 512 void NavigatorImpl::DidNavigate( |
513 RenderFrameHostImpl* render_frame_host, | 513 RenderFrameHostImpl* render_frame_host, |
514 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 514 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
| 515 std::unique_ptr<NavigationHandleImpl> navigation_handle) { |
515 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree(); | 516 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree(); |
516 bool oopifs_possible = SiteIsolationPolicy::AreCrossProcessFramesPossible(); | 517 bool oopifs_possible = SiteIsolationPolicy::AreCrossProcessFramesPossible(); |
517 | 518 |
518 bool has_embedded_credentials = | 519 bool has_embedded_credentials = |
519 params.url.has_username() || params.url.has_password(); | 520 params.url.has_username() || params.url.has_password(); |
520 UMA_HISTOGRAM_BOOLEAN("Navigation.FrameHasEmbeddedCredentials", | 521 UMA_HISTOGRAM_BOOLEAN("Navigation.FrameHasEmbeddedCredentials", |
521 has_embedded_credentials); | 522 has_embedded_credentials); |
522 | 523 |
523 bool is_navigation_within_page = controller_->IsURLInPageNavigation( | 524 bool is_navigation_within_page = controller_->IsURLInPageNavigation( |
524 params.url, params.origin, params.was_within_same_page, | 525 params.url, params.origin, params.was_within_same_page, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 // regressing it again. | 612 // regressing it again. |
612 // TODO(nasko): Verify the correctness of the above comment, since some of the | 613 // TODO(nasko): Verify the correctness of the above comment, since some of the |
613 // code doesn't exist anymore. Also, move this code in the | 614 // code doesn't exist anymore. Also, move this code in the |
614 // PageTransitionIsMainFrame code block above. | 615 // PageTransitionIsMainFrame code block above. |
615 if (ui::PageTransitionIsMainFrame(params.transition) && delegate_) | 616 if (ui::PageTransitionIsMainFrame(params.transition) && delegate_) |
616 delegate_->SetMainFrameMimeType(params.contents_mime_type); | 617 delegate_->SetMainFrameMimeType(params.contents_mime_type); |
617 | 618 |
618 int old_entry_count = controller_->GetEntryCount(); | 619 int old_entry_count = controller_->GetEntryCount(); |
619 LoadCommittedDetails details; | 620 LoadCommittedDetails details; |
620 bool did_navigate = controller_->RendererDidNavigate( | 621 bool did_navigate = controller_->RendererDidNavigate( |
621 render_frame_host, params, &details, is_navigation_within_page); | 622 render_frame_host, params, &details, is_navigation_within_page, |
| 623 navigation_handle.get()); |
622 | 624 |
623 // If the history length and/or offset changed, update other renderers in the | 625 // If the history length and/or offset changed, update other renderers in the |
624 // FrameTree. | 626 // FrameTree. |
625 if (old_entry_count != controller_->GetEntryCount() || | 627 if (old_entry_count != controller_->GetEntryCount() || |
626 details.previous_entry_index != | 628 details.previous_entry_index != |
627 controller_->GetLastCommittedEntryIndex()) { | 629 controller_->GetLastCommittedEntryIndex()) { |
628 frame_tree->root()->render_manager()->SendPageMessage( | 630 frame_tree->root()->render_manager()->SendPageMessage( |
629 new PageMsg_SetHistoryOffsetAndLength( | 631 new PageMsg_SetHistoryOffsetAndLength( |
630 MSG_ROUTING_NONE, controller_->GetLastCommittedEntryIndex(), | 632 MSG_ROUTING_NONE, controller_->GetLastCommittedEntryIndex(), |
631 controller_->GetEntryCount()), | 633 controller_->GetEntryCount()), |
(...skipping 28 matching lines...) Expand all Loading... |
660 if (did_navigate && | 662 if (did_navigate && |
661 (controller_->GetLastCommittedEntry()->GetTransitionType() & | 663 (controller_->GetLastCommittedEntry()->GetTransitionType() & |
662 ui::PAGE_TRANSITION_FORWARD_BACK)) { | 664 ui::PAGE_TRANSITION_FORWARD_BACK)) { |
663 transition_type = ui::PageTransitionFromInt( | 665 transition_type = ui::PageTransitionFromInt( |
664 params.transition | ui::PAGE_TRANSITION_FORWARD_BACK); | 666 params.transition | ui::PAGE_TRANSITION_FORWARD_BACK); |
665 } | 667 } |
666 | 668 |
667 delegate_->DidCommitProvisionalLoad(render_frame_host, | 669 delegate_->DidCommitProvisionalLoad(render_frame_host, |
668 params.url, | 670 params.url, |
669 transition_type); | 671 transition_type); |
670 render_frame_host->navigation_handle()->DidCommitNavigation( | 672 navigation_handle->DidCommitNavigation(params, is_navigation_within_page, |
671 params, is_navigation_within_page, render_frame_host); | 673 render_frame_host); |
672 render_frame_host->SetNavigationHandle(nullptr); | 674 navigation_handle.reset(); |
673 } | 675 } |
674 | 676 |
675 if (!did_navigate) | 677 if (!did_navigate) |
676 return; // No navigation happened. | 678 return; // No navigation happened. |
677 | 679 |
678 // DO NOT ADD MORE STUFF TO THIS FUNCTION! Your component should either listen | 680 // DO NOT ADD MORE STUFF TO THIS FUNCTION! Your component should either listen |
679 // for the appropriate notification (best) or you can add it to | 681 // for the appropriate notification (best) or you can add it to |
680 // DidNavigateMainFramePostCommit / DidNavigateAnyFramePostCommit (only if | 682 // DidNavigateMainFramePostCommit / DidNavigateAnyFramePostCommit (only if |
681 // necessary, please). | 683 // necessary, please). |
682 | 684 |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 const base::TimeTicks& renderer_before_unload_end_time) { | 1065 const base::TimeTicks& renderer_before_unload_end_time) { |
1064 // Only stores the beforeunload delay if we're tracking a browser initiated | 1066 // Only stores the beforeunload delay if we're tracking a browser initiated |
1065 // navigation and it happened later than the navigation request. | 1067 // navigation and it happened later than the navigation request. |
1066 if (navigation_data_ && | 1068 if (navigation_data_ && |
1067 renderer_before_unload_start_time > navigation_data_->start_time_) { | 1069 renderer_before_unload_start_time > navigation_data_->start_time_) { |
1068 navigation_data_->before_unload_delay_ = | 1070 navigation_data_->before_unload_delay_ = |
1069 renderer_before_unload_end_time - renderer_before_unload_start_time; | 1071 renderer_before_unload_end_time - renderer_before_unload_start_time; |
1070 } | 1072 } |
1071 } | 1073 } |
1072 | 1074 |
1073 NavigationHandleImpl* NavigatorImpl::GetNavigationHandleForFrameHost( | |
1074 RenderFrameHostImpl* render_frame_host) { | |
1075 return render_frame_host->navigation_handle(); | |
1076 } | |
1077 | |
1078 void NavigatorImpl::DiscardPendingEntryIfNeeded(NavigationHandleImpl* handle) { | 1075 void NavigatorImpl::DiscardPendingEntryIfNeeded(NavigationHandleImpl* handle) { |
1079 // Racy conditions can cause a fail message to arrive after its corresponding | 1076 // Racy conditions can cause a fail message to arrive after its corresponding |
1080 // pending entry has been replaced by another navigation. If | 1077 // pending entry has been replaced by another navigation. If |
1081 // |DiscardPendingEntry| is called in this case, then the completely valid | 1078 // |DiscardPendingEntry| is called in this case, then the completely valid |
1082 // entry for the new navigation would be discarded. See crbug.com/513742. To | 1079 // entry for the new navigation would be discarded. See crbug.com/513742. To |
1083 // catch this case, the current pending entry is compared against the current | 1080 // catch this case, the current pending entry is compared against the current |
1084 // navigation handle's entry id, which should correspond to the failed load. | 1081 // navigation handle's entry id, which should correspond to the failed load. |
1085 NavigationEntry* pending_entry = controller_->GetPendingEntry(); | 1082 NavigationEntry* pending_entry = controller_->GetPendingEntry(); |
1086 bool pending_matches_fail_msg = | 1083 bool pending_matches_fail_msg = |
1087 handle && pending_entry && | 1084 handle && pending_entry && |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 if (navigation_handle) | 1264 if (navigation_handle) |
1268 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); | 1265 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); |
1269 | 1266 |
1270 controller_->SetPendingEntry(std::move(entry)); | 1267 controller_->SetPendingEntry(std::move(entry)); |
1271 if (delegate_) | 1268 if (delegate_) |
1272 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1269 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
1273 } | 1270 } |
1274 } | 1271 } |
1275 | 1272 |
1276 } // namespace content | 1273 } // namespace content |
OLD | NEW |