| 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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 difference); | 580 difference); |
| 581 } else { | 581 } else { |
| 582 UMA_HISTOGRAM_TIMES("Navigation.Start.RendererBrowserDifference.Negative", | 582 UMA_HISTOGRAM_TIMES("Navigation.Start.RendererBrowserDifference.Negative", |
| 583 -difference); | 583 -difference); |
| 584 } | 584 } |
| 585 return navigation_start; | 585 return navigation_start; |
| 586 } | 586 } |
| 587 | 587 |
| 588 // PlzNavigate | 588 // PlzNavigate |
| 589 CommonNavigationParams MakeCommonNavigationParams( | 589 CommonNavigationParams MakeCommonNavigationParams( |
| 590 blink::WebURLRequest* request, | 590 const blink::WebFrameClient::NavigationPolicyInfo& info) { |
| 591 bool should_replace_current_entry) { | |
| 592 Referrer referrer( | 591 Referrer referrer( |
| 593 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()), | 592 GURL(info.urlRequest.httpHeaderField( |
| 594 request->referrerPolicy()); | 593 WebString::fromUTF8("Referer")).latin1()), |
| 594 info.urlRequest.referrerPolicy()); |
| 595 | 595 |
| 596 // Set the ui timestamp for this navigation. Currently the timestamp here is | 596 // Set the ui timestamp for this navigation. Currently the timestamp here is |
| 597 // only non empty when the navigation was triggered by an Android intent, or | 597 // only non empty when the navigation was triggered by an Android intent, or |
| 598 // by the user clicking on a link. The timestamp is converted from a double | 598 // by the user clicking on a link. The timestamp is converted from a double |
| 599 // version supported by blink. It will be passed back to the renderer in the | 599 // version supported by blink. It will be passed back to the renderer in the |
| 600 // CommitNavigation IPC, and then back to the browser again in the | 600 // CommitNavigation IPC, and then back to the browser again in the |
| 601 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs. | 601 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs. |
| 602 base::TimeTicks ui_timestamp = | 602 base::TimeTicks ui_timestamp = |
| 603 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime()); | 603 base::TimeTicks() + |
| 604 base::TimeDelta::FromSecondsD(info.urlRequest.uiStartTime()); |
| 604 FrameMsg_UILoadMetricsReportType::Value report_type = | 605 FrameMsg_UILoadMetricsReportType::Value report_type = |
| 605 static_cast<FrameMsg_UILoadMetricsReportType::Value>( | 606 static_cast<FrameMsg_UILoadMetricsReportType::Value>( |
| 606 request->inputPerfMetricReportPolicy()); | 607 info.urlRequest.inputPerfMetricReportPolicy()); |
| 608 |
| 609 FrameMsg_Navigate_Type::Value navigation_type = |
| 610 info.navigationType == blink::WebNavigationTypeReload |
| 611 ? FrameMsg_Navigate_Type::RELOAD |
| 612 : FrameMsg_Navigate_Type::NORMAL; |
| 607 | 613 |
| 608 const RequestExtraData* extra_data = | 614 const RequestExtraData* extra_data = |
| 609 static_cast<RequestExtraData*>(request->getExtraData()); | 615 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); |
| 610 DCHECK(extra_data); | 616 DCHECK(extra_data); |
| 611 return CommonNavigationParams( | 617 return CommonNavigationParams( |
| 612 request->url(), referrer, extra_data->transition_type(), | 618 info.urlRequest.url(), referrer, extra_data->transition_type(), |
| 613 FrameMsg_Navigate_Type::NORMAL, true, should_replace_current_entry, | 619 navigation_type, true, info.replacesCurrentHistoryItem, |
| 614 ui_timestamp, report_type, GURL(), GURL(), extra_data->lofi_state(), | 620 ui_timestamp, report_type, GURL(), GURL(), extra_data->lofi_state(), |
| 615 base::TimeTicks::Now(), request->httpMethod().latin1(), | 621 base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(), |
| 616 GetRequestBodyForWebURLRequest(*request)); | 622 GetRequestBodyForWebURLRequest(info.urlRequest)); |
| 617 } | 623 } |
| 618 | 624 |
| 619 media::Context3D GetSharedMainThreadContext3D( | 625 media::Context3D GetSharedMainThreadContext3D( |
| 620 scoped_refptr<ContextProviderCommandBuffer> provider) { | 626 scoped_refptr<ContextProviderCommandBuffer> provider) { |
| 621 if (!provider) | 627 if (!provider) |
| 622 return media::Context3D(); | 628 return media::Context3D(); |
| 623 return media::Context3D(provider->ContextGL(), provider->GrContext()); | 629 return media::Context3D(provider->ContextGL(), provider->GrContext()); |
| 624 } | 630 } |
| 625 | 631 |
| 626 bool IsReload(FrameMsg_Navigate_Type::Value navigation_type) { | 632 bool IsReload(FrameMsg_Navigate_Type::Value navigation_type) { |
| (...skipping 4430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5057 !weak_self) { | 5063 !weak_self) { |
| 5058 return blink::WebNavigationPolicyIgnore; | 5064 return blink::WebNavigationPolicyIgnore; |
| 5059 } | 5065 } |
| 5060 } | 5066 } |
| 5061 | 5067 |
| 5062 // PlzNavigate: if the navigation is not synchronous, send it to the browser. | 5068 // PlzNavigate: if the navigation is not synchronous, send it to the browser. |
| 5063 // This includes navigations with no request being sent to the network stack. | 5069 // This includes navigations with no request being sent to the network stack. |
| 5064 if (IsBrowserSideNavigationEnabled() && | 5070 if (IsBrowserSideNavigationEnabled() && |
| 5065 info.urlRequest.checkForBrowserSideNavigation() && | 5071 info.urlRequest.checkForBrowserSideNavigation() && |
| 5066 ShouldMakeNetworkRequestForURL(url)) { | 5072 ShouldMakeNetworkRequestForURL(url)) { |
| 5067 BeginNavigation(&info.urlRequest, info.replacesCurrentHistoryItem, | 5073 BeginNavigation(info); |
| 5068 info.isClientRedirect); | |
| 5069 return blink::WebNavigationPolicyHandledByClient; | 5074 return blink::WebNavigationPolicyHandledByClient; |
| 5070 } | 5075 } |
| 5071 | 5076 |
| 5072 return info.defaultPolicy; | 5077 return info.defaultPolicy; |
| 5073 } | 5078 } |
| 5074 | 5079 |
| 5075 void RenderFrameImpl::OnGetSavableResourceLinks() { | 5080 void RenderFrameImpl::OnGetSavableResourceLinks() { |
| 5076 std::vector<GURL> resources_list; | 5081 std::vector<GURL> resources_list; |
| 5077 std::vector<SavableSubframe> subframes; | 5082 std::vector<SavableSubframe> subframes; |
| 5078 SavableResourcesResult result(&resources_list, &subframes); | 5083 SavableResourcesResult result(&resources_list, &subframes); |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5771 render_view_->history_list_offset_ = | 5776 render_view_->history_list_offset_ = |
| 5772 request_params.current_history_list_offset; | 5777 request_params.current_history_list_offset; |
| 5773 render_view_->history_list_length_ = | 5778 render_view_->history_list_length_ = |
| 5774 request_params.current_history_list_length; | 5779 request_params.current_history_list_length; |
| 5775 if (request_params.should_clear_history_list) { | 5780 if (request_params.should_clear_history_list) { |
| 5776 CHECK_EQ(-1, render_view_->history_list_offset_); | 5781 CHECK_EQ(-1, render_view_->history_list_offset_); |
| 5777 CHECK_EQ(0, render_view_->history_list_length_); | 5782 CHECK_EQ(0, render_view_->history_list_length_); |
| 5778 } | 5783 } |
| 5779 } | 5784 } |
| 5780 | 5785 |
| 5781 void RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request, | 5786 void RenderFrameImpl::BeginNavigation(const NavigationPolicyInfo& info) { |
| 5782 bool should_replace_current_entry, | |
| 5783 bool is_client_redirect) { | |
| 5784 CHECK(IsBrowserSideNavigationEnabled()); | 5787 CHECK(IsBrowserSideNavigationEnabled()); |
| 5785 DCHECK(request); | |
| 5786 | 5788 |
| 5787 // Note: At this stage, the goal is to apply all the modifications the | 5789 // Note: At this stage, the goal is to apply all the modifications the |
| 5788 // renderer wants to make to the request, and then send it to the browser, so | 5790 // renderer wants to make to the request, and then send it to the browser, so |
| 5789 // that the actual network request can be started. Ideally, all such | 5791 // that the actual network request can be started. Ideally, all such |
| 5790 // modifications should take place in willSendRequest, and in the | 5792 // modifications should take place in willSendRequest, and in the |
| 5791 // implementation of willSendRequest for the various InspectorAgents | 5793 // implementation of willSendRequest for the various InspectorAgents |
| 5792 // (devtools). | 5794 // (devtools). |
| 5793 // | 5795 // |
| 5794 // TODO(clamy): Apply devtools override. | 5796 // TODO(clamy): Apply devtools override. |
| 5795 // TODO(clamy): Make sure that navigation requests are not modified somewhere | 5797 // TODO(clamy): Make sure that navigation requests are not modified somewhere |
| 5796 // else in blink. | 5798 // else in blink. |
| 5797 willSendRequest(frame_, 0, *request, blink::WebURLResponse()); | 5799 willSendRequest(frame_, 0, info.urlRequest, blink::WebURLResponse()); |
| 5798 | 5800 |
| 5799 // Update the transition type of the request for client side redirects. | 5801 // Update the transition type of the request for client side redirects. |
| 5800 if (!request->getExtraData()) | 5802 if (!info.urlRequest.getExtraData()) |
| 5801 request->setExtraData(new RequestExtraData()); | 5803 info.urlRequest.setExtraData(new RequestExtraData()); |
| 5802 if (is_client_redirect) { | 5804 if (info.isClientRedirect) { |
| 5803 RequestExtraData* extra_data = | 5805 RequestExtraData* extra_data = |
| 5804 static_cast<RequestExtraData*>(request->getExtraData()); | 5806 static_cast<RequestExtraData*>(info.urlRequest.getExtraData()); |
| 5805 extra_data->set_transition_type(ui::PageTransitionFromInt( | 5807 extra_data->set_transition_type(ui::PageTransitionFromInt( |
| 5806 extra_data->transition_type() | ui::PAGE_TRANSITION_CLIENT_REDIRECT)); | 5808 extra_data->transition_type() | ui::PAGE_TRANSITION_CLIENT_REDIRECT)); |
| 5807 } | 5809 } |
| 5808 | 5810 |
| 5809 // TODO(clamy): Same-document navigations should not be sent back to the | 5811 // TODO(clamy): Same-document navigations should not be sent back to the |
| 5810 // browser. | 5812 // browser. |
| 5811 // TODO(clamy): Data urls should not be sent back to the browser either. | 5813 // TODO(clamy): Data urls should not be sent back to the browser either. |
| 5812 // These values are assumed on the browser side for navigations. These checks | 5814 // These values are assumed on the browser side for navigations. These checks |
| 5813 // ensure the renderer has the correct values. | 5815 // ensure the renderer has the correct values. |
| 5814 DCHECK_EQ(FETCH_REQUEST_MODE_NAVIGATE, | 5816 DCHECK_EQ(FETCH_REQUEST_MODE_NAVIGATE, |
| 5815 GetFetchRequestModeForWebURLRequest(*request)); | 5817 GetFetchRequestModeForWebURLRequest(info.urlRequest)); |
| 5816 DCHECK_EQ(FETCH_CREDENTIALS_MODE_INCLUDE, | 5818 DCHECK_EQ(FETCH_CREDENTIALS_MODE_INCLUDE, |
| 5817 GetFetchCredentialsModeForWebURLRequest(*request)); | 5819 GetFetchCredentialsModeForWebURLRequest(info.urlRequest)); |
| 5818 DCHECK(GetFetchRedirectModeForWebURLRequest(*request) == | 5820 DCHECK(GetFetchRedirectModeForWebURLRequest(info.urlRequest) == |
| 5819 FetchRedirectMode::MANUAL_MODE); | 5821 FetchRedirectMode::MANUAL_MODE); |
| 5820 DCHECK(frame_->parent() || | 5822 DCHECK(frame_->parent() || |
| 5821 GetRequestContextFrameTypeForWebURLRequest(*request) == | 5823 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == |
| 5822 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); | 5824 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); |
| 5823 DCHECK(!frame_->parent() || | 5825 DCHECK(!frame_->parent() || |
| 5824 GetRequestContextFrameTypeForWebURLRequest(*request) == | 5826 GetRequestContextFrameTypeForWebURLRequest(info.urlRequest) == |
| 5825 REQUEST_CONTEXT_FRAME_TYPE_NESTED); | 5827 REQUEST_CONTEXT_FRAME_TYPE_NESTED); |
| 5826 | 5828 |
| 5827 Send(new FrameHostMsg_BeginNavigation( | 5829 Send(new FrameHostMsg_BeginNavigation( |
| 5828 routing_id_, | 5830 routing_id_, |
| 5829 MakeCommonNavigationParams(request, should_replace_current_entry), | 5831 MakeCommonNavigationParams(info), |
| 5830 BeginNavigationParams(GetWebURLRequestHeaders(*request), | 5832 BeginNavigationParams( |
| 5831 GetLoadFlagsForWebURLRequest(*request), | 5833 GetWebURLRequestHeaders(info.urlRequest), |
| 5832 request->hasUserGesture(), | 5834 GetLoadFlagsForWebURLRequest(info.urlRequest), |
| 5833 request->skipServiceWorker() != | 5835 info.urlRequest.hasUserGesture(), |
| 5834 blink::WebURLRequest::SkipServiceWorker::None, | 5836 info.urlRequest.skipServiceWorker() != |
| 5835 GetRequestContextTypeForWebURLRequest(*request)))); | 5837 blink::WebURLRequest::SkipServiceWorker::None, |
| 5838 GetRequestContextTypeForWebURLRequest(info.urlRequest)))); |
| 5836 } | 5839 } |
| 5837 | 5840 |
| 5838 void RenderFrameImpl::LoadDataURL( | 5841 void RenderFrameImpl::LoadDataURL( |
| 5839 const CommonNavigationParams& params, | 5842 const CommonNavigationParams& params, |
| 5840 const RequestNavigationParams& request_params, | 5843 const RequestNavigationParams& request_params, |
| 5841 WebLocalFrame* frame, | 5844 WebLocalFrame* frame, |
| 5842 blink::WebFrameLoadType load_type, | 5845 blink::WebFrameLoadType load_type, |
| 5843 blink::WebHistoryItem item_for_history_navigation, | 5846 blink::WebHistoryItem item_for_history_navigation, |
| 5844 blink::WebHistoryLoadType history_load_type, | 5847 blink::WebHistoryLoadType history_load_type, |
| 5845 bool is_client_redirect) { | 5848 bool is_client_redirect) { |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6328 // event target. Potentially a Pepper plugin will receive the event. | 6331 // event target. Potentially a Pepper plugin will receive the event. |
| 6329 // In order to tell whether a plugin gets the last mouse event and which it | 6332 // In order to tell whether a plugin gets the last mouse event and which it |
| 6330 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6333 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6331 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6334 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6332 // |pepper_last_mouse_event_target_|. | 6335 // |pepper_last_mouse_event_target_|. |
| 6333 pepper_last_mouse_event_target_ = nullptr; | 6336 pepper_last_mouse_event_target_ = nullptr; |
| 6334 #endif | 6337 #endif |
| 6335 } | 6338 } |
| 6336 | 6339 |
| 6337 } // namespace content | 6340 } // namespace content |
| OLD | NEW |