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

Unified Diff: content/browser/frame_host/navigation_request.cc

Issue 1907443006: PlzNavigate: store POST data in the FrameNavigationEntry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/navigation_request.cc
diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc
index 1139604533b8c68a1d9239703294f9edc0664e5f..021bcd0b80911ef33805aa266ed87f52d156f329 100644
--- a/content/browser/frame_host/navigation_request.cc
+++ b/content/browser/frame_host/navigation_request.cc
@@ -80,20 +80,24 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated(
headers.SetHeaderIfMissing(net::HttpRequestHeaders::kUserAgent,
GetContentClient()->GetUserAgent());
- // Fill POST data from the browser in the request body.
+ // Fill POST data in the request body.
scoped_refptr<ResourceRequestBody> request_body;
- if (entry.GetHasPostData()) {
- request_body = new ResourceRequestBody();
- request_body->AppendBytes(
- reinterpret_cast<const char *>(
- entry.GetBrowserInitiatedPostData()->front()),
- entry.GetBrowserInitiatedPostData()->size());
+ if (frame_entry.method() == "POST") {
+ request_body =
+ frame_entry.post_data() ? frame_entry.post_data()->MakeCopy() : nullptr;
+ if (!request_body && entry.GetBrowserInitiatedPostData()) {
+ request_body = new ResourceRequestBody();
+ request_body->AppendBytes(
+ reinterpret_cast<const char*>(
+ entry.GetBrowserInitiatedPostData()->front()),
+ entry.GetBrowserInitiatedPostData()->size());
+ }
}
std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest(
frame_tree_node, entry.ConstructCommonNavigationParams(
- dest_url, dest_referrer, navigation_type, lofi_state,
- navigation_start),
+ frame_entry, dest_url, dest_referrer,
+ navigation_type, lofi_state, navigation_start),
BeginNavigationParams(headers.ToString(),
LoadFlagFromNavigationType(navigation_type),
false, // has_user_gestures
@@ -194,6 +198,9 @@ NavigationRequest::NavigationRequest(
common_params, begin_params, first_party_for_cookies,
frame_tree_node->current_origin(), frame_tree_node->IsMainFrame(),
parent_is_main_frame, frame_tree_node->frame_tree_node_id(), body));
+
+ if (body)
+ post_data_ = body->MakeCopy();
}
NavigationRequest::~NavigationRequest() {
@@ -419,7 +426,7 @@ void NavigationRequest::CommitNavigation() {
TransferNavigationHandleOwnership(render_frame_host);
render_frame_host->CommitNavigation(response_.get(), std::move(body_),
common_params_, request_params_,
- is_view_source_);
+ is_view_source_, post_data_);
// When navigating to a Javascript url, the NavigationRequest is not stored
// in the FrameTreeNode. Therefore do not reset it, as this could cancel an

Powered by Google App Engine
This is Rietveld 408576698