diff --git a/DEPS b/DEPS index 46e58cce59eadf69ea39ecb8c4c132dc48126806..3f3987af6ab6b64947218906555d29cb8b0a17c2 100644 --- a/DEPS +++ b/DEPS @@ -19,7 +19,7 @@ vars = { 'chromium_git': 'https://chromium.googlesource.com', - 'mojo_sdk_revision': '13824e0387395335e4c9fa54873a540ef21d6096', + 'mojo_sdk_revision': '40b28d5dc1ebd9f1416e3b0be9bddca2d59c48ac', 'mojo_devtools_revision': '49879d78ce4486e10c2214a101d9b2e82794b2f4', 'skia_revision': '87ed6be0e4ea8b0a88915045f697d0fd734ed6f5', diff --git a/mojo/services/keyboard/interfaces/BUILD.gn b/mojo/services/keyboard/interfaces/BUILD.gn index 6aa938977f7ba38b0c0f88a31064bb6516a276d6..b3ca11d1ff04720983a036c46e787d0135186670 100644 --- a/mojo/services/keyboard/interfaces/BUILD.gn +++ b/mojo/services/keyboard/interfaces/BUILD.gn @@ -9,4 +9,10 @@ mojom("interfaces") { sources = [ "keyboard.mojom", ] + + import_dirs = [ get_path_info("../../", "abspath") ] + + deps = [ + "../../native_viewport/interfaces", + ] } diff --git a/mojo/services/keyboard/interfaces/keyboard.mojom b/mojo/services/keyboard/interfaces/keyboard.mojom index 97942207a8ac08efdf7931d35b1d49500c9792f9..2fa451592616b80b8dbf86dd31cdac9f76bba27e 100644 --- a/mojo/services/keyboard/interfaces/keyboard.mojom +++ b/mojo/services/keyboard/interfaces/keyboard.mojom @@ -5,6 +5,8 @@ [DartPackage="mojo_services"] module keyboard; +import "native_viewport/interfaces/native_viewport.mojom"; + struct CompletionData { int64 id; int32 position; @@ -49,3 +51,9 @@ interface KeyboardService { SetText(string text); SetSelection(int32 start, int32 end); }; + +interface KeyboardServiceFactory { + CreateKeyboardService( + mojo.NativeViewportEventDispatcher& keyEventDispatcher, + KeyboardService& serviceRequest); +}; diff --git a/mojo/services/native_viewport/interfaces/native_viewport.mojom b/mojo/services/native_viewport/interfaces/native_viewport.mojom index 99e2bad3f41cea5407d78a139ed9efc5ea9c3f77..34654146fc1560d0ad1c496f9eb319e1c38b3e1c 100644 --- a/mojo/services/native_viewport/interfaces/native_viewport.mojom +++ b/mojo/services/native_viewport/interfaces/native_viewport.mojom @@ -34,7 +34,6 @@ interface NativeViewport { Close(); SetSize(Size size); SetEventDispatcher(NativeViewportEventDispatcher dispatcher); - SetKeyEventDispatcher(NativeViewportEventDispatcher dispatcher); // Requests a ContextProvider capable of producing contexts that draw to // this native viewport. diff --git a/sky/shell/platform/mojo/BUILD.gn b/sky/shell/platform/mojo/BUILD.gn index b4ad6422054a9ed668c6e02c15d7fd43752fd37e..a097b3308c3f7d5017e2dfb5d795c46adb4fbf53 100644 --- a/sky/shell/platform/mojo/BUILD.gn +++ b/sky/shell/platform/mojo/BUILD.gn @@ -31,6 +31,7 @@ mojo_native_application("mojo") { "//mojo/services/asset_bundle/interfaces", "//mojo/services/content_handler/interfaces", "//mojo/services/gpu/interfaces", + "//mojo/services/keyboard/interfaces", "//mojo/services/native_viewport/interfaces", "//mojo/services/service_registry/interfaces", "//services/asset_bundle:lib", diff --git a/sky/shell/platform/mojo/platform_view_mojo.cc b/sky/shell/platform/mojo/platform_view_mojo.cc index b1ae1d14e20c963c76d86c6f655113029fc9dae8..eb70ce20a2b4e6d1f86e7554e7264c5948cb77b5 100644 --- a/sky/shell/platform/mojo/platform_view_mojo.cc +++ b/sky/shell/platform/mojo/platform_view_mojo.cc @@ -57,6 +57,9 @@ PlatformViewMojo::~PlatformViewMojo() { void PlatformViewMojo::Init(mojo::Shell* shell) { mojo::ConnectToService(shell, "mojo:native_viewport_service", &viewport_); + // Grab the application connector so that we can connect to services later + shell->CreateApplicationConnector(GetProxy(&connector_)); + mojo::NativeViewportEventDispatcherPtr ptr; dispatcher_binding_.Bind(GetProxy(&ptr)); viewport_->SetEventDispatcher(ptr.Pass()); @@ -85,13 +88,19 @@ void PlatformViewMojo::Init(mojo::Shell* shell) { base::Bind(&RasterizerMojo::OnContextProviderAvailable, rasterizer->GetWeakPtr(), base::Passed(&context_provider_info)))); - ConnectToEngine(mojo::GetProxy(&sky_engine_)); + ConnectToEngine(GetProxy(&sky_engine_)); } void PlatformViewMojo::Run(const mojo::String& url, ServicesDataPtr services, mojo::asset_bundle::AssetBundlePtr bundle) { + + mojo::ServiceProviderPtr services_provided_by_embedder; + service_provider_.Bind(GetProxy(&services_provided_by_embedder)); + service_provider_.AddService(this); + services->services_provided_by_embedder = services_provided_by_embedder.Pass(); + sky_engine_->SetServices(services.Pass()); sky_engine_->RunFromAssetBundle(url, bundle.Pass()); } @@ -140,6 +149,12 @@ void PlatformViewMojo::OnEvent(mojo::EventPtr event, sky_engine_->OnPointerPacket(packet.Pass()); break; } + case mojo::EventType::KEY_PRESSED: + case mojo::EventType::KEY_RELEASED: + if (key_event_dispatcher_) { + key_event_dispatcher_->OnEvent(event.Pass(), callback); + return; // key_event_dispatcher_ will invoke callback + } default: break; } @@ -147,5 +162,26 @@ void PlatformViewMojo::OnEvent(mojo::EventPtr event, callback.Run(); } +void PlatformViewMojo::Create( + mojo::ApplicationConnection* connection, + mojo::InterfaceRequest request) { + + mojo::ServiceProviderPtr keyboard_service_provider; + connector_->ConnectToApplication( + "mojo:keyboard", + GetProxy(&keyboard_service_provider), + nullptr); + +#if defined(OS_LINUX) + keyboard::KeyboardServiceFactoryPtr factory; + mojo::ConnectToService(keyboard_service_provider.get(), &factory); + factory->CreateKeyboardService(GetProxy(&key_event_dispatcher_), request.Pass()); +#else + keyboard_service_provider->ConnectToService( + keyboard::KeyboardService::Name_, + request.PassMessagePipe()); +#endif +} + } // namespace shell } // namespace sky diff --git a/sky/shell/platform/mojo/platform_view_mojo.h b/sky/shell/platform/mojo/platform_view_mojo.h index 9f9ab14bbb650dacdc7f0045412e59fa6152b2aa..d3f20473e8cc9ee6fa291f77f3295a8e28f43e8a 100644 --- a/sky/shell/platform/mojo/platform_view_mojo.h +++ b/sky/shell/platform/mojo/platform_view_mojo.h @@ -5,10 +5,12 @@ #ifndef SKY_SHELL_PLATFORM_MOJO_PLATFORM_VIEW_MOJO_H_ #define SKY_SHELL_PLATFORM_MOJO_PLATFORM_VIEW_MOJO_H_ +#include "mojo/public/cpp/application/service_provider_impl.h" #include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/interfaces/application/service_provider.mojom.h" #include "mojo/public/interfaces/application/shell.mojom.h" #include "mojo/services/asset_bundle/interfaces/asset_bundle.mojom.h" +#include "mojo/services/keyboard/interfaces/keyboard.mojom.h" #include "mojo/services/native_viewport/interfaces/native_viewport.mojom.h" #include "sky/shell/platform_view.h" @@ -16,7 +18,8 @@ namespace sky { namespace shell { class PlatformViewMojo : public PlatformView, - public mojo::NativeViewportEventDispatcher { + public mojo::NativeViewportEventDispatcher, + public mojo::InterfaceFactory<::keyboard::KeyboardService> { public: explicit PlatformViewMojo(const Config& config); ~PlatformViewMojo() override; @@ -34,11 +37,22 @@ class PlatformViewMojo : public PlatformView, void OnEvent(mojo::EventPtr event, const mojo::Callback& callback) override; + // |mojo::InterfaceFactory| implementation: + void Create( + mojo::ApplicationConnection* connection, + mojo::InterfaceRequest<::keyboard::KeyboardService>) override; + + mojo::ApplicationConnectorPtr connector_; + mojo::NativeViewportPtr viewport_; mojo::Binding dispatcher_binding_; sky::SkyEnginePtr sky_engine_; + mojo::ServiceProviderImpl service_provider_; + + mojo::NativeViewportEventDispatcherPtr key_event_dispatcher_; + DISALLOW_COPY_AND_ASSIGN(PlatformViewMojo); };