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

Unified 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: Extracted a shared NavigationEntryImpl::ConstructResourceRequestBody. 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/navigator_impl.cc
diff --git a/content/browser/frame_host/navigator_impl.cc b/content/browser/frame_host/navigator_impl.cc
index 6fcdb074b4a0f6badd1ea04256214a7e2223480d..fb4ac9b5b56376c429d691a3ccdf12c01b6b8e2f 100644
--- a/content/browser/frame_host/navigator_impl.cc
+++ b/content/browser/frame_host/navigator_impl.cc
@@ -257,7 +257,8 @@ bool NavigatorImpl::NavigateToEntry(
const NavigationEntryImpl& entry,
NavigationController::ReloadType reload_type,
bool is_same_document_history_load,
- bool is_pending_entry) {
+ bool is_pending_entry,
+ const scoped_refptr<ResourceRequestBody>& post_body) {
TRACE_EVENT0("browser,navigation", "NavigatorImpl::NavigateToEntry");
GURL dest_url = frame_entry.url();
@@ -375,10 +376,10 @@ bool NavigatorImpl::NavigateToEntry(
FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType(
controller_->GetBrowserContext(), entry, reload_type);
dest_render_frame_host->Navigate(
- entry.ConstructCommonNavigationParams(dest_url, dest_referrer,
- navigation_type, lofi_state,
- navigation_start),
- entry.ConstructStartNavigationParams(),
+ entry.ConstructCommonNavigationParams(frame_entry.method(), dest_url,
clamy 2016/05/19 16:08:00 In the current code, the method is always GET for
Łukasz Anforowicz 2016/05/19 18:06:59 Oh, I see - this is the concern that you're addres
+ dest_referrer, navigation_type,
+ lofi_state, navigation_start),
+ entry.ConstructStartNavigationParams(post_body),
entry.ConstructRequestNavigationParams(
frame_entry, is_same_document_history_load,
frame_tree_node->has_committed_real_load(),
@@ -424,7 +425,7 @@ bool NavigatorImpl::NavigateToPendingEntry(
bool is_same_document_history_load) {
return NavigateToEntry(frame_tree_node, frame_entry,
*controller_->GetPendingEntry(), reload_type,
- is_same_document_history_load, true);
+ is_same_document_history_load, true, nullptr);
}
bool NavigatorImpl::NavigateNewChildFrame(
@@ -445,7 +446,7 @@ bool NavigatorImpl::NavigateNewChildFrame(
return NavigateToEntry(render_frame_host->frame_tree_node(), *frame_entry,
*entry, NavigationControllerImpl::NO_RELOAD, false,
- false);
+ false, nullptr);
}
void NavigatorImpl::DidNavigate(
@@ -707,11 +708,18 @@ void NavigatorImpl::RequestTransferURL(
const Referrer& referrer,
ui::PageTransition page_transition,
const GlobalRequestID& transferred_global_request_id,
- bool should_replace_current_entry) {
+ bool should_replace_current_entry,
+ const NavigationHandleImpl* transfer_navigation_handle) {
// This call only makes sense for subframes if OOPIFs are possible.
DCHECK(!render_frame_host->GetParent() ||
SiteIsolationPolicy::AreCrossProcessFramesPossible());
+ // Figure out the HTTP method.
+ // TODO(lukasza): Guarantee that |transfer_navigation_handle| is not null (it
+ // is null, when we are called from RenderFrameProxyHost::OnOpenURL).
clamy 2016/05/19 16:08:00 I think it would be better to pass the post data a
Łukasz Anforowicz 2016/05/19 18:06:59 Done. And thanks a lot for the suggestion - it re
+ std::string method =
+ transfer_navigation_handle ? transfer_navigation_handle->method() : "GET";
+
// Allow the delegate to cancel the transfer.
if (!delegate_->ShouldTransferNavigation())
return;
@@ -771,12 +779,11 @@ void NavigatorImpl::RequestTransferURL(
is_renderer_initiated, std::string(),
controller_->GetBrowserContext()));
}
- // TODO(creis): Handle POST submissions. See https://crbug.com/582211 and
- // https://crbug.com/101395.
+ // TODO(lukasza): https://crbug.com/568703: Keep pre-transfer PageState.
entry->AddOrUpdateFrameEntry(
node, -1, -1, nullptr,
static_cast<SiteInstanceImpl*>(source_site_instance), dest_url,
- referrer_to_use, PageState(), "GET", -1);
+ referrer_to_use, PageState(), method, -1);
} else {
// Main frame case.
entry = NavigationEntryImpl::FromNavigationEntry(
@@ -806,14 +813,20 @@ void NavigatorImpl::RequestTransferURL(
// further in https://crbug.com/536906.
scoped_refptr<FrameNavigationEntry> frame_entry(entry->GetFrameEntry(node));
if (!frame_entry) {
- // TODO(creis): Handle POST submissions here, as above.
frame_entry = new FrameNavigationEntry(
node->unique_name(), -1, -1, nullptr,
static_cast<SiteInstanceImpl*>(source_site_instance), dest_url,
- referrer_to_use, "GET", -1);
+ referrer_to_use, method, -1);
}
+
+ // TODO(lukasza): Guarantee that |transfer_navigation_handle| is not null (it
+ // is null, when we are called from RenderFrameProxyHost::OnOpenURL).
+ scoped_refptr<ResourceRequestBody> post_body;
+ if (transfer_navigation_handle)
+ post_body = transfer_navigation_handle->resource_request_body();
+
NavigateToEntry(node, *frame_entry, *entry.get(),
- NavigationController::NO_RELOAD, false, false);
+ NavigationController::NO_RELOAD, false, false, post_body);
}
// PlzNavigate

Powered by Google App Engine
This is Rietveld 408576698