Chromium Code Reviews| 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 4653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4664 // that the load is properly tracked by the WebNavigation API. | 4664 // that the load is properly tracked by the WebNavigation API. |
| 4665 Send(new FrameHostMsg_DidStartProvisionalLoad( | 4665 Send(new FrameHostMsg_DidStartProvisionalLoad( |
| 4666 routing_id_, common_params.url, common_params.navigation_start)); | 4666 routing_id_, common_params.url, common_params.navigation_start)); |
| 4667 | 4667 |
| 4668 // Send the provisional load failure. | 4668 // Send the provisional load failure. |
| 4669 blink::WebURLError error = | 4669 blink::WebURLError error = |
| 4670 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); | 4670 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); |
| 4671 WebURLRequest failed_request = CreateURLRequestForNavigation( | 4671 WebURLRequest failed_request = CreateURLRequestForNavigation( |
| 4672 common_params, std::unique_ptr<StreamOverrideParameters>(), | 4672 common_params, std::unique_ptr<StreamOverrideParameters>(), |
| 4673 frame_->isViewSourceModeEnabled()); | 4673 frame_->isViewSourceModeEnabled()); |
| 4674 failed_request.setBypassBeforeUnload(true); | |
| 4674 SendFailedProvisionalLoad(failed_request, error, frame_); | 4675 SendFailedProvisionalLoad(failed_request, error, frame_); |
| 4675 | 4676 |
| 4676 // This check should have been done on the browser side already. | 4677 // This check should have been done on the browser side already. |
| 4677 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { | 4678 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { |
| 4678 NOTREACHED(); | 4679 NOTREACHED(); |
| 4679 return; | 4680 return; |
| 4680 } | 4681 } |
| 4681 | 4682 |
| 4682 // Make sure errors are not shown in view source mode. | 4683 // Make sure errors are not shown in view source mode. |
| 4683 frame_->enableViewSourceMode(false); | 4684 frame_->enableViewSourceMode(false); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4851 OpenURL(url, Referrer(), info.defaultPolicy, | 4852 OpenURL(url, Referrer(), info.defaultPolicy, |
| 4852 info.replacesCurrentHistoryItem, false); | 4853 info.replacesCurrentHistoryItem, false); |
| 4853 return blink::WebNavigationPolicyIgnore; | 4854 return blink::WebNavigationPolicyIgnore; |
| 4854 } | 4855 } |
| 4855 | 4856 |
| 4856 // PlzNavigate: if the navigation is not synchronous, send it to the browser. | 4857 // PlzNavigate: if the navigation is not synchronous, send it to the browser. |
| 4857 // This includes navigations with no request being sent to the network stack. | 4858 // This includes navigations with no request being sent to the network stack. |
| 4858 if (IsBrowserSideNavigationEnabled() && | 4859 if (IsBrowserSideNavigationEnabled() && |
| 4859 info.urlRequest.checkForBrowserSideNavigation() && | 4860 info.urlRequest.checkForBrowserSideNavigation() && |
| 4860 ShouldMakeNetworkRequestForURL(url)) { | 4861 ShouldMakeNetworkRequestForURL(url)) { |
| 4861 BeginNavigation(&info.urlRequest, info.replacesCurrentHistoryItem, | 4862 // Check if the navigation can be sent to the browser, otherwise ignore it. |
| 4862 info.isClientRedirect); | 4863 bool proceeding_with_navigation = |
| 4863 return blink::WebNavigationPolicyHandledByClient; | 4864 BeginNavigation(&info.urlRequest, info.replacesCurrentHistoryItem, |
| 4865 info.isClientRedirect); | |
| 4866 // DO NOT ADD CODE AFTER THIS FUNCTION. It executes the BeforeUnload event | |
|
nasko
2016/04/15 14:42:22
nit: "AFTER THIS FUNCTION" < The function or funct
| |
| 4867 // for the frame, which may delete the RenderFrameImpl. | |
| 4868 return proceeding_with_navigation | |
| 4869 ? blink::WebNavigationPolicyHandledByClient | |
| 4870 : blink::WebNavigationPolicyIgnore; | |
|
nasko
2016/04/15 14:42:22
Isn't the beforeunload event already invoked befor
clamy
2016/04/15 14:45:54
No it's executed right afterwards (hence why I hav
dcheng
2016/04/15 17:21:42
Hmm, we should try to figure out how to make Blink
clamy
2016/04/25 11:36:55
The problem is that the call to decidePolicyForNav
dcheng
2016/04/26 06:32:31
Hmm, I see the problem, but I think it's awkward t
clamy
2016/04/26 10:07:09
The bit in WebURLRequest is not coming from this p
dcheng
2016/04/27 09:21:29
Part of me thinks that it's weird to expose intern
clamy
2016/04/27 11:29:27
I'm not really sure how OOPIF works here in the cu
dcheng
2016/04/27 13:42:04
I think there should only be one place that runs t
| |
| 4864 } | 4871 } |
| 4865 | 4872 |
| 4866 return info.defaultPolicy; | 4873 return info.defaultPolicy; |
| 4867 } | 4874 } |
| 4868 | 4875 |
| 4869 void RenderFrameImpl::OnGetSavableResourceLinks() { | 4876 void RenderFrameImpl::OnGetSavableResourceLinks() { |
| 4870 std::vector<GURL> resources_list; | 4877 std::vector<GURL> resources_list; |
| 4871 std::vector<SavableSubframe> subframes; | 4878 std::vector<SavableSubframe> subframes; |
| 4872 SavableResourcesResult result(&resources_list, &subframes); | 4879 SavableResourcesResult result(&resources_list, &subframes); |
| 4873 | 4880 |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5284 ? blink::WebFrameLoadType::ReplaceCurrentItem | 5291 ? blink::WebFrameLoadType::ReplaceCurrentItem |
| 5285 : blink::WebFrameLoadType::Standard; | 5292 : blink::WebFrameLoadType::Standard; |
| 5286 blink::WebHistoryLoadType history_load_type = | 5293 blink::WebHistoryLoadType history_load_type = |
| 5287 blink::WebHistoryDifferentDocumentLoad; | 5294 blink::WebHistoryDifferentDocumentLoad; |
| 5288 bool should_load_request = false; | 5295 bool should_load_request = false; |
| 5289 WebHistoryItem item_for_history_navigation; | 5296 WebHistoryItem item_for_history_navigation; |
| 5290 WebURLRequest request = | 5297 WebURLRequest request = |
| 5291 CreateURLRequestForNavigation(common_params, std::move(stream_params), | 5298 CreateURLRequestForNavigation(common_params, std::move(stream_params), |
| 5292 frame_->isViewSourceModeEnabled()); | 5299 frame_->isViewSourceModeEnabled()); |
| 5293 | 5300 |
| 5301 // PlzNavigate: If the navigation made a network request, the BeforeUnload | |
| 5302 // event has already executed. Bypass it when committing the navigation. | |
| 5303 if (IsBrowserSideNavigationEnabled() && | |
| 5304 ShouldMakeNetworkRequestForURL(common_params.url)) { | |
| 5305 request.setBypassBeforeUnload(true); | |
| 5306 } | |
| 5307 | |
| 5294 // Used to determine whether this frame is actually loading a request as part | 5308 // Used to determine whether this frame is actually loading a request as part |
| 5295 // of a history navigation. | 5309 // of a history navigation. |
| 5296 bool has_history_navigation_in_frame = false; | 5310 bool has_history_navigation_in_frame = false; |
| 5297 | 5311 |
| 5298 #if defined(OS_ANDROID) | 5312 #if defined(OS_ANDROID) |
| 5299 request.setHasUserGesture(start_params.has_user_gesture); | 5313 request.setHasUserGesture(start_params.has_user_gesture); |
| 5300 #endif | 5314 #endif |
| 5301 | 5315 |
| 5302 // PlzNavigate: Make sure that Blink's loader will not try to use browser side | 5316 // PlzNavigate: Make sure that Blink's loader will not try to use browser side |
| 5303 // navigation for this request (since it already went to the browser). | 5317 // navigation for this request (since it already went to the browser). |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5590 render_view_->history_list_offset_ = | 5604 render_view_->history_list_offset_ = |
| 5591 request_params.current_history_list_offset; | 5605 request_params.current_history_list_offset; |
| 5592 render_view_->history_list_length_ = | 5606 render_view_->history_list_length_ = |
| 5593 request_params.current_history_list_length; | 5607 request_params.current_history_list_length; |
| 5594 if (request_params.should_clear_history_list) { | 5608 if (request_params.should_clear_history_list) { |
| 5595 CHECK_EQ(-1, render_view_->history_list_offset_); | 5609 CHECK_EQ(-1, render_view_->history_list_offset_); |
| 5596 CHECK_EQ(0, render_view_->history_list_length_); | 5610 CHECK_EQ(0, render_view_->history_list_length_); |
| 5597 } | 5611 } |
| 5598 } | 5612 } |
| 5599 | 5613 |
| 5600 void RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request, | 5614 bool RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request, |
| 5601 bool should_replace_current_entry, | 5615 bool should_replace_current_entry, |
| 5602 bool is_client_redirect) { | 5616 bool is_client_redirect) { |
| 5603 CHECK(IsBrowserSideNavigationEnabled()); | 5617 CHECK(IsBrowserSideNavigationEnabled()); |
| 5604 DCHECK(request); | 5618 DCHECK(request); |
| 5605 // TODO(clamy): Execute the beforeunload event. | 5619 |
| 5620 // Execute the BeforeUnload for main frames, If asked not to proceed, do not | |
| 5621 // send the navigation request to the browser. | |
| 5622 if (!frame_->dispatchBeforeUnloadEvent()) | |
| 5623 return false; | |
| 5606 | 5624 |
| 5607 // Note: At this stage, the goal is to apply all the modifications the | 5625 // Note: At this stage, the goal is to apply all the modifications the |
| 5608 // renderer wants to make to the request, and then send it to the browser, so | 5626 // renderer wants to make to the request, and then send it to the browser, so |
| 5609 // that the actual network request can be started. Ideally, all such | 5627 // that the actual network request can be started. Ideally, all such |
| 5610 // modifications should take place in willSendRequest, and in the | 5628 // modifications should take place in willSendRequest, and in the |
| 5611 // implementation of willSendRequest for the various InspectorAgents | 5629 // implementation of willSendRequest for the various InspectorAgents |
| 5612 // (devtools). | 5630 // (devtools). |
| 5613 // | 5631 // |
| 5614 // TODO(clamy): Apply devtools override. | 5632 // TODO(clamy): Apply devtools override. |
| 5615 // TODO(clamy): Make sure that navigation requests are not modified somewhere | 5633 // TODO(clamy): Make sure that navigation requests are not modified somewhere |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 5646 | 5664 |
| 5647 Send(new FrameHostMsg_BeginNavigation( | 5665 Send(new FrameHostMsg_BeginNavigation( |
| 5648 routing_id_, | 5666 routing_id_, |
| 5649 MakeCommonNavigationParams(request, should_replace_current_entry), | 5667 MakeCommonNavigationParams(request, should_replace_current_entry), |
| 5650 BeginNavigationParams(GetWebURLRequestHeaders(*request), | 5668 BeginNavigationParams(GetWebURLRequestHeaders(*request), |
| 5651 GetLoadFlagsForWebURLRequest(*request), | 5669 GetLoadFlagsForWebURLRequest(*request), |
| 5652 request->hasUserGesture(), | 5670 request->hasUserGesture(), |
| 5653 request->skipServiceWorker(), | 5671 request->skipServiceWorker(), |
| 5654 GetRequestContextTypeForWebURLRequest(*request)), | 5672 GetRequestContextTypeForWebURLRequest(*request)), |
| 5655 GetRequestBodyForWebURLRequest(*request))); | 5673 GetRequestBodyForWebURLRequest(*request))); |
| 5674 return true; | |
| 5656 } | 5675 } |
| 5657 | 5676 |
| 5658 void RenderFrameImpl::LoadDataURL( | 5677 void RenderFrameImpl::LoadDataURL( |
| 5659 const CommonNavigationParams& params, | 5678 const CommonNavigationParams& params, |
| 5660 const RequestNavigationParams& request_params, | 5679 const RequestNavigationParams& request_params, |
| 5661 WebLocalFrame* frame, | 5680 WebLocalFrame* frame, |
| 5662 blink::WebFrameLoadType load_type, | 5681 blink::WebFrameLoadType load_type, |
| 5663 blink::WebHistoryItem item_for_history_navigation, | 5682 blink::WebHistoryItem item_for_history_navigation, |
| 5664 blink::WebHistoryLoadType history_load_type, | 5683 blink::WebHistoryLoadType history_load_type, |
| 5665 bool is_client_redirect) { | 5684 bool is_client_redirect) { |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6037 int match_count, | 6056 int match_count, |
| 6038 int ordinal, | 6057 int ordinal, |
| 6039 const WebRect& selection_rect, | 6058 const WebRect& selection_rect, |
| 6040 bool final_status_update) { | 6059 bool final_status_update) { |
| 6041 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6060 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
| 6042 selection_rect, ordinal, | 6061 selection_rect, ordinal, |
| 6043 final_status_update)); | 6062 final_status_update)); |
| 6044 } | 6063 } |
| 6045 | 6064 |
| 6046 } // namespace content | 6065 } // namespace content |
| OLD | NEW |