Index: content/browser/frame_host/render_frame_host_impl.cc |
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc |
index 44334dea3167a5799caeb140e8922cae6042e5f5..5fd3336722a151e071dc4d986ed973399982db96 100644 |
--- a/content/browser/frame_host/render_frame_host_impl.cc |
+++ b/content/browser/frame_host/render_frame_host_impl.cc |
@@ -87,6 +87,8 @@ |
#include "device/vibration/vibration_manager_impl.h" |
#include "media/mojo/interfaces/media_service.mojom.h" |
#include "media/mojo/interfaces/service_factory.mojom.h" |
+#include "mojo/public/cpp/bindings/associated_interface_ptr.h" |
+#include "mojo/public/cpp/bindings/associated_interface_request.h" |
#include "services/shell/public/cpp/connector.h" |
#include "services/shell/public/cpp/interface_provider.h" |
#include "ui/accessibility/ax_tree.h" |
@@ -267,6 +269,7 @@ RenderFrameHostImpl::RenderFrameHostImpl(SiteInstance* site_instance, |
weak_ptr_factory_(this) { |
frame_tree_->AddRenderViewHostRef(render_view_host_); |
GetProcess()->AddRoute(routing_id_, this); |
+ GetProcess()->AddRoutedInterfaces(routing_id_, this); |
g_routing_id_frame_map.Get().insert(std::make_pair( |
RenderFrameHostID(GetProcess()->GetID(), routing_id_), |
this)); |
@@ -500,6 +503,29 @@ shell::InterfaceProvider* RenderFrameHostImpl::GetRemoteInterfaces() { |
return remote_interfaces_.get(); |
} |
+void RenderFrameHostImpl::AddRoutedInterface( |
+ const base::StringPiece& name, |
+ const RoutedInterfaceFactory& factory) { |
+ auto result = |
+ routed_interfaces_.insert(std::make_pair(name.as_string(), factory)); |
+ DCHECK(result.second); |
+} |
+ |
+void RenderFrameHostImpl::RemoveRoutedInterface(const base::StringPiece& name) { |
+ auto it = routed_interfaces_.find(name.as_string()); |
+ DCHECK(it != routed_interfaces_.end()); |
+ routed_interfaces_.erase(it); |
+} |
+ |
+void RenderFrameHostImpl::GetRemoteRoutedInterface( |
+ const base::StringPiece& name, |
+ mojo::ScopedInterfaceEndpointHandle handle) { |
+ mojom::RoutedInterfaceAssociatedRequest request; |
+ request.Bind(std::move(handle)); |
+ GetRemoteRoutedInterfaces()->GetRoutedInterface(name.as_string(), |
+ std::move(request)); |
+} |
+ |
blink::WebPageVisibilityState RenderFrameHostImpl::GetVisibilityState() { |
// Works around the crashes seen in https://crbug.com/501863, where the |
// active WebContents from a browser iterator may contain a render frame |
@@ -1463,6 +1489,10 @@ void RenderFrameHostImpl::OnRenderProcessGone(int status, int exit_code) { |
iter.second.Run(ui::AXTreeUpdate()); |
ax_tree_snapshot_callbacks_.clear(); |
+ // Ensure that future remote interface requests are associated with the new |
+ // process's channel. |
+ remote_routed_interfaces_.reset(); |
+ |
if (!is_active()) { |
// If the process has died, we don't need to wait for the swap out ack from |
// this RenderFrame if it is pending deletion. Complete the swap out to |
@@ -3061,4 +3091,23 @@ void RenderFrameHostImpl::DeleteWebBluetoothService() { |
web_bluetooth_service_.reset(); |
} |
+mojom::RoutedInterfaceProvider* |
+RenderFrameHostImpl::GetRemoteRoutedInterfaces() { |
+ if (!remote_routed_interfaces_) { |
+ GetProcess()->GetRemoteRouteProvider()->GetRoutedInterfaces( |
+ GetRoutingID(), |
+ mojo::GetProxy(&remote_routed_interfaces_, |
+ GetProcess()->GetChannel()->GetAssociatedGroup())); |
+ } |
+ return remote_routed_interfaces_.get(); |
+} |
+ |
+void RenderFrameHostImpl::GetRoutedInterface( |
+ const std::string& name, |
+ mojom::RoutedInterfaceAssociatedRequest request) { |
+ auto it = routed_interfaces_.find(name); |
+ if (it != routed_interfaces_.end()) |
+ it->second.Run(request.PassHandle()); |
+} |
+ |
} // namespace content |