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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
540 common_params.report_type)); | 540 common_params.report_type)); |
541 return request; | 541 return request; |
542 } | 542 } |
543 | 543 |
544 // Converts the HTTP body data stored in ResourceRequestBody format to a | 544 // Converts the HTTP body data stored in ResourceRequestBody format to a |
545 // WebHTTPBody, which is then added to the WebURLRequest. | 545 // WebHTTPBody, which is then added to the WebURLRequest. |
546 // PlzNavigate: used to add the POST data sent by the renderer at commit time | 546 // PlzNavigate: used to add the POST data sent by the renderer at commit time |
547 // to the WebURLRequest used to commit the navigation. This ensures that the | 547 // to the WebURLRequest used to commit the navigation. This ensures that the |
548 // POST data will be in the PageState sent to the browser on commit. | 548 // POST data will be in the PageState sent to the browser on commit. |
549 void AddHTTPBodyToRequest(WebURLRequest* request, | 549 void AddHTTPBodyToRequest(WebURLRequest* request, |
550 scoped_refptr<ResourceRequestBody> body) { | 550 const scoped_refptr<ResourceRequestBody>& body) { |
551 WebHTTPBody http_body; | 551 WebHTTPBody http_body; |
552 http_body.initialize(); | 552 http_body.initialize(); |
553 http_body.setIdentifier(body->identifier()); | 553 http_body.setIdentifier(body->identifier()); |
554 for (const ResourceRequestBody::Element& element : *(body->elements())) { | 554 for (const ResourceRequestBody::Element& element : *(body->elements())) { |
555 long long length = -1; | 555 long long length = -1; |
556 switch (element.type()) { | 556 switch (element.type()) { |
557 case storage::DataElement::TYPE_BYTES: | 557 case storage::DataElement::TYPE_BYTES: |
558 http_body.appendData(WebData(element.bytes(), element.length())); | 558 http_body.appendData(WebData(element.bytes(), element.length())); |
559 break; | 559 break; |
560 case storage::DataElement::TYPE_FILE: | 560 case storage::DataElement::TYPE_FILE: |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
632 static_cast<FrameMsg_UILoadMetricsReportType::Value>( | 632 static_cast<FrameMsg_UILoadMetricsReportType::Value>( |
633 request->inputPerfMetricReportPolicy()); | 633 request->inputPerfMetricReportPolicy()); |
634 | 634 |
635 const RequestExtraData* extra_data = | 635 const RequestExtraData* extra_data = |
636 static_cast<RequestExtraData*>(request->getExtraData()); | 636 static_cast<RequestExtraData*>(request->getExtraData()); |
637 DCHECK(extra_data); | 637 DCHECK(extra_data); |
638 return CommonNavigationParams( | 638 return CommonNavigationParams( |
639 request->url(), referrer, extra_data->transition_type(), | 639 request->url(), referrer, extra_data->transition_type(), |
640 FrameMsg_Navigate_Type::NORMAL, true, should_replace_current_entry, | 640 FrameMsg_Navigate_Type::NORMAL, true, should_replace_current_entry, |
641 ui_timestamp, report_type, GURL(), GURL(), extra_data->lofi_state(), | 641 ui_timestamp, report_type, GURL(), GURL(), extra_data->lofi_state(), |
642 base::TimeTicks::Now(), request->httpMethod().latin1()); | 642 base::TimeTicks::Now(), request->httpMethod().latin1(), |
643 GetRequestBodyForWebURLRequest(*request)); | |
643 } | 644 } |
644 | 645 |
645 media::Context3D GetSharedMainThreadContext3D( | 646 media::Context3D GetSharedMainThreadContext3D( |
646 scoped_refptr<ContextProviderCommandBuffer> provider) { | 647 scoped_refptr<ContextProviderCommandBuffer> provider) { |
647 if (!provider) | 648 if (!provider) |
648 return media::Context3D(); | 649 return media::Context3D(); |
649 return media::Context3D(provider->ContextGL(), provider->GrContext()); | 650 return media::Context3D(provider->ContextGL(), provider->GrContext()); |
650 } | 651 } |
651 | 652 |
652 bool IsReload(FrameMsg_Navigate_Type::Value navigation_type) { | 653 bool IsReload(FrameMsg_Navigate_Type::Value navigation_type) { |
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1581 } | 1582 } |
1582 | 1583 |
1583 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); | 1584 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); |
1584 // Can be NULL in tests. | 1585 // Can be NULL in tests. |
1585 if (render_thread_impl) | 1586 if (render_thread_impl) |
1586 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); | 1587 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); |
1587 DCHECK(!IsBrowserSideNavigationEnabled()); | 1588 DCHECK(!IsBrowserSideNavigationEnabled()); |
1588 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, | 1589 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, |
1589 "url", common_params.url.possibly_invalid_spec()); | 1590 "url", common_params.url.possibly_invalid_spec()); |
1590 NavigateInternal(common_params, start_params, request_params, | 1591 NavigateInternal(common_params, start_params, request_params, |
1591 std::unique_ptr<StreamOverrideParameters>(), nullptr); | 1592 std::unique_ptr<StreamOverrideParameters>()); |
1592 } | 1593 } |
1593 | 1594 |
1594 void RenderFrameImpl::BindServiceRegistry( | 1595 void RenderFrameImpl::BindServiceRegistry( |
1595 shell::mojom::InterfaceProviderRequest services, | 1596 shell::mojom::InterfaceProviderRequest services, |
1596 shell::mojom::InterfaceProviderPtr exposed_services) { | 1597 shell::mojom::InterfaceProviderPtr exposed_services) { |
1597 service_registry_.Bind(std::move(services)); | 1598 service_registry_.Bind(std::move(services)); |
1598 service_registry_.BindRemoteServiceProvider(std::move(exposed_services)); | 1599 service_registry_.BindRemoteServiceProvider(std::move(exposed_services)); |
1599 } | 1600 } |
1600 | 1601 |
1601 ManifestManager* RenderFrameImpl::manifest_manager() { | 1602 ManifestManager* RenderFrameImpl::manifest_manager() { |
(...skipping 3117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4719 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { | 4720 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { |
4720 if (renderer_accessibility()) | 4721 if (renderer_accessibility()) |
4721 renderer_accessibility()->AccessibilityFocusedNodeChanged(node); | 4722 renderer_accessibility()->AccessibilityFocusedNodeChanged(node); |
4722 } | 4723 } |
4723 | 4724 |
4724 // PlzNavigate | 4725 // PlzNavigate |
4725 void RenderFrameImpl::OnCommitNavigation( | 4726 void RenderFrameImpl::OnCommitNavigation( |
4726 const ResourceResponseHead& response, | 4727 const ResourceResponseHead& response, |
4727 const GURL& stream_url, | 4728 const GURL& stream_url, |
4728 const CommonNavigationParams& common_params, | 4729 const CommonNavigationParams& common_params, |
4729 const RequestNavigationParams& request_params, | 4730 const RequestNavigationParams& request_params) { |
4730 scoped_refptr<ResourceRequestBody> post_data) { | |
4731 CHECK(IsBrowserSideNavigationEnabled()); | 4731 CHECK(IsBrowserSideNavigationEnabled()); |
4732 // This will override the url requested by the WebURLLoader, as well as | 4732 // This will override the url requested by the WebURLLoader, as well as |
4733 // provide it with the response to the request. | 4733 // provide it with the response to the request. |
4734 std::unique_ptr<StreamOverrideParameters> stream_override( | 4734 std::unique_ptr<StreamOverrideParameters> stream_override( |
4735 new StreamOverrideParameters()); | 4735 new StreamOverrideParameters()); |
4736 stream_override->stream_url = stream_url; | 4736 stream_override->stream_url = stream_url; |
4737 stream_override->response = response; | 4737 stream_override->response = response; |
4738 | 4738 |
4739 NavigateInternal(common_params, StartNavigationParams(), request_params, | 4739 NavigateInternal(common_params, StartNavigationParams(), request_params, |
4740 std::move(stream_override), post_data); | 4740 std::move(stream_override)); |
4741 } | 4741 } |
4742 | 4742 |
4743 // PlzNavigate | 4743 // PlzNavigate |
4744 void RenderFrameImpl::OnFailedNavigation( | 4744 void RenderFrameImpl::OnFailedNavigation( |
4745 const CommonNavigationParams& common_params, | 4745 const CommonNavigationParams& common_params, |
4746 const RequestNavigationParams& request_params, | 4746 const RequestNavigationParams& request_params, |
4747 bool has_stale_copy_in_cache, | 4747 bool has_stale_copy_in_cache, |
4748 int error_code) { | 4748 int error_code) { |
4749 DCHECK(IsBrowserSideNavigationEnabled()); | 4749 DCHECK(IsBrowserSideNavigationEnabled()); |
4750 bool is_reload = IsReload(common_params.navigation_type); | 4750 bool is_reload = IsReload(common_params.navigation_type); |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5326 params.frame_unique_name = frame_->uniqueName().utf8(); | 5326 params.frame_unique_name = frame_->uniqueName().utf8(); |
5327 } | 5327 } |
5328 | 5328 |
5329 Send(new FrameHostMsg_OpenURL(routing_id_, params)); | 5329 Send(new FrameHostMsg_OpenURL(routing_id_, params)); |
5330 } | 5330 } |
5331 | 5331 |
5332 void RenderFrameImpl::NavigateInternal( | 5332 void RenderFrameImpl::NavigateInternal( |
5333 const CommonNavigationParams& common_params, | 5333 const CommonNavigationParams& common_params, |
5334 const StartNavigationParams& start_params, | 5334 const StartNavigationParams& start_params, |
5335 const RequestNavigationParams& request_params, | 5335 const RequestNavigationParams& request_params, |
5336 std::unique_ptr<StreamOverrideParameters> stream_params, | 5336 std::unique_ptr<StreamOverrideParameters> stream_params) { |
5337 scoped_refptr<ResourceRequestBody> post_data) { | |
5338 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); | 5337 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); |
5339 | 5338 |
5340 // Lower bound for browser initiated navigation start time. | 5339 // Lower bound for browser initiated navigation start time. |
5341 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); | 5340 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); |
5342 bool is_reload = IsReload(common_params.navigation_type); | 5341 bool is_reload = IsReload(common_params.navigation_type); |
5343 bool is_history_navigation = request_params.page_state.IsValid(); | 5342 bool is_history_navigation = request_params.page_state.IsValid(); |
5344 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; | 5343 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; |
5345 RenderFrameImpl::PrepareRenderViewForNavigation( | 5344 RenderFrameImpl::PrepareRenderViewForNavigation( |
5346 common_params.url, request_params); | 5345 common_params.url, request_params); |
5347 | 5346 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5388 ? blink::WebFrameLoadType::ReplaceCurrentItem | 5387 ? blink::WebFrameLoadType::ReplaceCurrentItem |
5389 : blink::WebFrameLoadType::Standard; | 5388 : blink::WebFrameLoadType::Standard; |
5390 blink::WebHistoryLoadType history_load_type = | 5389 blink::WebHistoryLoadType history_load_type = |
5391 blink::WebHistoryDifferentDocumentLoad; | 5390 blink::WebHistoryDifferentDocumentLoad; |
5392 bool should_load_request = false; | 5391 bool should_load_request = false; |
5393 WebHistoryItem item_for_history_navigation; | 5392 WebHistoryItem item_for_history_navigation; |
5394 WebURLRequest request = | 5393 WebURLRequest request = |
5395 CreateURLRequestForNavigation(common_params, std::move(stream_params), | 5394 CreateURLRequestForNavigation(common_params, std::move(stream_params), |
5396 frame_->isViewSourceModeEnabled()); | 5395 frame_->isViewSourceModeEnabled()); |
5397 | 5396 |
5398 if (IsBrowserSideNavigationEnabled() && post_data) | 5397 if (IsBrowserSideNavigationEnabled() && common_params.post_data) |
5399 AddHTTPBodyToRequest(&request, post_data); | 5398 AddHTTPBodyToRequest(&request, common_params.post_data); |
5400 | 5399 |
5401 // Used to determine whether this frame is actually loading a request as part | 5400 // Used to determine whether this frame is actually loading a request as part |
5402 // of a history navigation. | 5401 // of a history navigation. |
5403 bool has_history_navigation_in_frame = false; | 5402 bool has_history_navigation_in_frame = false; |
5404 | 5403 |
5405 #if defined(OS_ANDROID) | 5404 #if defined(OS_ANDROID) |
5406 request.setHasUserGesture(start_params.has_user_gesture); | 5405 request.setHasUserGesture(start_params.has_user_gesture); |
5407 #endif | 5406 #endif |
5408 | 5407 |
5409 // PlzNavigate: Make sure that Blink's loader will not try to use browser side | 5408 // PlzNavigate: Make sure that Blink's loader will not try to use browser side |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5480 if (!start_params.extra_headers.empty() && !browser_side_navigation) { | 5479 if (!start_params.extra_headers.empty() && !browser_side_navigation) { |
5481 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(), | 5480 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(), |
5482 start_params.extra_headers.end(), | 5481 start_params.extra_headers.end(), |
5483 "\n"); | 5482 "\n"); |
5484 i.GetNext();) { | 5483 i.GetNext();) { |
5485 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), | 5484 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), |
5486 WebString::fromUTF8(i.values())); | 5485 WebString::fromUTF8(i.values())); |
5487 } | 5486 } |
5488 } | 5487 } |
5489 | 5488 |
5490 if (common_params.method == "POST" && !browser_side_navigation) { | |
5491 // Set post data. | |
5492 WebHTTPBody http_body; | |
5493 http_body.initialize(); | |
5494 const char* data = nullptr; | |
5495 if (start_params.browser_initiated_post_data.size()) { | |
5496 data = reinterpret_cast<const char*>( | |
5497 &start_params.browser_initiated_post_data.front()); | |
5498 } | |
5499 http_body.appendData( | |
5500 WebData(data, start_params.browser_initiated_post_data.size())); | |
5501 request.setHTTPBody(http_body); | |
5502 } | |
5503 | |
5504 // A session history navigation should have been accompanied by state. | 5489 // A session history navigation should have been accompanied by state. |
5505 CHECK_EQ(request_params.page_id, -1); | 5490 CHECK_EQ(request_params.page_id, -1); |
5506 | 5491 |
5507 should_load_request = true; | 5492 should_load_request = true; |
5508 } | 5493 } |
5509 | 5494 |
5495 if (common_params.method == "POST" && !browser_side_navigation && | |
5496 common_params.post_data) { | |
5497 AddHTTPBodyToRequest(&request, common_params.post_data); | |
clamy
2016/05/23 16:59:28
What happens in the reload/history navigation case
Łukasz Anforowicz
2016/05/23 18:38:47
You're right - we should only add common_params.po
Charlie Reis
2016/05/23 19:07:26
Thanks, looks right to me.
clamy
2016/05/24 11:46:35
Thanks lgtm too. My comment in the other CL was re
| |
5498 } | |
5499 | |
5510 if (should_load_request) { | 5500 if (should_load_request) { |
5511 // Sanitize navigation start now that we know the load_type. | 5501 // Sanitize navigation start now that we know the load_type. |
5512 pending_navigation_params_->common_params.navigation_start = | 5502 pending_navigation_params_->common_params.navigation_start = |
5513 SanitizeNavigationTiming(load_type, common_params.navigation_start, | 5503 SanitizeNavigationTiming(load_type, common_params.navigation_start, |
5514 renderer_navigation_start); | 5504 renderer_navigation_start); |
5515 | 5505 |
5516 // PlzNavigate: check if the navigation being committed originated as a | 5506 // PlzNavigate: check if the navigation being committed originated as a |
5517 // client redirect. | 5507 // client redirect. |
5518 bool is_client_redirect = | 5508 bool is_client_redirect = |
5519 browser_side_navigation | 5509 browser_side_navigation |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5750 GetRequestContextFrameTypeForWebURLRequest(*request) == | 5740 GetRequestContextFrameTypeForWebURLRequest(*request) == |
5751 REQUEST_CONTEXT_FRAME_TYPE_NESTED); | 5741 REQUEST_CONTEXT_FRAME_TYPE_NESTED); |
5752 | 5742 |
5753 Send(new FrameHostMsg_BeginNavigation( | 5743 Send(new FrameHostMsg_BeginNavigation( |
5754 routing_id_, | 5744 routing_id_, |
5755 MakeCommonNavigationParams(request, should_replace_current_entry), | 5745 MakeCommonNavigationParams(request, should_replace_current_entry), |
5756 BeginNavigationParams(GetWebURLRequestHeaders(*request), | 5746 BeginNavigationParams(GetWebURLRequestHeaders(*request), |
5757 GetLoadFlagsForWebURLRequest(*request), | 5747 GetLoadFlagsForWebURLRequest(*request), |
5758 request->hasUserGesture(), | 5748 request->hasUserGesture(), |
5759 request->skipServiceWorker(), | 5749 request->skipServiceWorker(), |
5760 GetRequestContextTypeForWebURLRequest(*request)), | 5750 GetRequestContextTypeForWebURLRequest(*request)))); |
5761 GetRequestBodyForWebURLRequest(*request))); | |
5762 } | 5751 } |
5763 | 5752 |
5764 void RenderFrameImpl::LoadDataURL( | 5753 void RenderFrameImpl::LoadDataURL( |
5765 const CommonNavigationParams& params, | 5754 const CommonNavigationParams& params, |
5766 const RequestNavigationParams& request_params, | 5755 const RequestNavigationParams& request_params, |
5767 WebLocalFrame* frame, | 5756 WebLocalFrame* frame, |
5768 blink::WebFrameLoadType load_type, | 5757 blink::WebFrameLoadType load_type, |
5769 blink::WebHistoryItem item_for_history_navigation, | 5758 blink::WebHistoryItem item_for_history_navigation, |
5770 blink::WebHistoryLoadType history_load_type, | 5759 blink::WebHistoryLoadType history_load_type, |
5771 bool is_client_redirect) { | 5760 bool is_client_redirect) { |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6204 // event target. Potentially a Pepper plugin will receive the event. | 6193 // event target. Potentially a Pepper plugin will receive the event. |
6205 // In order to tell whether a plugin gets the last mouse event and which it | 6194 // In order to tell whether a plugin gets the last mouse event and which it |
6206 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6195 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6207 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6196 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6208 // |pepper_last_mouse_event_target_|. | 6197 // |pepper_last_mouse_event_target_|. |
6209 pepper_last_mouse_event_target_ = nullptr; | 6198 pepper_last_mouse_event_target_ = nullptr; |
6210 #endif | 6199 #endif |
6211 } | 6200 } |
6212 | 6201 |
6213 } // namespace content | 6202 } // namespace content |
OLD | NEW |