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

Side by Side 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, 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/navigation_request.h" 5 #include "content/browser/frame_host/navigation_request.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "content/browser/devtools/render_frame_devtools_agent_host.h" 9 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
10 #include "content/browser/frame_host/frame_tree.h" 10 #include "content/browser/frame_host/frame_tree.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 bool is_same_document_history_load, 73 bool is_same_document_history_load,
74 const base::TimeTicks& navigation_start, 74 const base::TimeTicks& navigation_start,
75 NavigationControllerImpl* controller) { 75 NavigationControllerImpl* controller) {
76 // Copy existing headers and add necessary headers that may not be present 76 // Copy existing headers and add necessary headers that may not be present
77 // in the RequestNavigationParams. 77 // in the RequestNavigationParams.
78 net::HttpRequestHeaders headers; 78 net::HttpRequestHeaders headers;
79 headers.AddHeadersFromString(entry.extra_headers()); 79 headers.AddHeadersFromString(entry.extra_headers());
80 headers.SetHeaderIfMissing(net::HttpRequestHeaders::kUserAgent, 80 headers.SetHeaderIfMissing(net::HttpRequestHeaders::kUserAgent,
81 GetContentClient()->GetUserAgent()); 81 GetContentClient()->GetUserAgent());
82 82
83 // Fill POST data from the browser in the request body. 83 // Fill POST data in the request body.
84 scoped_refptr<ResourceRequestBody> request_body; 84 scoped_refptr<ResourceRequestBody> request_body;
85 if (entry.GetHasPostData()) { 85 if (frame_entry.method() == "POST") {
86 request_body = new ResourceRequestBody(); 86 request_body =
87 request_body->AppendBytes( 87 frame_entry.post_data() ? frame_entry.post_data()->MakeCopy() : nullptr;
88 reinterpret_cast<const char *>( 88 if (!request_body && entry.GetBrowserInitiatedPostData()) {
89 entry.GetBrowserInitiatedPostData()->front()), 89 request_body = new ResourceRequestBody();
90 entry.GetBrowserInitiatedPostData()->size()); 90 request_body->AppendBytes(
91 reinterpret_cast<const char*>(
92 entry.GetBrowserInitiatedPostData()->front()),
93 entry.GetBrowserInitiatedPostData()->size());
94 }
91 } 95 }
92 96
93 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( 97 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest(
94 frame_tree_node, entry.ConstructCommonNavigationParams( 98 frame_tree_node, entry.ConstructCommonNavigationParams(
95 dest_url, dest_referrer, navigation_type, lofi_state, 99 frame_entry, dest_url, dest_referrer,
96 navigation_start), 100 navigation_type, lofi_state, navigation_start),
97 BeginNavigationParams(headers.ToString(), 101 BeginNavigationParams(headers.ToString(),
98 LoadFlagFromNavigationType(navigation_type), 102 LoadFlagFromNavigationType(navigation_type),
99 false, // has_user_gestures 103 false, // has_user_gestures
100 false, // skip_service_worker 104 false, // skip_service_worker
101 REQUEST_CONTEXT_TYPE_LOCATION), 105 REQUEST_CONTEXT_TYPE_LOCATION),
102 entry.ConstructRequestNavigationParams( 106 entry.ConstructRequestNavigationParams(
103 frame_entry, is_same_document_history_load, 107 frame_entry, is_same_document_history_load,
104 frame_tree_node->has_committed_real_load(), 108 frame_tree_node->has_committed_real_load(),
105 controller->GetPendingEntryIndex() == -1, 109 controller->GetPendingEntryIndex() == -1,
106 controller->GetIndexOfEntry(&entry), 110 controller->GetIndexOfEntry(&entry),
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 const GURL& first_party_for_cookies = 191 const GURL& first_party_for_cookies =
188 frame_tree_node->IsMainFrame() 192 frame_tree_node->IsMainFrame()
189 ? common_params.url 193 ? common_params.url
190 : frame_tree_node->frame_tree()->root()->current_url(); 194 : frame_tree_node->frame_tree()->root()->current_url();
191 bool parent_is_main_frame = !frame_tree_node->parent() ? 195 bool parent_is_main_frame = !frame_tree_node->parent() ?
192 false : frame_tree_node->parent()->IsMainFrame(); 196 false : frame_tree_node->parent()->IsMainFrame();
193 info_.reset(new NavigationRequestInfo( 197 info_.reset(new NavigationRequestInfo(
194 common_params, begin_params, first_party_for_cookies, 198 common_params, begin_params, first_party_for_cookies,
195 frame_tree_node->current_origin(), frame_tree_node->IsMainFrame(), 199 frame_tree_node->current_origin(), frame_tree_node->IsMainFrame(),
196 parent_is_main_frame, frame_tree_node->frame_tree_node_id(), body)); 200 parent_is_main_frame, frame_tree_node->frame_tree_node_id(), body));
201
202 if (body)
203 post_data_ = body->MakeCopy();
197 } 204 }
198 205
199 NavigationRequest::~NavigationRequest() { 206 NavigationRequest::~NavigationRequest() {
200 } 207 }
201 208
202 void NavigationRequest::BeginNavigation() { 209 void NavigationRequest::BeginNavigation() {
203 DCHECK(!loader_); 210 DCHECK(!loader_);
204 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE); 211 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE);
205 state_ = STARTED; 212 state_ = STARTED;
206 RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get()); 213 RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get());
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 RenderFrameHostImpl* render_frame_host = 419 RenderFrameHostImpl* render_frame_host =
413 navigation_handle_->GetRenderFrameHost(); 420 navigation_handle_->GetRenderFrameHost();
414 DCHECK(render_frame_host == 421 DCHECK(render_frame_host ==
415 frame_tree_node_->render_manager()->current_frame_host() || 422 frame_tree_node_->render_manager()->current_frame_host() ||
416 render_frame_host == 423 render_frame_host ==
417 frame_tree_node_->render_manager()->speculative_frame_host()); 424 frame_tree_node_->render_manager()->speculative_frame_host());
418 425
419 TransferNavigationHandleOwnership(render_frame_host); 426 TransferNavigationHandleOwnership(render_frame_host);
420 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 427 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
421 common_params_, request_params_, 428 common_params_, request_params_,
422 is_view_source_); 429 is_view_source_, post_data_);
423 430
424 // When navigating to a Javascript url, the NavigationRequest is not stored 431 // When navigating to a Javascript url, the NavigationRequest is not stored
425 // in the FrameTreeNode. Therefore do not reset it, as this could cancel an 432 // in the FrameTreeNode. Therefore do not reset it, as this could cancel an
426 // existing pending navigation. 433 // existing pending navigation.
427 if (!common_params_.url.SchemeIs(url::kJavaScriptScheme)) 434 if (!common_params_.url.SchemeIs(url::kJavaScriptScheme))
428 frame_tree_node_->ResetNavigationRequest(true); 435 frame_tree_node_->ResetNavigationRequest(true);
429 } 436 }
430 437
431 void NavigationRequest::InitializeServiceWorkerHandleIfNeeded() { 438 void NavigationRequest::InitializeServiceWorkerHandleIfNeeded() {
432 // Only initialize the ServiceWorkerNavigationHandle if it can be created for 439 // Only initialize the ServiceWorkerNavigationHandle if it can be created for
(...skipping 19 matching lines...) Expand all
452 browser_context, navigating_frame_host->GetSiteInstance()); 459 browser_context, navigating_frame_host->GetSiteInstance());
453 DCHECK(partition); 460 DCHECK(partition);
454 461
455 ServiceWorkerContextWrapper* service_worker_context = 462 ServiceWorkerContextWrapper* service_worker_context =
456 static_cast<ServiceWorkerContextWrapper*>( 463 static_cast<ServiceWorkerContextWrapper*>(
457 partition->GetServiceWorkerContext()); 464 partition->GetServiceWorkerContext());
458 navigation_handle_->InitServiceWorkerHandle(service_worker_context); 465 navigation_handle_->InitServiceWorkerHandle(service_worker_context);
459 } 466 }
460 467
461 } // namespace content 468 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698