OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
539 common_params.report_type)); | 539 common_params.report_type)); |
540 return request; | 540 return request; |
541 } | 541 } |
542 | 542 |
543 // Converts the HTTP body data stored in ResourceRequestBody format to a | 543 // Converts the HTTP body data stored in ResourceRequestBody format to a |
544 // WebHTTPBody, which is then added to the WebURLRequest. | 544 // WebHTTPBody, which is then added to the WebURLRequest. |
545 // PlzNavigate: used to add the POST data sent by the renderer at commit time | 545 // PlzNavigate: used to add the POST data sent by the renderer at commit time |
546 // to the WebURLRequest used to commit the navigation. This ensures that the | 546 // to the WebURLRequest used to commit the navigation. This ensures that the |
547 // POST data will be in the PageState sent to the browser on commit. | 547 // POST data will be in the PageState sent to the browser on commit. |
548 void AddHTTPBodyToRequest(WebURLRequest* request, | 548 void AddHTTPBodyToRequest(WebURLRequest* request, |
549 scoped_refptr<ResourceRequestBody> body) { | 549 const scoped_refptr<ResourceRequestBody>& body) { |
550 WebHTTPBody http_body; | 550 WebHTTPBody http_body; |
551 http_body.initialize(); | 551 http_body.initialize(); |
552 http_body.setIdentifier(body->identifier()); | 552 http_body.setIdentifier(body->identifier()); |
553 for (const ResourceRequestBody::Element& element : *(body->elements())) { | 553 for (const ResourceRequestBody::Element& element : *(body->elements())) { |
554 long long length = -1; | 554 long long length = -1; |
555 switch (element.type()) { | 555 switch (element.type()) { |
556 case storage::DataElement::TYPE_BYTES: | 556 case storage::DataElement::TYPE_BYTES: |
557 http_body.appendData(WebData(element.bytes(), element.length())); | 557 http_body.appendData(WebData(element.bytes(), element.length())); |
558 break; | 558 break; |
559 case storage::DataElement::TYPE_FILE: | 559 case storage::DataElement::TYPE_FILE: |
(...skipping 4703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5263 } | 5263 } |
5264 | 5264 |
5265 Send(new FrameHostMsg_OpenURL(routing_id_, params)); | 5265 Send(new FrameHostMsg_OpenURL(routing_id_, params)); |
5266 } | 5266 } |
5267 | 5267 |
5268 void RenderFrameImpl::NavigateInternal( | 5268 void RenderFrameImpl::NavigateInternal( |
5269 const CommonNavigationParams& common_params, | 5269 const CommonNavigationParams& common_params, |
5270 const StartNavigationParams& start_params, | 5270 const StartNavigationParams& start_params, |
5271 const RequestNavigationParams& request_params, | 5271 const RequestNavigationParams& request_params, |
5272 std::unique_ptr<StreamOverrideParameters> stream_params, | 5272 std::unique_ptr<StreamOverrideParameters> stream_params, |
5273 scoped_refptr<ResourceRequestBody> post_data) { | 5273 scoped_refptr<ResourceRequestBody> post_data) { |
clamy
2016/05/20 15:49:14
Note: moving post_data to the CommonNavigationPara
Łukasz Anforowicz
2016/05/20 22:18:47
Done.
| |
5274 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); | 5274 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); |
5275 | 5275 |
5276 // Lower bound for browser initiated navigation start time. | 5276 // Lower bound for browser initiated navigation start time. |
5277 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); | 5277 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); |
5278 bool is_reload = IsReload(common_params.navigation_type); | 5278 bool is_reload = IsReload(common_params.navigation_type); |
5279 bool is_history_navigation = request_params.page_state.IsValid(); | 5279 bool is_history_navigation = request_params.page_state.IsValid(); |
5280 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; | 5280 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; |
5281 RenderFrameImpl::PrepareRenderViewForNavigation( | 5281 RenderFrameImpl::PrepareRenderViewForNavigation( |
5282 common_params.url, request_params); | 5282 common_params.url, request_params); |
5283 | 5283 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5419 if (!start_params.extra_headers.empty() && !browser_side_navigation) { | 5419 if (!start_params.extra_headers.empty() && !browser_side_navigation) { |
5420 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(), | 5420 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(), |
5421 start_params.extra_headers.end(), | 5421 start_params.extra_headers.end(), |
5422 "\n"); | 5422 "\n"); |
5423 i.GetNext();) { | 5423 i.GetNext();) { |
5424 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), | 5424 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), |
5425 WebString::fromUTF8(i.values())); | 5425 WebString::fromUTF8(i.values())); |
5426 } | 5426 } |
5427 } | 5427 } |
5428 | 5428 |
5429 if (common_params.method == "POST" && !browser_side_navigation) { | 5429 if (common_params.method == "POST" && !browser_side_navigation && |
clamy
2016/05/20 15:49:14
This means that the post data will only be added t
Łukasz Anforowicz
2016/05/20 22:18:47
Done. You're right - now that this handles not on
| |
5430 // Set post data. | 5430 start_params.post_data) { |
5431 WebHTTPBody http_body; | 5431 AddHTTPBodyToRequest(&request, start_params.post_data); |
5432 http_body.initialize(); | |
5433 const char* data = nullptr; | |
5434 if (start_params.browser_initiated_post_data.size()) { | |
5435 data = reinterpret_cast<const char*>( | |
5436 &start_params.browser_initiated_post_data.front()); | |
5437 } | |
5438 http_body.appendData( | |
5439 WebData(data, start_params.browser_initiated_post_data.size())); | |
5440 request.setHTTPBody(http_body); | |
5441 } | 5432 } |
5442 | 5433 |
5443 // A session history navigation should have been accompanied by state. | 5434 // A session history navigation should have been accompanied by state. |
5444 CHECK_EQ(request_params.page_id, -1); | 5435 CHECK_EQ(request_params.page_id, -1); |
5445 | 5436 |
5446 should_load_request = true; | 5437 should_load_request = true; |
5447 } | 5438 } |
5448 | 5439 |
5449 if (should_load_request) { | 5440 if (should_load_request) { |
5450 // Sanitize navigation start now that we know the load_type. | 5441 // Sanitize navigation start now that we know the load_type. |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6141 // event target. Potentially a Pepper plugin will receive the event. | 6132 // event target. Potentially a Pepper plugin will receive the event. |
6142 // In order to tell whether a plugin gets the last mouse event and which it | 6133 // In order to tell whether a plugin gets the last mouse event and which it |
6143 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6134 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6144 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6135 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6145 // |pepper_last_mouse_event_target_|. | 6136 // |pepper_last_mouse_event_target_|. |
6146 pepper_last_mouse_event_target_ = nullptr; | 6137 pepper_last_mouse_event_target_ = nullptr; |
6147 #endif | 6138 #endif |
6148 } | 6139 } |
6149 | 6140 |
6150 } // namespace content | 6141 } // namespace content |
OLD | NEW |