Look for the keyboard in the view services

The engine now provides the keyboard and raw keyboard services via the view
services. This patch updates the framework to look there for the keyboard.
Also, this patch migrates callers to the new MojoServices name for these entry
points.
This commit is contained in:
Adam Barth 2016-03-18 12:43:51 -07:00
parent 964ba0c69b
commit addc87dcf1
6 changed files with 30 additions and 12 deletions

View File

@ -1 +1 @@
138fae117a19b6c7a9ae1a098daf35275a3002e7
5114eade633fa9d08355d3e7a67b4c9f983d4357

View File

@ -30,7 +30,7 @@ class MojoShell {
static MojoShell _instance;
static mojom.ShellProxy _initShellProxy() {
core.MojoHandle shellHandle = new core.MojoHandle(ui.takeShellProxyHandle());
core.MojoHandle shellHandle = new core.MojoHandle(ui.MojoServices.takeShell());
if (!shellHandle.isValid)
return null;
return new mojom.ShellProxy.fromHandle(shellHandle);
@ -38,13 +38,13 @@ class MojoShell {
final mojom.Shell _shell = _initShellProxy()?.ptr;
static ApplicationConnection _initEmbedderConnection() {
core.MojoHandle servicesHandle = new core.MojoHandle(ui.takeServicesProvidedByEmbedder());
core.MojoHandle exposedServicesHandle = new core.MojoHandle(ui.takeServicesProvidedToEmbedder());
if (!servicesHandle.isValid || !exposedServicesHandle.isValid)
core.MojoHandle incomingServicesHandle = new core.MojoHandle(ui.MojoServices.takeIncomingServices());
core.MojoHandle outgoingServicesHandle = new core.MojoHandle(ui.MojoServices.takeOutgoingServices());
if (!incomingServicesHandle.isValid || !outgoingServicesHandle.isValid)
return null;
mojom.ServiceProviderProxy services = new mojom.ServiceProviderProxy.fromHandle(servicesHandle);
mojom.ServiceProviderStub exposedServices = new mojom.ServiceProviderStub.fromHandle(exposedServicesHandle);
return new ApplicationConnection(exposedServices, services);
mojom.ServiceProviderProxy incomingServices = new mojom.ServiceProviderProxy.fromHandle(incomingServicesHandle);
mojom.ServiceProviderStub outgoingServices = new mojom.ServiceProviderStub.fromHandle(outgoingServicesHandle);
return new ApplicationConnection(outgoingServices, incomingServices);
}
final ApplicationConnection _embedderConnection = _initEmbedderConnection();
@ -92,6 +92,24 @@ class MojoShell {
services.close();
}
static mojom.ServiceProviderProxy _takeViewServices() {
core.MojoHandle services = new core.MojoHandle(ui.MojoServices.takeViewServices());
if (!services.isValid)
return null;
return new mojom.ServiceProviderProxy.fromHandle(services);
}
final mojom.ServiceProviderProxy _viewServices = _takeViewServices();
void connectToViewAssociatedService(bindings.ProxyBase proxy) {
if (overrideConnectToService != null && overrideConnectToService(null, proxy))
return;
if (_viewServices == null)
return;
core.MojoMessagePipe pipe = new core.MojoMessagePipe();
proxy.impl.bind(pipe.endpoints[0]);
_viewServices.ptr.connectToService(proxy.serviceName, pipe.endpoints[1]);
}
/// Registers a service to expose to the embedder.
void provideService(String interfaceName, ServiceFactory factory) {
_embedderConnection?.provideService(interfaceName, factory);

View File

@ -18,7 +18,7 @@ import 'box.dart';
import 'object.dart';
mojom.ViewProxy _initViewProxy() {
int viewHandle = ui.takeViewHandle();
int viewHandle = ui.MojoServices.takeView();
if (viewHandle == core.MojoHandle.INVALID)
return null;
return new mojom.ViewProxy.fromHandle(new core.MojoHandle(viewHandle));

View File

@ -105,7 +105,7 @@ class MojoAssetBundle extends CachingAssetBundle {
}
AssetBundle _initRootBundle() {
int h = ui.takeRootBundleHandle();
int h = ui.MojoServices.takeRootBundle();
if (h == core.MojoHandle.INVALID)
return null;
core.MojoHandle handle = new core.MojoHandle(h);

View File

@ -84,7 +84,7 @@ class KeyboardHandle {
mojom.KeyboardProxy _initKeyboardProxy() {
mojom.KeyboardProxy proxy = new mojom.KeyboardProxy.unbound();
shell.connectToService(null, proxy);
shell.connectToViewAssociatedService(proxy);
return proxy;
}

View File

@ -59,7 +59,7 @@ class _RawKeyboardListenerState extends State<RawKeyboardListener> implements mo
return;
_stub = new mojom.RawKeyboardListenerStub.unbound()..impl = this;
mojom.RawKeyboardServiceProxy keyboard = new mojom.RawKeyboardServiceProxy.unbound();
shell.connectToService(null, keyboard);
shell.connectToViewAssociatedService(keyboard);
keyboard.ptr.addListener(_stub);
keyboard.close();
}