OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 module mojo.shell.mojom; | 5 module mojo.shell.mojom; |
6 | 6 |
7 import "mojo/shell/public/interfaces/interface_provider.mojom"; | 7 import "mojo/shell/public/interfaces/connector.mojom"; |
| 8 import "mojo/shell/public/interfaces/shell_client_factory.mojom"; |
| 9 |
| 10 struct InstanceInfo { |
| 11 uint32 id; |
| 12 string name; |
| 13 string qualifier; |
| 14 uint32 pid; |
| 15 }; |
| 16 |
| 17 // Implemented by a client that wishes to be informed when the list of running |
| 18 // instances changes. |
| 19 interface InstanceListener { |
| 20 // Called once when the listener is added via Shell::AddInstanceListener() to |
| 21 // provide the initial list of instances that the listener observes changes |
| 22 // against. |
| 23 SetExistingInstances(array<InstanceInfo> instances); |
| 24 |
| 25 // Called when the shell has started tracking an instance. This happens when |
| 26 // the shell first handles a request to launch the instance, before any |
| 27 // process is created for it. |
| 28 InstanceCreated(InstanceInfo instance); |
| 29 |
| 30 // Called when the shell has stopped tracking an instance. (i.e. when it has |
| 31 // ended/quit). |
| 32 InstanceDestroyed(uint32 id); |
| 33 |
| 34 // Called when a pid is available for the instance. This could be because a |
| 35 // process was created by the runner for it, or because an existing content |
| 36 // handler process was assigned. |
| 37 InstancePIDAvailable(uint32 id, uint32 pid); |
| 38 }; |
| 39 |
| 40 // Implemented by an object in the shell associated with a specific instance. |
| 41 // Tells it the PID for a process launched by the client. This interface is only |
| 42 // available to callers of Shell::CreateInstanceForFactory(). |
| 43 interface PIDReceiver { |
| 44 SetPID(uint32 pid); |
| 45 }; |
8 | 46 |
9 // Specifies a whitelist of applications and services an application can connect | 47 // Specifies a whitelist of applications and services an application can connect |
10 // to. Connections to applications not explicitly specified here as a key are | 48 // to. Connections to applications not explicitly specified here as a key are |
11 // rejected. Connections to services not specified in an application's allowed | 49 // rejected. Connections to services not specified in an application's allowed |
12 // interfaces value are not made. | 50 // interfaces value are not made. |
13 // A "*" value as the only key in an otherwise empty map means the application | 51 // A "*" value as the only key in an otherwise empty map means the application |
14 // may connect to any other application. | 52 // may connect to any other application. |
15 // A "*" value as the only string in an otherwise empty array of interface names | 53 // A "*" value as the only string in an otherwise empty array of interface names |
16 // means the application may connect to any service in that application. | 54 // means the application may connect to any service in that application. |
17 // An empty interface name array means the application may not connect to any | 55 // An empty interface name array means the application may not connect to any |
18 // services exposed by the application it is connecting to. | 56 // services exposed by the application it is connecting to. |
19 struct CapabilityFilter { | 57 struct CapabilityFilter { |
20 map<string, array<string>> filter; | 58 map<string, array<string>> filter; |
21 }; | 59 }; |
22 | 60 |
23 // Encapsulates establishing connections with other Mojo applications. | 61 interface Shell { |
24 interface Connector { | 62 // Instructs the Shell to create an instance for an existing process at the |
25 const uint32 kInvalidApplicationID = 0; | 63 // other end of |factory|, and perform applicable initialization. |user_id| is |
26 const uint32 kUserRoot = 0; | 64 // the user the instance should be created as. This is typically set to |
27 const uint32 kUserInherit = 1; | 65 // Connector::kUserInherit, unless the application has the ability to connect |
| 66 // as other users. |
| 67 CreateInstanceForFactory(ShellClientFactory factory, |
| 68 string name, |
| 69 uint32 user_id, |
| 70 CapabilityFilter filter, |
| 71 PIDReceiver& pid_receiver); |
28 | 72 |
29 // Requests a connection with another application. The application originating | 73 // The listener is removed when the |listener| pipe is closed. |
30 // the request is referred to as the "source" and the one receiving the | 74 AddInstanceListener(InstanceListener listener); |
31 // "target". | |
32 // | |
33 // The connection is embodied by a pair of message pipes binding the | |
34 // InterfaceProvider interface, which allows both the source and target | |
35 // applications to export interfaces to one another. The interfaces bound via | |
36 // these InterfaceProviders are brokered by the shell according to the | |
37 // security policy defined by each application in its manifest . | |
38 // | |
39 // If the target application is not running, the shell will run it, calling | |
40 // its Initialize() method before completing the connection. | |
41 // | |
42 // Parameters: | |
43 // | |
44 // name | |
45 // A mojo: or exe: name identifying the target application. | |
46 // | |
47 // user_id | |
48 // The user id of the target application instance to connect to. If no such | |
49 // instance exists, the shell may start one. This user id will be passed | |
50 // to the new instance via Initialize(). Applications must generally set | |
51 // this to kUserInherit, and the shell will either connect to an existing | |
52 // instance matching the caller's user id, create a new instance matching | |
53 // the caller's user id, or connect to an existing instance running as | |
54 // kUserRoot. By default, applications do not have the ability to pass | |
55 // arbitrary values to this method, and doing so will result in a | |
56 // connection error on the remote service provider. An application with | |
57 // the ability to launch applications with arbitrary user ids (e.g. a login | |
58 // app) may set this value to something meaningful to it. | |
59 // | |
60 // remote_interfaces | |
61 // Allows the source application access to interface implementations | |
62 // exposed by the target application. The interfaces accessible via this | |
63 // InterfaceParameter are filtered by the security policy described by the | |
64 // source and target application manifests. | |
65 // | |
66 // local_interfaces | |
67 // Allows the remote application access to interface implementations | |
68 // exposed by the source application. The interfaces accessible via this | |
69 // InterfaceProvider are filtered by the security policy described by the | |
70 // source and target application manifests. | |
71 // | |
72 // Response parameters: | |
73 // | |
74 // application_id | |
75 // A unique identifier for the instance that was connected to. | |
76 // | |
77 // user_id | |
78 // The user id the shell ran the target application as. Typically a client | |
79 // passes kUserInherit to Connect(), which is an invalid user id, so this | |
80 // value in the response is guaranteed to be a valid user id, either the | |
81 // id connected to, or kUserRoot if no user-specific instance was located. | |
82 // | |
83 Connect(string name, | |
84 uint32 user_id, | |
85 InterfaceProvider&? remote_interfaces, | |
86 InterfaceProvider? local_interfaces) => (uint32 application_id, | |
87 uint32 user_id); | |
88 | |
89 // Clones this Connector so it can be passed to another thread. | |
90 Clone(Connector& request); | |
91 }; | 75 }; |
OLD | NEW |