diff --git a/sky/shell/ui/internals.cc b/sky/shell/ui/internals.cc index 72367e2c78e..05adb76f624 100644 --- a/sky/shell/ui/internals.cc +++ b/sky/shell/ui/internals.cc @@ -41,7 +41,8 @@ void TakeServicesProvidedByEmbedder(Dart_NativeArguments args) { } void TakeServicesProvidedToEmbedder(Dart_NativeArguments args) { - Dart_SetIntegerReturnValue(args, 0); + Dart_SetIntegerReturnValue( + args, GetInternals()->TakeServicesProvidedToEmbedder().value()); } void TakeServiceRegistry(Dart_NativeArguments args) { @@ -93,10 +94,16 @@ Internals::Internals(mojo::ServiceProviderPtr platform_service_provider, mojo::asset_bundle::AssetBundlePtr root_bundle) : root_bundle_(root_bundle.Pass()), service_provider_impl_(GetProxy(&service_provider_)), + platform_service_provider_(platform_service_provider.Pass()) { service_provider_impl_.set_fallback_service_provider( platform_service_provider_.get()); service_provider_impl_.AddService(this); + + // Currently we don't consume any services provided by the application. + // So there's no need to hold the proxy to the application's ServiceProvider. + mojo::ServiceProviderPtr application_service_provider; + services_provided_to_embedder_ = GetProxy(&application_service_provider); } Internals::~Internals() { @@ -117,5 +124,9 @@ mojo::Handle Internals::TakeRootBundleHandle() { return root_bundle_.PassInterface().PassHandle().release(); } +mojo::Handle Internals::TakeServicesProvidedToEmbedder() { + return services_provided_to_embedder_.PassMessagePipe().release(); +} + } // namespace shell } // namespace sky diff --git a/sky/shell/ui/internals.h b/sky/shell/ui/internals.h index cfa04fa07d9..0d028cb06f6 100644 --- a/sky/shell/ui/internals.h +++ b/sky/shell/ui/internals.h @@ -31,6 +31,7 @@ class Internals mojo::Handle TakeServicesProvidedByEmbedder(); mojo::Handle TakeRootBundleHandle(); + mojo::Handle TakeServicesProvidedToEmbedder(); private: explicit Internals(mojo::ServiceProviderPtr platform_service_provider, @@ -46,6 +47,11 @@ class Internals mojo::ServiceProviderImpl service_provider_impl_; mojo::ServiceProviderPtr platform_service_provider_; + // A ServiceProvider supplied by the application that exposes services to + // the embedder. + mojo::InterfaceRequest + services_provided_to_embedder_; + MOJO_DISALLOW_COPY_AND_ASSIGN(Internals); };