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

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: Addressed comments 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/navigation_request.cc
diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc
index 159c6a0357375327207fa92f9940e7bcda8aa0c5..f79963e477ba40bbce36b8c2bab061a6a70879ff 100644
--- a/content/browser/frame_host/navigation_request.cc
+++ b/content/browser/frame_host/navigation_request.cc
@@ -80,20 +80,23 @@ 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.GetPostData();
+ 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
@@ -196,6 +199,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();
Łukasz Anforowicz 2016/05/12 02:53:59 Can you help me understand why we need to make a d
clamy 2016/05/12 08:53:13 I wasn't sure about this so I made a copy to stay
Łukasz Anforowicz 2016/05/12 19:44:12 I think it should be safe not to make a copy - I'v
Charlie Reis 2016/05/16 21:16:41 +1 to removing the deep copy if we can.
clamy 2016/05/19 13:11:57 Done.
}
NavigationRequest::~NavigationRequest() {
@@ -256,6 +262,10 @@ void NavigationRequest::TransferNavigationHandleOwnership(
void NavigationRequest::OnRequestRedirected(
const net::RedirectInfo& redirect_info,
const scoped_refptr<ResourceResponse>& response) {
+ // If the navigation is no longer a POST, the POST data should be reset.
+ if (common_params_.method == "POST" && redirect_info.new_method != "POST")
Łukasz Anforowicz 2016/05/12 02:53:59 Shouldn't the second part of the condition be suff
clamy 2016/05/12 08:53:13 No but I thought it made a bit clearer the case in
Łukasz Anforowicz 2016/05/12 19:44:12 Acknowledged. I don't strongly feel one way or an
Charlie Reis 2016/05/16 21:16:41 I think we should remove the first part (common_pa
+ post_data_ = nullptr;
+
common_params_.url = redirect_info.new_url;
common_params_.method = redirect_info.new_method;
common_params_.referrer.url = GURL(redirect_info.new_referrer);
@@ -421,7 +431,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