| 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/browser/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 | 917 |
| 918 // Called when the renderer navigates. For every frame loaded, we'll get this | 918 // Called when the renderer navigates. For every frame loaded, we'll get this |
| 919 // notification containing parameters identifying the navigation. | 919 // notification containing parameters identifying the navigation. |
| 920 // | 920 // |
| 921 // Subframes are identified by the page transition type. For subframes loaded | 921 // Subframes are identified by the page transition type. For subframes loaded |
| 922 // as part of a wider page load, the page_id will be the same as for the top | 922 // as part of a wider page load, the page_id will be the same as for the top |
| 923 // level frame. If the user explicitly requests a subframe navigation, we will | 923 // level frame. If the user explicitly requests a subframe navigation, we will |
| 924 // get a new page_id because we need to create a new navigation entry for that | 924 // get a new page_id because we need to create a new navigation entry for that |
| 925 // action. | 925 // action. |
| 926 void RenderFrameHostImpl::OnDidCommitProvisionalLoad(const IPC::Message& msg) { | 926 void RenderFrameHostImpl::OnDidCommitProvisionalLoad(const IPC::Message& msg) { |
| 927 LOG(ERROR) |
| 928 << "RenderFrameHostImpl::OnDidCommitProvisionalLoad frame_tree_node_id: " |
| 929 << frame_tree_node()->frame_tree_node_id(); |
| 927 RenderProcessHost* process = GetProcess(); | 930 RenderProcessHost* process = GetProcess(); |
| 928 | 931 |
| 929 // Read the parameters out of the IPC message directly to avoid making another | 932 // Read the parameters out of the IPC message directly to avoid making another |
| 930 // copy when we filter the URLs. | 933 // copy when we filter the URLs. |
| 931 base::PickleIterator iter(msg); | 934 base::PickleIterator iter(msg); |
| 932 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; | 935 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; |
| 933 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: | 936 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: |
| 934 Read(&msg, &iter, &validated_params)) { | 937 Read(&msg, &iter, &validated_params)) { |
| 935 bad_message::ReceivedBadMessage( | 938 bad_message::ReceivedBadMessage( |
| 936 process, bad_message::RFH_COMMIT_DESERIALIZATION_FAILED); | 939 process, bad_message::RFH_COMMIT_DESERIALIZATION_FAILED); |
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2009 } | 2012 } |
| 2010 | 2013 |
| 2011 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { | 2014 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { |
| 2012 DCHECK(data_url.SchemeIs(url::kDataScheme)); | 2015 DCHECK(data_url.SchemeIs(url::kDataScheme)); |
| 2013 CommonNavigationParams common_params( | 2016 CommonNavigationParams common_params( |
| 2014 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, | 2017 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, |
| 2015 FrameMsg_Navigate_Type::NORMAL, false, false, base::TimeTicks::Now(), | 2018 FrameMsg_Navigate_Type::NORMAL, false, false, base::TimeTicks::Now(), |
| 2016 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL(), LOFI_OFF, | 2019 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL(), LOFI_OFF, |
| 2017 base::TimeTicks::Now(), "GET"); | 2020 base::TimeTicks::Now(), "GET"); |
| 2018 if (IsBrowserSideNavigationEnabled()) { | 2021 if (IsBrowserSideNavigationEnabled()) { |
| 2019 CommitNavigation(nullptr, nullptr, common_params, | 2022 CommitNavigation(nullptr, common_params, RequestNavigationParams(), |
| 2020 RequestNavigationParams()); | 2023 mojo::ScopedDataPipeConsumerHandle(), -1); |
| 2021 } else { | 2024 } else { |
| 2022 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); | 2025 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); |
| 2023 } | 2026 } |
| 2024 } | 2027 } |
| 2025 | 2028 |
| 2026 void RenderFrameHostImpl::OpenURL(const FrameHostMsg_OpenURL_Params& params, | 2029 void RenderFrameHostImpl::OpenURL(const FrameHostMsg_OpenURL_Params& params, |
| 2027 SiteInstance* source_site_instance) { | 2030 SiteInstance* source_site_instance) { |
| 2028 GURL validated_url(params.url); | 2031 GURL validated_url(params.url); |
| 2029 GetProcess()->FilterURL(false, &validated_url); | 2032 GetProcess()->FilterURL(false, &validated_url); |
| 2030 | 2033 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2138 // correctly while waiting for a response. | 2141 // correctly while waiting for a response. |
| 2139 if (is_waiting && dialog_was_suppressed) { | 2142 if (is_waiting && dialog_was_suppressed) { |
| 2140 render_view_host_->GetWidget()->delegate()->RendererUnresponsive( | 2143 render_view_host_->GetWidget()->delegate()->RendererUnresponsive( |
| 2141 render_view_host_->GetWidget()); | 2144 render_view_host_->GetWidget()); |
| 2142 } | 2145 } |
| 2143 } | 2146 } |
| 2144 | 2147 |
| 2145 // PlzNavigate | 2148 // PlzNavigate |
| 2146 void RenderFrameHostImpl::CommitNavigation( | 2149 void RenderFrameHostImpl::CommitNavigation( |
| 2147 ResourceResponse* response, | 2150 ResourceResponse* response, |
| 2148 scoped_ptr<StreamHandle> body, | |
| 2149 const CommonNavigationParams& common_params, | 2151 const CommonNavigationParams& common_params, |
| 2150 const RequestNavigationParams& request_params) { | 2152 const RequestNavigationParams& request_params, |
| 2151 DCHECK((response && body.get()) || | 2153 // TODO(carlosk): these default parameters are a hack and has to go away. |
| 2152 !ShouldMakeNetworkRequestForURL(common_params.url)); | 2154 mojo::ScopedDataPipeConsumerHandle data_consumer_handle = |
| 2155 mojo::ScopedDataPipeConsumerHandle(), |
| 2156 int request_id = -1) { |
| 2157 DCHECK((response && data_consumer_handle.is_valid()) || |
| 2158 !ShouldMakeNetworkRequestForURL(common_params.url)); |
| 2153 UpdatePermissionsForNavigation(common_params, request_params); | 2159 UpdatePermissionsForNavigation(common_params, request_params); |
| 2154 | 2160 |
| 2155 // Get back to a clean state, in case we start a new navigation without | 2161 // Get back to a clean state, in case we start a new navigation without |
| 2156 // completing a RFH swap or unload handler. | 2162 // completing a RFH swap or unload handler. |
| 2157 SetState(RenderFrameHostImpl::STATE_DEFAULT); | 2163 SetState(RenderFrameHostImpl::STATE_DEFAULT); |
| 2158 | 2164 |
| 2159 const GURL body_url = body.get() ? body->GetURL() : GURL(); | 2165 // Sends the consumer data handle to the renderer via Mojo. |
| 2166 // TODO(carlosk): See if there's a way to bind the server earlier then this |
| 2167 // so that we don't have to wait for the binding to commit. Is there a |
| 2168 // notification received by the browser that a RenderFrame was created on the |
| 2169 // renderer? |
| 2170 // TODO(carlosk): possibly store the server reference somewhere. Is that even |
| 2171 // needed or is Mojo smart about caching bound remote references? |
| 2172 int32_t current_commit_id = -1; |
| 2173 if (data_consumer_handle.is_valid()) { |
| 2174 static int32_t commit_id = 0; |
| 2175 DataPipeConsumerHandleReceiverPtr consumer_receiver; |
| 2176 GetServiceRegistry()->ConnectToRemoteService( |
| 2177 mojo::GetProxy(&consumer_receiver)); |
| 2178 current_commit_id = ++commit_id; |
| 2179 consumer_receiver->ReceiveDataPipeConsumerHandle( |
| 2180 std::move(data_consumer_handle), request_id, current_commit_id); |
| 2181 } |
| 2182 |
| 2160 const ResourceResponseHead head = response ? | 2183 const ResourceResponseHead head = response ? |
| 2161 response->head : ResourceResponseHead(); | 2184 response->head : ResourceResponseHead(); |
| 2162 Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params, | 2185 Send(new FrameMsg_CommitNavigation(routing_id_, head, GURL(), common_params, |
| 2163 request_params)); | 2186 request_params, current_commit_id)); |
| 2164 | |
| 2165 // TODO(clamy): Release the stream handle once the renderer has finished | |
| 2166 // reading it. | |
| 2167 stream_handle_ = std::move(body); | |
| 2168 | 2187 |
| 2169 // When navigating to a Javascript url, no commit is expected from the | 2188 // When navigating to a Javascript url, no commit is expected from the |
| 2170 // RenderFrameHost, nor should the throbber start. The NavigationRequest is | 2189 // RenderFrameHost, nor should the throbber start. The NavigationRequest is |
| 2171 // also not stored in the FrameTreeNode. Therefore do not reset it, as this | 2190 // also not stored in the FrameTreeNode. Therefore do not reset it, as this |
| 2172 // could cancel an existing pending navigation. | 2191 // could cancel an existing pending navigation. |
| 2173 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) { | 2192 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) { |
| 2174 pending_commit_ = true; | 2193 pending_commit_ = true; |
| 2175 is_loading_ = true; | 2194 is_loading_ = true; |
| 2176 frame_tree_node_->ResetNavigationRequest(true); | 2195 frame_tree_node_->ResetNavigationRequest(true); |
| 2177 } | 2196 } |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2706 FrameTreeNode* focused_frame_tree_node = frame_tree_->GetFocusedFrame(); | 2725 FrameTreeNode* focused_frame_tree_node = frame_tree_->GetFocusedFrame(); |
| 2707 if (!focused_frame_tree_node) | 2726 if (!focused_frame_tree_node) |
| 2708 return; | 2727 return; |
| 2709 RenderFrameHostImpl* focused_frame = | 2728 RenderFrameHostImpl* focused_frame = |
| 2710 focused_frame_tree_node->current_frame_host(); | 2729 focused_frame_tree_node->current_frame_host(); |
| 2711 DCHECK(focused_frame); | 2730 DCHECK(focused_frame); |
| 2712 dst->focused_tree_id = focused_frame->GetAXTreeID(); | 2731 dst->focused_tree_id = focused_frame->GetAXTreeID(); |
| 2713 } | 2732 } |
| 2714 | 2733 |
| 2715 } // namespace content | 2734 } // namespace content |
| OLD | NEW |