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 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 // Note also that we hide the referrer for Web UI pages. We don't really | 739 // Note also that we hide the referrer for Web UI pages. We don't really |
740 // want web sites to see a referrer of "chrome://blah" (and some | 740 // want web sites to see a referrer of "chrome://blah" (and some |
741 // chrome: URLs might have search terms or other stuff we don't want to | 741 // chrome: URLs might have search terms or other stuff we don't want to |
742 // send to the site), so we send no referrer. | 742 // send to the site), so we send no referrer. |
743 referrer_to_use = Referrer(); | 743 referrer_to_use = Referrer(); |
744 | 744 |
745 // Navigations in Web UI pages count as browser-initiated navigations. | 745 // Navigations in Web UI pages count as browser-initiated navigations. |
746 is_renderer_initiated = false; | 746 is_renderer_initiated = false; |
747 } | 747 } |
748 | 748 |
749 NavigationController::LoadURLParams load_url_params(dest_url); | 749 // Create a NavigationEntry for the transfer, without making it the pending |
| 750 // entry. Subframe transfers should only be possible in OOPIF-enabled modes, |
| 751 // and should have a clone of the last committed entry with a |
| 752 // FrameNavigationEntry for the target frame. Main frame transfers should |
| 753 // have a new NavigationEntry. |
| 754 // TODO(creis): Make this unnecessary by creating (and validating) the params |
| 755 // directly, passing them to the destination RenderFrameHost. See |
| 756 // https://crbug.com/536906. |
| 757 std::unique_ptr<NavigationEntryImpl> entry; |
| 758 if (!node->IsMainFrame()) { |
| 759 // Subframe case: create FrameNavigationEntry. |
| 760 CHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); |
| 761 if (controller_->GetLastCommittedEntry()) { |
| 762 entry = controller_->GetLastCommittedEntry()->Clone(); |
| 763 entry->SetPageID(-1); |
| 764 } else { |
| 765 // If there's no last committed entry, create an entry for about:blank |
| 766 // with a subframe entry for our destination. |
| 767 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208. |
| 768 entry = NavigationEntryImpl::FromNavigationEntry( |
| 769 controller_->CreateNavigationEntry( |
| 770 GURL(url::kAboutBlankURL), referrer_to_use, page_transition, |
| 771 is_renderer_initiated, std::string(), |
| 772 controller_->GetBrowserContext())); |
| 773 } |
| 774 // TODO(creis): Handle POST submissions. See https://crbug.com/582211 and |
| 775 // https://crbug.com/101395. |
| 776 entry->AddOrUpdateFrameEntry(node, -1, -1, nullptr, dest_url, |
| 777 referrer_to_use, PageState(), "GET", -1); |
| 778 } else { |
| 779 // Main frame case. |
| 780 entry = NavigationEntryImpl::FromNavigationEntry( |
| 781 controller_->CreateNavigationEntry( |
| 782 dest_url, referrer_to_use, page_transition, is_renderer_initiated, |
| 783 std::string(), controller_->GetBrowserContext())); |
| 784 } |
| 785 |
750 // The source_site_instance may matter for navigations via RenderFrameProxy. | 786 // The source_site_instance may matter for navigations via RenderFrameProxy. |
751 load_url_params.source_site_instance = source_site_instance; | 787 entry->set_source_site_instance( |
752 load_url_params.transition_type = page_transition; | 788 static_cast<SiteInstanceImpl*>(source_site_instance)); |
753 load_url_params.frame_tree_node_id = node->frame_tree_node_id(); | 789 entry->SetRedirectChain(redirect_chain); |
754 load_url_params.referrer = referrer_to_use; | 790 // Don't allow an entry replacement if there is no entry to replace. |
755 load_url_params.redirect_chain = redirect_chain; | 791 // http://crbug.com/457149 |
756 load_url_params.is_renderer_initiated = is_renderer_initiated; | 792 if (should_replace_current_entry && controller_->GetEntryCount() > 0) |
757 load_url_params.transferred_global_request_id = transferred_global_request_id; | 793 entry->set_should_replace_entry(true); |
758 load_url_params.should_replace_current_entry = should_replace_current_entry; | 794 if (controller_->GetLastCommittedEntry() && |
| 795 controller_->GetLastCommittedEntry()->GetIsOverridingUserAgent()) { |
| 796 entry->SetIsOverridingUserAgent(true); |
| 797 } |
| 798 entry->set_transferred_global_request_id(transferred_global_request_id); |
| 799 // TODO(creis): Set user gesture and intent received timestamp on Android. |
759 | 800 |
760 controller_->LoadURLWithParams(load_url_params); | 801 // We may not have successfully added the FrameNavigationEntry to |entry| |
| 802 // above (per https://crbug.com/608402), in which case we create it from |
| 803 // scratch. This works because we do not depend on |frame_entry| being inside |
| 804 // |entry| during NavigateToEntry. This will go away when we shortcut this |
| 805 // further in https://crbug.com/536906. |
| 806 scoped_refptr<FrameNavigationEntry> frame_entry(entry->GetFrameEntry(node)); |
| 807 if (!frame_entry) { |
| 808 // TODO(creis): Handle POST submissions here, as above. |
| 809 frame_entry = |
| 810 new FrameNavigationEntry(node->unique_name(), -1, -1, nullptr, dest_url, |
| 811 referrer_to_use, "GET", -1); |
| 812 } |
| 813 NavigateToEntry(node, *frame_entry, *entry.get(), |
| 814 NavigationController::NO_RELOAD, false, false); |
761 } | 815 } |
762 | 816 |
763 // PlzNavigate | 817 // PlzNavigate |
764 void NavigatorImpl::OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, | 818 void NavigatorImpl::OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, |
765 bool proceed) { | 819 bool proceed) { |
766 CHECK(IsBrowserSideNavigationEnabled()); | 820 CHECK(IsBrowserSideNavigationEnabled()); |
767 DCHECK(frame_tree_node); | 821 DCHECK(frame_tree_node); |
768 | 822 |
769 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); | 823 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); |
770 | 824 |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 if (pending_entry != controller_->GetVisibleEntry() || | 1145 if (pending_entry != controller_->GetVisibleEntry() || |
1092 !should_preserve_entry) { | 1146 !should_preserve_entry) { |
1093 controller_->DiscardPendingEntry(true); | 1147 controller_->DiscardPendingEntry(true); |
1094 | 1148 |
1095 // Also force the UI to refresh. | 1149 // Also force the UI to refresh. |
1096 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 1150 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
1097 } | 1151 } |
1098 } | 1152 } |
1099 | 1153 |
1100 } // namespace content | 1154 } // namespace content |
OLD | NEW |