Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: content/browser/frame_host/navigator_impl.cc

Issue 1871293002: Don't use pending NavigationEntries for navigation transfers (try #2). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix SubframeOnEmptyPage Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 entry->AddOrUpdateFrameEntry(node, -1, -1, nullptr, dest_url,
775 referrer_to_use, PageState(), "GET", -1);
alexmos 2016/05/03 22:07:52 Is it ok that this is always "GET" (and also in th
Charlie Reis 2016/05/03 23:43:05 Yeah, this is a TODO.
776 } else {
777 // Main frame case.
778 entry = NavigationEntryImpl::FromNavigationEntry(
779 controller_->CreateNavigationEntry(
780 dest_url, referrer_to_use, page_transition, is_renderer_initiated,
781 std::string(), controller_->GetBrowserContext()));
782 }
783
750 // The source_site_instance may matter for navigations via RenderFrameProxy. 784 // The source_site_instance may matter for navigations via RenderFrameProxy.
751 load_url_params.source_site_instance = source_site_instance; 785 entry->set_source_site_instance(
752 load_url_params.transition_type = page_transition; 786 static_cast<SiteInstanceImpl*>(source_site_instance));
753 load_url_params.frame_tree_node_id = node->frame_tree_node_id(); 787 entry->SetRedirectChain(redirect_chain);
754 load_url_params.referrer = referrer_to_use; 788 // Don't allow an entry replacement if there is no entry to replace.
755 load_url_params.redirect_chain = redirect_chain; 789 // http://crbug.com/457149
756 load_url_params.is_renderer_initiated = is_renderer_initiated; 790 if (should_replace_current_entry && controller_->GetEntryCount() > 0)
757 load_url_params.transferred_global_request_id = transferred_global_request_id; 791 entry->set_should_replace_entry(true);
758 load_url_params.should_replace_current_entry = should_replace_current_entry; 792 if (controller_->GetLastCommittedEntry() &&
793 controller_->GetLastCommittedEntry()->GetIsOverridingUserAgent()) {
794 entry->SetIsOverridingUserAgent(true);
795 }
796 entry->set_transferred_global_request_id(transferred_global_request_id);
797 // TODO(creis): Set user gesture and intent received timestamp on Android.
798 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(node);
759 799
760 controller_->LoadURLWithParams(load_url_params); 800 // We may not have successfully added the FrameNavigationEntry to |entry|
801 // above (per https://crbug.com/608402), in which case we create it from
802 // scratch. This works because we do not depend on |frame_entry| being inside
803 // |entry| during NavigateToEntry. This will go away when we shortcut this
804 // further in https://crbug.com/536906.
805 if (!frame_entry) {
Charlie Reis 2016/05/02 22:35:34 This is the fix. It should be safe for the time b
806 frame_entry =
alexmos 2016/05/03 22:07:51 How will this get cleaned up?
Charlie Reis 2016/05/03 23:43:05 Good point-- it would leak in this branch, since |
807 new FrameNavigationEntry(node->unique_name(), -1, -1, nullptr, dest_url,
808 referrer_to_use, "GET", -1);
809 }
810 NavigateToEntry(node, *frame_entry, *entry.get(),
811 NavigationController::NO_RELOAD, false, false);
761 } 812 }
762 813
763 // PlzNavigate 814 // PlzNavigate
764 void NavigatorImpl::OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, 815 void NavigatorImpl::OnBeforeUnloadACK(FrameTreeNode* frame_tree_node,
765 bool proceed) { 816 bool proceed) {
766 CHECK(IsBrowserSideNavigationEnabled()); 817 CHECK(IsBrowserSideNavigationEnabled());
767 DCHECK(frame_tree_node); 818 DCHECK(frame_tree_node);
768 819
769 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); 820 NavigationRequest* navigation_request = frame_tree_node->navigation_request();
770 821
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 if (pending_entry != controller_->GetVisibleEntry() || 1142 if (pending_entry != controller_->GetVisibleEntry() ||
1092 !should_preserve_entry) { 1143 !should_preserve_entry) {
1093 controller_->DiscardPendingEntry(true); 1144 controller_->DiscardPendingEntry(true);
1094 1145
1095 // Also force the UI to refresh. 1146 // Also force the UI to refresh.
1096 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); 1147 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL);
1097 } 1148 }
1098 } 1149 }
1099 1150
1100 } // namespace content 1151 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698