| 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 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 | 1509 |
| 1510 void RenderFrameImpl::OnBeforeUnload() { | 1510 void RenderFrameImpl::OnBeforeUnload() { |
| 1511 TRACE_EVENT1("navigation", "RenderFrameImpl::OnBeforeUnload", | 1511 TRACE_EVENT1("navigation", "RenderFrameImpl::OnBeforeUnload", |
| 1512 "id", routing_id_); | 1512 "id", routing_id_); |
| 1513 // TODO(creis): Right now, this is only called on the main frame. Make the | 1513 // TODO(creis): Right now, this is only called on the main frame. Make the |
| 1514 // browser process send dispatchBeforeUnloadEvent to every frame that needs | 1514 // browser process send dispatchBeforeUnloadEvent to every frame that needs |
| 1515 // it. | 1515 // it. |
| 1516 CHECK(!frame_->parent()); | 1516 CHECK(!frame_->parent()); |
| 1517 | 1517 |
| 1518 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); | 1518 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); |
| 1519 bool proceed = frame_->dispatchBeforeUnloadEvent(); | 1519 bool proceed; |
| 1520 if (!frame_->dispatchBeforeUnloadEvent(&proceed)) |
| 1521 return; |
| 1520 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); | 1522 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); |
| 1521 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, | 1523 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, |
| 1522 before_unload_start_time, | 1524 before_unload_start_time, |
| 1523 before_unload_end_time)); | 1525 before_unload_end_time)); |
| 1524 } | 1526 } |
| 1525 | 1527 |
| 1526 void RenderFrameImpl::OnSwapOut( | 1528 void RenderFrameImpl::OnSwapOut( |
| 1527 int proxy_routing_id, | 1529 int proxy_routing_id, |
| 1528 bool is_loading, | 1530 bool is_loading, |
| 1529 const FrameReplicationState& replicated_frame_state) { | 1531 const FrameReplicationState& replicated_frame_state) { |
| (...skipping 3315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4845 // Must be a JavaScript navigation, which appears as "other". | 4847 // Must be a JavaScript navigation, which appears as "other". |
| 4846 info.navigationType == blink::WebNavigationTypeOther; | 4848 info.navigationType == blink::WebNavigationTypeOther; |
| 4847 | 4849 |
| 4848 if (is_fork) { | 4850 if (is_fork) { |
| 4849 // Open the URL via the browser, not via WebKit. | 4851 // Open the URL via the browser, not via WebKit. |
| 4850 OpenURL(url, Referrer(), info.defaultPolicy, | 4852 OpenURL(url, Referrer(), info.defaultPolicy, |
| 4851 info.replacesCurrentHistoryItem, false); | 4853 info.replacesCurrentHistoryItem, false); |
| 4852 return blink::WebNavigationPolicyIgnore; | 4854 return blink::WebNavigationPolicyIgnore; |
| 4853 } | 4855 } |
| 4854 | 4856 |
| 4857 // Execute the BeforeUnload event. If asked not to proceed or the frame is |
| 4858 // destroyed, ignore the navigation. |
| 4859 bool proceed = false; |
| 4860 if (!IsBrowserSideNavigationEnabled() || |
| 4861 info.urlRequest.checkForBrowserSideNavigation()) { |
| 4862 // PlzNavigate: this is not executed when commiting the navigation. |
| 4863 if (!frame_->dispatchBeforeUnloadEvent(&proceed) || !proceed) { |
| 4864 return blink::WebNavigationPolicyIgnore; |
| 4865 } |
| 4866 } |
| 4867 |
| 4855 // PlzNavigate: if the navigation is not synchronous, send it to the browser. | 4868 // PlzNavigate: if the navigation is not synchronous, send it to the browser. |
| 4856 // This includes navigations with no request being sent to the network stack. | 4869 // This includes navigations with no request being sent to the network stack. |
| 4857 if (IsBrowserSideNavigationEnabled() && | 4870 if (IsBrowserSideNavigationEnabled() && |
| 4858 info.urlRequest.checkForBrowserSideNavigation() && | 4871 info.urlRequest.checkForBrowserSideNavigation() && |
| 4859 ShouldMakeNetworkRequestForURL(url)) { | 4872 ShouldMakeNetworkRequestForURL(url)) { |
| 4860 BeginNavigation(&info.urlRequest, info.replacesCurrentHistoryItem, | 4873 BeginNavigation(&info.urlRequest, info.replacesCurrentHistoryItem, |
| 4861 info.isClientRedirect); | 4874 info.isClientRedirect); |
| 4862 return blink::WebNavigationPolicyHandledByClient; | 4875 return blink::WebNavigationPolicyHandledByClient; |
| 4863 } | 4876 } |
| 4864 | 4877 |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5596 CHECK_EQ(-1, render_view_->history_list_offset_); | 5609 CHECK_EQ(-1, render_view_->history_list_offset_); |
| 5597 CHECK_EQ(0, render_view_->history_list_length_); | 5610 CHECK_EQ(0, render_view_->history_list_length_); |
| 5598 } | 5611 } |
| 5599 } | 5612 } |
| 5600 | 5613 |
| 5601 void RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request, | 5614 void RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request, |
| 5602 bool should_replace_current_entry, | 5615 bool should_replace_current_entry, |
| 5603 bool is_client_redirect) { | 5616 bool is_client_redirect) { |
| 5604 CHECK(IsBrowserSideNavigationEnabled()); | 5617 CHECK(IsBrowserSideNavigationEnabled()); |
| 5605 DCHECK(request); | 5618 DCHECK(request); |
| 5606 // TODO(clamy): Execute the beforeunload event. | |
| 5607 | 5619 |
| 5608 // Note: At this stage, the goal is to apply all the modifications the | 5620 // Note: At this stage, the goal is to apply all the modifications the |
| 5609 // renderer wants to make to the request, and then send it to the browser, so | 5621 // renderer wants to make to the request, and then send it to the browser, so |
| 5610 // that the actual network request can be started. Ideally, all such | 5622 // that the actual network request can be started. Ideally, all such |
| 5611 // modifications should take place in willSendRequest, and in the | 5623 // modifications should take place in willSendRequest, and in the |
| 5612 // implementation of willSendRequest for the various InspectorAgents | 5624 // implementation of willSendRequest for the various InspectorAgents |
| 5613 // (devtools). | 5625 // (devtools). |
| 5614 // | 5626 // |
| 5615 // TODO(clamy): Apply devtools override. | 5627 // TODO(clamy): Apply devtools override. |
| 5616 // TODO(clamy): Make sure that navigation requests are not modified somewhere | 5628 // TODO(clamy): Make sure that navigation requests are not modified somewhere |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6038 int match_count, | 6050 int match_count, |
| 6039 int ordinal, | 6051 int ordinal, |
| 6040 const WebRect& selection_rect, | 6052 const WebRect& selection_rect, |
| 6041 bool final_status_update) { | 6053 bool final_status_update) { |
| 6042 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6054 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
| 6043 selection_rect, ordinal, | 6055 selection_rect, ordinal, |
| 6044 final_status_update)); | 6056 final_status_update)); |
| 6045 } | 6057 } |
| 6046 | 6058 |
| 6047 } // namespace content | 6059 } // namespace content |
| OLD | NEW |