OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 package org.chromium.mojo.application; | |
6 | |
7 import org.chromium.mojo.bindings.Interface; | |
8 import org.chromium.mojo.bindings.Interface.Proxy; | |
9 import org.chromium.mojo.bindings.InterfaceRequest; | |
10 import org.chromium.mojo.system.Core; | |
11 import org.chromium.mojo.system.Pair; | |
12 import org.chromium.mojom.mojo.ServiceProvider; | |
13 import org.chromium.mojom.mojo.Shell; | |
14 | |
15 /** | |
16 * Helper class to help connecting to other application through the shell. | |
17 */ | |
18 public class ShellHelper { | |
19 /** | |
20 * Connects to a service in another application. | |
21 * | |
22 * @param core Implementation of the {@link Core} api. | |
23 * @param shell Instance of the shell. | |
24 * @param application URL to the application to use. | |
25 * @param manager {@link org.chromium.mojo.bindings.Interface.NamedManager}
for the service to | |
26 * connect to. | |
27 * @return a proxy to the service. | |
28 */ | |
29 public static <I extends Interface, P extends Proxy> P connectToService( | |
30 Core core, Shell shell, String application, Interface.NamedManager<I
, P> manager) { | |
31 Pair<ServiceProvider.Proxy, InterfaceRequest<ServiceProvider>> providerR
equest = | |
32 ServiceProvider.MANAGER.getInterfaceRequest(core); | |
33 try (ServiceProvider.Proxy provider = providerRequest.first) { | |
34 shell.connectToApplication(application, providerRequest.second); | |
35 Pair<P, InterfaceRequest<I>> serviceRequest = manager.getInterfaceRe
quest(core); | |
36 provider.connectToService(manager.getName(), serviceRequest.second.p
assHandle()); | |
37 return serviceRequest.first; | |
38 } | |
39 } | |
40 } | |
OLD | NEW |