Index: chromecast/browser/cast_content_browser_client.cc |
diff --git a/chromecast/browser/cast_content_browser_client.cc b/chromecast/browser/cast_content_browser_client.cc |
index 7d9e4a3379d3e55d2b7943d3151788d7117efd92..1de06f8a11e6ea7adbc6ed0c3409fa1796b5106f 100644 |
--- a/chromecast/browser/cast_content_browser_client.cc |
+++ b/chromecast/browser/cast_content_browser_client.cc |
@@ -48,6 +48,7 @@ |
#include "content/public/browser/render_process_host.h" |
#include "content/public/browser/resource_dispatcher_host.h" |
#include "content/public/browser/web_contents.h" |
+#include "content/public/common/connection_filter.h" |
#include "content/public/common/content_descriptors.h" |
#include "content/public/common/content_switches.h" |
#include "content/public/common/service_names.mojom.h" |
@@ -55,6 +56,7 @@ |
#include "content/public/common/web_preferences.h" |
#include "net/ssl/ssl_cert_request_info.h" |
#include "net/url_request/url_request_context_getter.h" |
+#include "services/service_manager/public/cpp/connector.h" |
#include "services/service_manager/public/cpp/interface_registry.h" |
#include "ui/base/resource/resource_bundle.h" |
#include "ui/display/display.h" |
@@ -76,6 +78,7 @@ namespace chromecast { |
namespace shell { |
namespace { |
+ |
#if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) |
static std::unique_ptr<service_manager::Service> CreateMediaService( |
CastContentBrowserClient* browser_client) { |
@@ -92,6 +95,48 @@ static std::unique_ptr<service_manager::Service> CreateMediaService( |
} |
#endif // defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) |
+// This filter will be added to the ServiceManagerConnection for the browser |
+// process, registering these interfaces in "service:content_browser" so any |
+// external service can use them. This allows another service to connect to an |
+// interface "mojom::Foo" registered here by calling: |
+// |
+// mojom::FooPtr remote_foo; |
+// connector()->GetInterface("service:content_browser", &remote_foo"); |
+// |
+// Note: Service manifests will also need to be updated. For the example above, |
+// chromecast/browser/cast_content_browser_manifest_overlay.json will need to |
+// "provide" the interface... |
+// |
+// provides: { |
+// "foo_interfaces": [ "mojom::Foo" ] |
+// } |
+// |
+// ...and the service manifest for the remote service will need to "require" it |
+// from "content_browser": |
+// |
+// requires: { |
+// "content_browser": [ "foo_interfaces" ] |
+// } |
+// |
+// We will not filter on |remote_identity| here; instead, connection |
+// constraints will be enforced only by the manifests. |
+class ContentBrowserConnectionFilter : public content::ConnectionFilter { |
alokp
2016/12/14 05:46:16
Are we using connection filter anywhere? If not I
slan
2016/12/19 17:58:18
Removed.
|
+ public: |
+ ContentBrowserConnectionFilter() {} |
+ ~ContentBrowserConnectionFilter() override {} |
+ |
+ // content::ConnectionFilter implementation: |
+ bool OnConnect(const service_manager::Identity& remote_identity, |
+ service_manager::InterfaceRegistry* registry, |
+ service_manager::Connector* connector) { |
+ DCHECK(registry); |
+ return true; |
+ } |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(ContentBrowserConnectionFilter); |
+}; |
+ |
} // namespace |
CastContentBrowserClient::CastContentBrowserClient() |
@@ -422,6 +467,8 @@ void CastContentBrowserClient::ExposeInterfacesToRenderer( |
base::ThreadTaskRunnerHandle::Get()); |
} |
+// When registering an in-process service, also update the manifest overlay in |
+// chromecast/browser/BUILD.gn to include the service. |
void CastContentBrowserClient::RegisterInProcessServices( |
StaticServiceMap* services) { |
#if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) |
@@ -432,6 +479,12 @@ void CastContentBrowserClient::RegisterInProcessServices( |
#endif |
} |
+void CastContentBrowserClient::AddConnectionFilters( |
+ ConnectionFilterList* connection_filter_list) { |
+ connection_filter_list->push_back( |
+ base::MakeUnique<ContentBrowserConnectionFilter>()); |
+} |
+ |
std::unique_ptr<base::Value> |
CastContentBrowserClient::GetServiceManifestOverlay( |
const std::string& service_name) { |