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

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

Issue 1956383003: Forwarding POST body into renderer after a cross-site transfer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More tweaks of the DCHECKs in constructor of CommonNavigationParams. Created 4 years, 6 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 error_description, was_ignored_by_handler); 262 error_description, was_ignored_by_handler);
263 } 263 }
264 } 264 }
265 265
266 bool NavigatorImpl::NavigateToEntry( 266 bool NavigatorImpl::NavigateToEntry(
267 FrameTreeNode* frame_tree_node, 267 FrameTreeNode* frame_tree_node,
268 const FrameNavigationEntry& frame_entry, 268 const FrameNavigationEntry& frame_entry,
269 const NavigationEntryImpl& entry, 269 const NavigationEntryImpl& entry,
270 NavigationController::ReloadType reload_type, 270 NavigationController::ReloadType reload_type,
271 bool is_same_document_history_load, 271 bool is_same_document_history_load,
272 bool is_pending_entry) { 272 bool is_pending_entry,
273 const scoped_refptr<ResourceRequestBody>& post_body) {
273 TRACE_EVENT0("browser,navigation", "NavigatorImpl::NavigateToEntry"); 274 TRACE_EVENT0("browser,navigation", "NavigatorImpl::NavigateToEntry");
274 275
275 GURL dest_url = frame_entry.url(); 276 GURL dest_url = frame_entry.url();
276 Referrer dest_referrer = frame_entry.referrer(); 277 Referrer dest_referrer = frame_entry.referrer();
277 if (reload_type == 278 if (reload_type ==
278 NavigationController::ReloadType::RELOAD_ORIGINAL_REQUEST_URL && 279 NavigationController::ReloadType::RELOAD_ORIGINAL_REQUEST_URL &&
279 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) { 280 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) {
280 // We may have been redirected when navigating to the current URL. 281 // We may have been redirected when navigating to the current URL.
281 // Use the URL the user originally intended to visit, if it's valid and if a 282 // Use the URL the user originally intended to visit, if it's valid and if a
282 // POST wasn't involved; the latter case avoids issues with sending data to 283 // POST wasn't involved; the latter case avoids issues with sending data to
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 is_transfer && 381 is_transfer &&
381 entry.transferred_global_request_id().child_id == 382 entry.transferred_global_request_id().child_id ==
382 dest_render_frame_host->GetProcess()->GetID(); 383 dest_render_frame_host->GetProcess()->GetID();
383 if (!is_transfer_to_same) { 384 if (!is_transfer_to_same) {
384 navigation_data_.reset(new NavigationMetricsData( 385 navigation_data_.reset(new NavigationMetricsData(
385 navigation_start, dest_url, entry.restore_type())); 386 navigation_start, dest_url, entry.restore_type()));
386 // Create the navigation parameters. 387 // Create the navigation parameters.
387 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType( 388 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType(
388 controller_->GetBrowserContext(), entry, reload_type); 389 controller_->GetBrowserContext(), entry, reload_type);
389 dest_render_frame_host->Navigate( 390 dest_render_frame_host->Navigate(
390 entry.ConstructCommonNavigationParams(frame_entry, nullptr, dest_url, 391 entry.ConstructCommonNavigationParams(
391 dest_referrer, navigation_type, 392 frame_entry, post_body, dest_url, dest_referrer, navigation_type,
392 lofi_state, navigation_start), 393 lofi_state, navigation_start),
393 entry.ConstructStartNavigationParams(), 394 entry.ConstructStartNavigationParams(),
394 entry.ConstructRequestNavigationParams( 395 entry.ConstructRequestNavigationParams(
395 frame_entry, is_same_document_history_load, 396 frame_entry, is_same_document_history_load,
396 frame_tree_node->has_committed_real_load(), 397 frame_tree_node->has_committed_real_load(),
397 controller_->GetPendingEntryIndex() == -1, 398 controller_->GetPendingEntryIndex() == -1,
398 controller_->GetIndexOfEntry(&entry), 399 controller_->GetIndexOfEntry(&entry),
399 controller_->GetLastCommittedEntryIndex(), 400 controller_->GetLastCommittedEntryIndex(),
400 controller_->GetEntryCount())); 401 controller_->GetEntryCount()));
401 } else { 402 } else {
402 // No need to navigate again. Just resume the deferred request. 403 // No need to navigate again. Just resume the deferred request.
(...skipping 26 matching lines...) Expand all
429 return true; 430 return true;
430 } 431 }
431 432
432 bool NavigatorImpl::NavigateToPendingEntry( 433 bool NavigatorImpl::NavigateToPendingEntry(
433 FrameTreeNode* frame_tree_node, 434 FrameTreeNode* frame_tree_node,
434 const FrameNavigationEntry& frame_entry, 435 const FrameNavigationEntry& frame_entry,
435 NavigationController::ReloadType reload_type, 436 NavigationController::ReloadType reload_type,
436 bool is_same_document_history_load) { 437 bool is_same_document_history_load) {
437 return NavigateToEntry(frame_tree_node, frame_entry, 438 return NavigateToEntry(frame_tree_node, frame_entry,
438 *controller_->GetPendingEntry(), reload_type, 439 *controller_->GetPendingEntry(), reload_type,
439 is_same_document_history_load, true); 440 is_same_document_history_load, true, nullptr);
440 } 441 }
441 442
442 bool NavigatorImpl::NavigateNewChildFrame( 443 bool NavigatorImpl::NavigateNewChildFrame(
443 RenderFrameHostImpl* render_frame_host, 444 RenderFrameHostImpl* render_frame_host,
444 const std::string& unique_name) { 445 const std::string& unique_name) {
445 NavigationEntryImpl* entry = 446 NavigationEntryImpl* entry =
446 controller_->GetEntryWithUniqueID(render_frame_host->nav_entry_id()); 447 controller_->GetEntryWithUniqueID(render_frame_host->nav_entry_id());
447 if (!entry) 448 if (!entry)
448 return false; 449 return false;
449 450
450 // TODO(creis): Remove unique_name from the IPC, now that we can rely on the 451 // TODO(creis): Remove unique_name from the IPC, now that we can rely on the
451 // replication state. 452 // replication state.
452 DCHECK_EQ(render_frame_host->frame_tree_node()->unique_name(), unique_name); 453 DCHECK_EQ(render_frame_host->frame_tree_node()->unique_name(), unique_name);
453 FrameNavigationEntry* frame_entry = 454 FrameNavigationEntry* frame_entry =
454 entry->GetFrameEntry(render_frame_host->frame_tree_node()); 455 entry->GetFrameEntry(render_frame_host->frame_tree_node());
455 if (!frame_entry) 456 if (!frame_entry)
456 return false; 457 return false;
457 458
458 return NavigateToEntry(render_frame_host->frame_tree_node(), *frame_entry, 459 return NavigateToEntry(render_frame_host->frame_tree_node(), *frame_entry,
459 *entry, NavigationControllerImpl::NO_RELOAD, false, 460 *entry, NavigationControllerImpl::NO_RELOAD, false,
460 false); 461 false, nullptr);
461 } 462 }
462 463
463 void NavigatorImpl::DidNavigate( 464 void NavigatorImpl::DidNavigate(
464 RenderFrameHostImpl* render_frame_host, 465 RenderFrameHostImpl* render_frame_host,
465 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 466 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
466 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree(); 467 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree();
467 bool oopifs_possible = SiteIsolationPolicy::AreCrossProcessFramesPossible(); 468 bool oopifs_possible = SiteIsolationPolicy::AreCrossProcessFramesPossible();
468 469
469 bool has_embedded_credentials = 470 bool has_embedded_credentials =
470 params.url.has_username() || params.url.has_password(); 471 params.url.has_username() || params.url.has_password();
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 } 718 }
718 719
719 void NavigatorImpl::RequestTransferURL( 720 void NavigatorImpl::RequestTransferURL(
720 RenderFrameHostImpl* render_frame_host, 721 RenderFrameHostImpl* render_frame_host,
721 const GURL& url, 722 const GURL& url,
722 SiteInstance* source_site_instance, 723 SiteInstance* source_site_instance,
723 const std::vector<GURL>& redirect_chain, 724 const std::vector<GURL>& redirect_chain,
724 const Referrer& referrer, 725 const Referrer& referrer,
725 ui::PageTransition page_transition, 726 ui::PageTransition page_transition,
726 const GlobalRequestID& transferred_global_request_id, 727 const GlobalRequestID& transferred_global_request_id,
727 bool should_replace_current_entry) { 728 bool should_replace_current_entry,
729 const std::string& method,
730 const scoped_refptr<ResourceRequestBody>& post_body) {
731 // |post_body| should be present for "POST" method and missing otherwise.
732 if (method == "POST")
733 DCHECK(post_body);
734 else
735 DCHECK(!post_body);
736
728 // This call only makes sense for subframes if OOPIFs are possible. 737 // This call only makes sense for subframes if OOPIFs are possible.
729 DCHECK(!render_frame_host->GetParent() || 738 DCHECK(!render_frame_host->GetParent() ||
730 SiteIsolationPolicy::AreCrossProcessFramesPossible()); 739 SiteIsolationPolicy::AreCrossProcessFramesPossible());
731 740
732 // Allow the delegate to cancel the transfer. 741 // Allow the delegate to cancel the transfer.
733 if (!delegate_->ShouldTransferNavigation()) 742 if (!delegate_->ShouldTransferNavigation())
734 return; 743 return;
735 744
736 GURL dest_url(url); 745 GURL dest_url(url);
737 Referrer referrer_to_use(referrer); 746 Referrer referrer_to_use(referrer);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 } else { 790 } else {
782 // If there's no last committed entry, create an entry for about:blank 791 // If there's no last committed entry, create an entry for about:blank
783 // with a subframe entry for our destination. 792 // with a subframe entry for our destination.
784 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208. 793 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208.
785 entry = NavigationEntryImpl::FromNavigationEntry( 794 entry = NavigationEntryImpl::FromNavigationEntry(
786 controller_->CreateNavigationEntry( 795 controller_->CreateNavigationEntry(
787 GURL(url::kAboutBlankURL), referrer_to_use, page_transition, 796 GURL(url::kAboutBlankURL), referrer_to_use, page_transition,
788 is_renderer_initiated, std::string(), 797 is_renderer_initiated, std::string(),
789 controller_->GetBrowserContext())); 798 controller_->GetBrowserContext()));
790 } 799 }
791 // TODO(creis): Handle POST submissions. See https://crbug.com/582211 and
792 // https://crbug.com/101395.
793 entry->AddOrUpdateFrameEntry( 800 entry->AddOrUpdateFrameEntry(
794 node, -1, -1, nullptr, 801 node, -1, -1, nullptr,
795 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, 802 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url,
796 referrer_to_use, PageState(), "GET", -1); 803 referrer_to_use, PageState(), method, -1);
797 } else { 804 } else {
798 // Main frame case. 805 // Main frame case.
799 entry = NavigationEntryImpl::FromNavigationEntry( 806 entry = NavigationEntryImpl::FromNavigationEntry(
800 controller_->CreateNavigationEntry( 807 controller_->CreateNavigationEntry(
801 dest_url, referrer_to_use, page_transition, is_renderer_initiated, 808 dest_url, referrer_to_use, page_transition, is_renderer_initiated,
802 std::string(), controller_->GetBrowserContext())); 809 std::string(), controller_->GetBrowserContext()));
803 entry->root_node()->frame_entry->set_source_site_instance( 810 entry->root_node()->frame_entry->set_source_site_instance(
804 static_cast<SiteInstanceImpl*>(source_site_instance)); 811 static_cast<SiteInstanceImpl*>(source_site_instance));
805 } 812 }
806 813
807 entry->SetRedirectChain(redirect_chain); 814 entry->SetRedirectChain(redirect_chain);
808 // Don't allow an entry replacement if there is no entry to replace. 815 // Don't allow an entry replacement if there is no entry to replace.
809 // http://crbug.com/457149 816 // http://crbug.com/457149
810 if (should_replace_current_entry && controller_->GetEntryCount() > 0) 817 if (should_replace_current_entry && controller_->GetEntryCount() > 0)
811 entry->set_should_replace_entry(true); 818 entry->set_should_replace_entry(true);
812 if (controller_->GetLastCommittedEntry() && 819 if (controller_->GetLastCommittedEntry() &&
813 controller_->GetLastCommittedEntry()->GetIsOverridingUserAgent()) { 820 controller_->GetLastCommittedEntry()->GetIsOverridingUserAgent()) {
814 entry->SetIsOverridingUserAgent(true); 821 entry->SetIsOverridingUserAgent(true);
815 } 822 }
816 entry->set_transferred_global_request_id(transferred_global_request_id); 823 entry->set_transferred_global_request_id(transferred_global_request_id);
817 // TODO(creis): Set user gesture and intent received timestamp on Android. 824 // TODO(creis): Set user gesture and intent received timestamp on Android.
818 825
819 // We may not have successfully added the FrameNavigationEntry to |entry| 826 // We may not have successfully added the FrameNavigationEntry to |entry|
820 // above (per https://crbug.com/608402), in which case we create it from 827 // above (per https://crbug.com/608402), in which case we create it from
821 // scratch. This works because we do not depend on |frame_entry| being inside 828 // scratch. This works because we do not depend on |frame_entry| being inside
822 // |entry| during NavigateToEntry. This will go away when we shortcut this 829 // |entry| during NavigateToEntry. This will go away when we shortcut this
823 // further in https://crbug.com/536906. 830 // further in https://crbug.com/536906.
824 scoped_refptr<FrameNavigationEntry> frame_entry(entry->GetFrameEntry(node)); 831 scoped_refptr<FrameNavigationEntry> frame_entry(entry->GetFrameEntry(node));
825 if (!frame_entry) { 832 if (!frame_entry) {
826 // TODO(creis): Handle POST submissions here, as above.
827 frame_entry = new FrameNavigationEntry( 833 frame_entry = new FrameNavigationEntry(
828 node->unique_name(), -1, -1, nullptr, 834 node->unique_name(), -1, -1, nullptr,
829 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, 835 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url,
830 referrer_to_use, "GET", -1); 836 referrer_to_use, method, -1);
831 } 837 }
832 NavigateToEntry(node, *frame_entry, *entry.get(), 838 NavigateToEntry(node, *frame_entry, *entry.get(),
833 NavigationController::NO_RELOAD, false, false); 839 NavigationController::NO_RELOAD, false, false, post_body);
834 } 840 }
835 841
836 // PlzNavigate 842 // PlzNavigate
837 void NavigatorImpl::OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, 843 void NavigatorImpl::OnBeforeUnloadACK(FrameTreeNode* frame_tree_node,
838 bool proceed) { 844 bool proceed) {
839 CHECK(IsBrowserSideNavigationEnabled()); 845 CHECK(IsBrowserSideNavigationEnabled());
840 DCHECK(frame_tree_node); 846 DCHECK(frame_tree_node);
841 847
842 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); 848 NavigationRequest* navigation_request = frame_tree_node->navigation_request();
843 849
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 if (pending_entry != controller_->GetVisibleEntry() || 1169 if (pending_entry != controller_->GetVisibleEntry() ||
1164 !should_preserve_entry) { 1170 !should_preserve_entry) {
1165 controller_->DiscardPendingEntry(true); 1171 controller_->DiscardPendingEntry(true);
1166 1172
1167 // Also force the UI to refresh. 1173 // Also force the UI to refresh.
1168 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); 1174 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL);
1169 } 1175 }
1170 } 1176 }
1171 1177
1172 } // namespace content 1178 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698