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/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 // Note also that we hide the referrer for Web UI pages. We don't really | 749 // Note also that we hide the referrer for Web UI pages. We don't really |
750 // want web sites to see a referrer of "chrome://blah" (and some | 750 // want web sites to see a referrer of "chrome://blah" (and some |
751 // chrome: URLs might have search terms or other stuff we don't want to | 751 // chrome: URLs might have search terms or other stuff we don't want to |
752 // send to the site), so we send no referrer. | 752 // send to the site), so we send no referrer. |
753 referrer_to_use = Referrer(); | 753 referrer_to_use = Referrer(); |
754 | 754 |
755 // Navigations in Web UI pages count as browser-initiated navigations. | 755 // Navigations in Web UI pages count as browser-initiated navigations. |
756 is_renderer_initiated = false; | 756 is_renderer_initiated = false; |
757 } | 757 } |
758 | 758 |
759 NavigationController::LoadURLParams load_url_params(dest_url); | 759 // Create a NavigationEntry for the transfer, without making it the pending |
| 760 // entry. Subframe transfers should only be possible in OOPIF-enabled modes, |
| 761 // and should have a clone of the last committed entry with a |
| 762 // FrameNavigationEntry for the target frame. Main frame transfers should |
| 763 // have a new NavigationEntry. |
| 764 // TODO(creis): Make this unnecessary by creating (and validating) the params |
| 765 // directly, passing them to the destination RenderFrameHost. |
| 766 scoped_ptr<NavigationEntryImpl> entry; |
| 767 if (!node->IsMainFrame()) { |
| 768 // Subframe case: create FrameNavigationEntry. |
| 769 CHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); |
| 770 if (controller_->GetLastCommittedEntry()) { |
| 771 entry = controller_->GetLastCommittedEntry()->Clone(); |
| 772 entry->SetPageID(-1); |
| 773 } else { |
| 774 // If there's no last committed entry, create an entry for about:blank |
| 775 // with a subframe entry for our destination. |
| 776 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208. |
| 777 entry = NavigationEntryImpl::FromNavigationEntry( |
| 778 controller_->CreateNavigationEntry( |
| 779 GURL(url::kAboutBlankURL), referrer_to_use, page_transition, |
| 780 is_renderer_initiated, std::string(), |
| 781 controller_->GetBrowserContext())); |
| 782 } |
| 783 entry->AddOrUpdateFrameEntry(node, std::string(), -1, -1, nullptr, dest_url, |
| 784 referrer_to_use, PageState()); |
| 785 } else { |
| 786 // Main frame case. |
| 787 entry = NavigationEntryImpl::FromNavigationEntry( |
| 788 controller_->CreateNavigationEntry( |
| 789 dest_url, referrer_to_use, page_transition, is_renderer_initiated, |
| 790 std::string(), controller_->GetBrowserContext())); |
| 791 } |
| 792 |
760 // The source_site_instance may matter for navigations via RenderFrameProxy. | 793 // The source_site_instance may matter for navigations via RenderFrameProxy. |
761 load_url_params.source_site_instance = source_site_instance; | 794 entry->set_source_site_instance( |
762 load_url_params.transition_type = page_transition; | 795 static_cast<SiteInstanceImpl*>(source_site_instance)); |
763 load_url_params.frame_tree_node_id = node->frame_tree_node_id(); | 796 entry->SetRedirectChain(redirect_chain); |
764 load_url_params.referrer = referrer_to_use; | 797 // Don't allow an entry replacement if there is no entry to replace. |
765 load_url_params.redirect_chain = redirect_chain; | 798 // http://crbug.com/457149 |
766 load_url_params.is_renderer_initiated = is_renderer_initiated; | 799 if (should_replace_current_entry && controller_->GetEntryCount() > 0) |
767 load_url_params.transferred_global_request_id = transferred_global_request_id; | 800 entry->set_should_replace_entry(true); |
768 load_url_params.should_replace_current_entry = should_replace_current_entry; | 801 if (controller_->GetLastCommittedEntry() && |
769 | 802 controller_->GetLastCommittedEntry()->GetIsOverridingUserAgent()) { |
770 controller_->LoadURLWithParams(load_url_params); | 803 entry->SetIsOverridingUserAgent(true); |
| 804 } |
| 805 entry->set_transferred_global_request_id(transferred_global_request_id); |
| 806 // TODO(creis): Set user gesture and intent received timestamp on Android. |
| 807 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(node); |
| 808 NavigateToEntry(node, *frame_entry, *entry.get(), |
| 809 NavigationController::NO_RELOAD, false, false); |
771 } | 810 } |
772 | 811 |
773 // PlzNavigate | 812 // PlzNavigate |
774 void NavigatorImpl::OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, | 813 void NavigatorImpl::OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, |
775 bool proceed) { | 814 bool proceed) { |
776 CHECK(IsBrowserSideNavigationEnabled()); | 815 CHECK(IsBrowserSideNavigationEnabled()); |
777 DCHECK(frame_tree_node); | 816 DCHECK(frame_tree_node); |
778 | 817 |
779 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); | 818 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); |
780 | 819 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 if (pending_entry != controller_->GetVisibleEntry() || | 1135 if (pending_entry != controller_->GetVisibleEntry() || |
1097 !should_preserve_entry) { | 1136 !should_preserve_entry) { |
1098 controller_->DiscardPendingEntry(true); | 1137 controller_->DiscardPendingEntry(true); |
1099 | 1138 |
1100 // Also force the UI to refresh. | 1139 // Also force the UI to refresh. |
1101 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 1140 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
1102 } | 1141 } |
1103 } | 1142 } |
1104 | 1143 |
1105 } // namespace content | 1144 } // namespace content |
OLD | NEW |