Index: content/renderer/render_frame_impl.cc |
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc |
index 8b82079aa7bc60fc6c74c3f5b813b6145973f607..61d415802ba8c4be02f61edcf8da0266b08b33cf 100644 |
--- a/content/renderer/render_frame_impl.cc |
+++ b/content/renderer/render_frame_impl.cc |
@@ -149,6 +149,7 @@ |
#include "net/base/net_errors.h" |
#include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
#include "net/http/http_util.h" |
+#include "storage/common/data_element.h" |
#include "third_party/WebKit/public/platform/URLConversion.h" |
#include "third_party/WebKit/public/platform/WebCachePolicy.h" |
#include "third_party/WebKit/public/platform/WebData.h" |
@@ -540,6 +541,38 @@ WebURLRequest CreateURLRequestForNavigation( |
return request; |
} |
+void AddHTTPBodyToRequest(WebURLRequest* request, |
+ scoped_refptr<ResourceRequestBody> body) { |
+ WebHTTPBody http_body; |
+ http_body.initialize(); |
+ http_body.setIdentifier(body->identifier()); |
+ for (auto element : *(body->elements())) { |
+ switch (element.type()) { |
+ case storage::DataElement::TYPE_BYTES: |
+ http_body.appendData(WebData( |
+ reinterpret_cast<const char*>(element.bytes()), element.length())); |
+ break; |
+ case storage::DataElement::TYPE_FILE: |
+ http_body.appendFileRange( |
+ element.path().AsUTF16Unsafe(), element.offset(), element.length(), |
+ element.expected_modification_time().ToDoubleT()); |
+ break; |
+ case storage::DataElement::TYPE_FILE_FILESYSTEM: |
+ http_body.appendFileSystemURLRange( |
+ element.filesystem_url(), element.offset(), element.length(), |
+ element.expected_modification_time().ToDoubleT()); |
+ break; |
+ case storage::DataElement::TYPE_BLOB: |
+ http_body.appendBlob(WebString::fromUTF8(element.blob_uuid())); |
+ break; |
+ default: |
+ NOTREACHED(); |
+ break; |
+ } |
+ } |
+ request->setHTTPBody(http_body); |
+} |
+ |
// Sanitizes the navigation_start timestamp for browser-initiated navigations, |
// where the browser possibly has a better notion of start time than the |
// renderer. In the case of cross-process navigations, this carries over the |
@@ -1486,7 +1519,7 @@ void RenderFrameImpl::OnNavigate( |
TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, |
"url", common_params.url.possibly_invalid_spec()); |
NavigateInternal(common_params, start_params, request_params, |
- std::unique_ptr<StreamOverrideParameters>()); |
+ std::unique_ptr<StreamOverrideParameters>(), nullptr); |
} |
void RenderFrameImpl::BindServiceRegistry( |
@@ -4623,7 +4656,8 @@ void RenderFrameImpl::OnCommitNavigation( |
const ResourceResponseHead& response, |
const GURL& stream_url, |
const CommonNavigationParams& common_params, |
- const RequestNavigationParams& request_params) { |
+ const RequestNavigationParams& request_params, |
+ scoped_refptr<ResourceRequestBody> post_data) { |
CHECK(IsBrowserSideNavigationEnabled()); |
// This will override the url requested by the WebURLLoader, as well as |
// provide it with the response to the request. |
@@ -4633,7 +4667,7 @@ void RenderFrameImpl::OnCommitNavigation( |
stream_override->response = response; |
NavigateInternal(common_params, StartNavigationParams(), request_params, |
- std::move(stream_override)); |
+ std::move(stream_override), post_data); |
} |
// PlzNavigate |
@@ -5229,7 +5263,8 @@ void RenderFrameImpl::NavigateInternal( |
const CommonNavigationParams& common_params, |
const StartNavigationParams& start_params, |
const RequestNavigationParams& request_params, |
- std::unique_ptr<StreamOverrideParameters> stream_params) { |
+ std::unique_ptr<StreamOverrideParameters> stream_params, |
+ scoped_refptr<ResourceRequestBody> post_data) { |
bool browser_side_navigation = IsBrowserSideNavigationEnabled(); |
// Lower bound for browser initiated navigation start time. |
@@ -5290,6 +5325,9 @@ void RenderFrameImpl::NavigateInternal( |
CreateURLRequestForNavigation(common_params, std::move(stream_params), |
frame_->isViewSourceModeEnabled()); |
+ if (IsBrowserSideNavigationEnabled() && post_data) |
+ AddHTTPBodyToRequest(&request, post_data); |
+ |
// Used to determine whether this frame is actually loading a request as part |
// of a history navigation. |
bool has_history_navigation_in_frame = false; |