| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 246 |
| 247 DISALLOW_COPY_AND_ASSIGN(RemoterFactoryImpl); | 247 DISALLOW_COPY_AND_ASSIGN(RemoterFactoryImpl); |
| 248 }; | 248 }; |
| 249 #endif // BUILDFLAG(ENABLE_MEDIA_REMOTING) | 249 #endif // BUILDFLAG(ENABLE_MEDIA_REMOTING) |
| 250 | 250 |
| 251 template <typename Interface> | 251 template <typename Interface> |
| 252 void IgnoreInterfaceRequest(mojo::InterfaceRequest<Interface> request) { | 252 void IgnoreInterfaceRequest(mojo::InterfaceRequest<Interface> request) { |
| 253 // Intentionally ignore the interface request. | 253 // Intentionally ignore the interface request. |
| 254 } | 254 } |
| 255 | 255 |
| 256 // The following functions simplify code paths where the UI thread notifies the |
| 257 // ResourceDispatcherHostImpl of information pertaining to loading behavior of |
| 258 // frame hosts. |
| 259 void NotifyRouteChangesOnIO( |
| 260 base::Callback<void(ResourceDispatcherHostImpl*, |
| 261 const GlobalFrameRoutingId&)> frame_callback, |
| 262 std::unique_ptr<std::set<GlobalFrameRoutingId>> routing_ids) { |
| 263 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 264 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
| 265 if (!rdh) |
| 266 return; |
| 267 for (const auto& routing_id : *routing_ids) |
| 268 frame_callback.Run(rdh, routing_id); |
| 269 } |
| 270 |
| 271 void NotifyForEachFrameFromUI( |
| 272 RenderFrameHost* root_frame_host, |
| 273 base::Callback<void(ResourceDispatcherHostImpl*, |
| 274 const GlobalFrameRoutingId&)> frame_callback) { |
| 275 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 276 |
| 277 FrameTree* frame_tree = static_cast<RenderFrameHostImpl*>(root_frame_host) |
| 278 ->frame_tree_node() |
| 279 ->frame_tree(); |
| 280 DCHECK_EQ(root_frame_host, frame_tree->GetMainFrame()); |
| 281 |
| 282 std::unique_ptr<std::set<GlobalFrameRoutingId>> routing_ids( |
| 283 new std::set<GlobalFrameRoutingId>()); |
| 284 for (FrameTreeNode* node : frame_tree->Nodes()) { |
| 285 RenderFrameHostImpl* frame_host = node->current_frame_host(); |
| 286 RenderFrameHostImpl* pending_frame_host = |
| 287 IsBrowserSideNavigationEnabled() |
| 288 ? node->render_manager()->speculative_frame_host() |
| 289 : node->render_manager()->pending_frame_host(); |
| 290 if (frame_host) |
| 291 routing_ids->insert(frame_host->GetGlobalFrameRoutingId()); |
| 292 if (pending_frame_host) |
| 293 routing_ids->insert(pending_frame_host->GetGlobalFrameRoutingId()); |
| 294 } |
| 295 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 296 base::Bind(&NotifyRouteChangesOnIO, frame_callback, |
| 297 base::Passed(std::move(routing_ids)))); |
| 298 } |
| 299 |
| 256 } // namespace | 300 } // namespace |
| 257 | 301 |
| 258 // static | 302 // static |
| 259 RenderFrameHost* RenderFrameHost::FromID(int render_process_id, | 303 RenderFrameHost* RenderFrameHost::FromID(int render_process_id, |
| 260 int render_frame_id) { | 304 int render_frame_id) { |
| 261 return RenderFrameHostImpl::FromID(render_process_id, render_frame_id); | 305 return RenderFrameHostImpl::FromID(render_process_id, render_frame_id); |
| 262 } | 306 } |
| 263 | 307 |
| 264 #if defined(OS_ANDROID) | 308 #if defined(OS_ANDROID) |
| 265 // static | 309 // static |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 render_widget_host_->InitForFrame(); | 1040 render_widget_host_->InitForFrame(); |
| 997 | 1041 |
| 998 if (enabled_bindings_ && created) { | 1042 if (enabled_bindings_ && created) { |
| 999 if (!frame_bindings_control_) | 1043 if (!frame_bindings_control_) |
| 1000 GetRemoteAssociatedInterfaces()->GetInterface(&frame_bindings_control_); | 1044 GetRemoteAssociatedInterfaces()->GetInterface(&frame_bindings_control_); |
| 1001 frame_bindings_control_->AllowBindings(enabled_bindings_); | 1045 frame_bindings_control_->AllowBindings(enabled_bindings_); |
| 1002 } | 1046 } |
| 1003 } | 1047 } |
| 1004 | 1048 |
| 1005 void RenderFrameHostImpl::Init() { | 1049 void RenderFrameHostImpl::Init() { |
| 1006 ResourceDispatcherHost::ResumeBlockedRequestsForFrameFromUI(this); | 1050 ResumeBlockedRequestsForFrame(); |
| 1007 if (!waiting_for_init_) | 1051 if (!waiting_for_init_) |
| 1008 return; | 1052 return; |
| 1009 | 1053 |
| 1010 waiting_for_init_ = false; | 1054 waiting_for_init_ = false; |
| 1011 if (pendinging_navigate_) { | 1055 if (pendinging_navigate_) { |
| 1012 frame_tree_node()->navigator()->OnBeginNavigation( | 1056 frame_tree_node()->navigator()->OnBeginNavigation( |
| 1013 frame_tree_node(), pendinging_navigate_->first, | 1057 frame_tree_node(), pendinging_navigate_->first, |
| 1014 pendinging_navigate_->second); | 1058 pendinging_navigate_->second); |
| 1015 pendinging_navigate_.reset(); | 1059 pendinging_navigate_.reset(); |
| 1016 } | 1060 } |
| (...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1828 if (!frame_bindings_control_) | 1872 if (!frame_bindings_control_) |
| 1829 GetRemoteAssociatedInterfaces()->GetInterface(&frame_bindings_control_); | 1873 GetRemoteAssociatedInterfaces()->GetInterface(&frame_bindings_control_); |
| 1830 frame_bindings_control_->AllowBindings(enabled_bindings_); | 1874 frame_bindings_control_->AllowBindings(enabled_bindings_); |
| 1831 } | 1875 } |
| 1832 } | 1876 } |
| 1833 | 1877 |
| 1834 int RenderFrameHostImpl::GetEnabledBindings() const { | 1878 int RenderFrameHostImpl::GetEnabledBindings() const { |
| 1835 return enabled_bindings_; | 1879 return enabled_bindings_; |
| 1836 } | 1880 } |
| 1837 | 1881 |
| 1882 void RenderFrameHostImpl::BlockRequestsForFrame() { |
| 1883 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1884 NotifyForEachFrameFromUI( |
| 1885 this, base::Bind(&ResourceDispatcherHostImpl::BlockRequestsForRoute)); |
| 1886 } |
| 1887 |
| 1888 void RenderFrameHostImpl::ResumeBlockedRequestsForFrame() { |
| 1889 NotifyForEachFrameFromUI( |
| 1890 this, |
| 1891 base::Bind(&ResourceDispatcherHostImpl::ResumeBlockedRequestsForRoute)); |
| 1892 } |
| 1893 |
| 1894 void RenderFrameHostImpl::CancelBlockedRequestsForFrame() { |
| 1895 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1896 NotifyForEachFrameFromUI( |
| 1897 this, |
| 1898 base::Bind(&ResourceDispatcherHostImpl::CancelBlockedRequestsForRoute)); |
| 1899 } |
| 1900 |
| 1838 void RenderFrameHostImpl::OnDidAccessInitialDocument() { | 1901 void RenderFrameHostImpl::OnDidAccessInitialDocument() { |
| 1839 delegate_->DidAccessInitialDocument(); | 1902 delegate_->DidAccessInitialDocument(); |
| 1840 } | 1903 } |
| 1841 | 1904 |
| 1842 void RenderFrameHostImpl::OnDidChangeOpener(int32_t opener_routing_id) { | 1905 void RenderFrameHostImpl::OnDidChangeOpener(int32_t opener_routing_id) { |
| 1843 frame_tree_node_->render_manager()->DidChangeOpener(opener_routing_id, | 1906 frame_tree_node_->render_manager()->DidChangeOpener(opener_routing_id, |
| 1844 GetSiteInstance()); | 1907 GetSiteInstance()); |
| 1845 } | 1908 } |
| 1846 | 1909 |
| 1847 void RenderFrameHostImpl::OnDidChangeName(const std::string& name, | 1910 void RenderFrameHostImpl::OnDidChangeName(const std::string& name, |
| (...skipping 1712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3560 service_manager::mojom::InterfaceProviderPtr provider; | 3623 service_manager::mojom::InterfaceProviderPtr provider; |
| 3561 BindInterfaceRegistryForRenderFrameHost(mojo::MakeRequest(&provider), this); | 3624 BindInterfaceRegistryForRenderFrameHost(mojo::MakeRequest(&provider), this); |
| 3562 java_interfaces_.reset(new service_manager::InterfaceProvider); | 3625 java_interfaces_.reset(new service_manager::InterfaceProvider); |
| 3563 java_interfaces_->Bind(std::move(provider)); | 3626 java_interfaces_->Bind(std::move(provider)); |
| 3564 } | 3627 } |
| 3565 return java_interfaces_.get(); | 3628 return java_interfaces_.get(); |
| 3566 } | 3629 } |
| 3567 #endif | 3630 #endif |
| 3568 | 3631 |
| 3569 } // namespace content | 3632 } // namespace content |
| OLD | NEW |