OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/interface_provider.mojom"; |
8 | 8 |
9 const string kRootUserID = "505C0EE9-3013-43C0-82B0-A84F50CF8D84"; | 9 const string kRootUserID = "505C0EE9-3013-43C0-82B0-A84F50CF8D84"; |
10 const string kInheritUserID = "D26290E4-4485-4EAE-81A2-66D1EEB40A9D"; | 10 const string kInheritUserID = "D26290E4-4485-4EAE-81A2-66D1EEB40A9D"; |
11 | 11 |
12 const uint32 kInvalidInstanceID = 0; | 12 const uint32 kInvalidInstanceID = 0; |
13 | 13 |
14 enum ConnectResult { | 14 enum ConnectResult { |
15 // The connection was established successfully. | 15 // The connection was established successfully. |
16 SUCCEEDED, | 16 SUCCEEDED, |
17 | 17 |
18 // The name or user id supplied was malformed, or the application specified | 18 // The name or user id supplied was malformed, or the application specified |
19 // by |name| could not be loaded. | 19 // by |name| could not be loaded. |
20 INVALID_ARGUMENT, | 20 INVALID_ARGUMENT, |
21 | 21 |
22 // The connection was blocked by policy. Either connections to |name| are | 22 // The connection was blocked by policy. Either connections to |name| are |
23 // forbidden from this app by the CapabilityFilter, or the application | 23 // forbidden from this app by the CapabilityFilter, or the application |
24 // attempted to connect using a user id other than its own, | 24 // attempted to connect using a user id other than its own, |
25 // kInheritUserID or kRootUserID. | 25 // kInheritUserID or kRootUserID. |
26 ACCESS_DENIED | 26 ACCESS_DENIED |
27 }; | 27 }; |
28 | 28 |
| 29 // A collection of metadata that disambiguates instances in the shell. |
| 30 struct Identity { |
| 31 // A mojo: or exe: name identifying an application. |
| 32 string name; |
| 33 |
| 34 // The user id of the target application instance to connect to. If no such |
| 35 // instance exists, the shell may start one. This user id will be passed to |
| 36 // the new instance via Initialize(). |
| 37 // When connecting to other applications, applications must generally pass |
| 38 // kInheritUserID for this value, and the shell will either connect to an |
| 39 // existing instance matching the caller's user id, create a new instance |
| 40 // matching the caller's user id, or connect to an existing instance running |
| 41 // as kRootUserID. By default, applications do not have the ability to set |
| 42 // arbitrary values to this field, and doing so will result in a connection |
| 43 // error on the remote service provider. An application with the ability to |
| 44 // launch applications with arbitrary user ids (e.g. a login app) may set this |
| 45 // value to something meaningful to it. The user id string is a valid guid of |
| 46 // the form "%08X-%04X-%04X-%04X-%012llX", and (aside from the root user whose |
| 47 // guid is defined above) intended to be not-guessable. |
| 48 // When an application is initialized or receives a connection from another |
| 49 // application, this value is always the resolved user id, never |
| 50 // kInheritUserID. |
| 51 string user_id; |
| 52 |
| 53 // An application may spawn multiple instances with the same name,user_id |
| 54 // pair, provided they are started with unique values of this field. |
| 55 // TODO(beng): enforce the emptiness of this parameter unless the client bears |
| 56 // the appropriate capability. |
| 57 string instance; |
| 58 }; |
| 59 |
29 // Encapsulates establishing connections with other Mojo applications. | 60 // Encapsulates establishing connections with other Mojo applications. |
30 interface Connector { | 61 interface Connector { |
31 // Requests a connection with another application. The application originating | 62 // Requests a connection with another application. The application originating |
32 // the request is referred to as the "source" and the one receiving the | 63 // the request is referred to as the "source" and the one receiving the |
33 // "target". | 64 // "target". |
34 // | 65 // |
35 // The connection is embodied by a pair of message pipes binding the | 66 // The connection is embodied by a pair of message pipes binding the |
36 // InterfaceProvider interface, which allows both the source and target | 67 // InterfaceProvider interface, which allows both the source and target |
37 // applications to export interfaces to one another. The interfaces bound via | 68 // applications to export interfaces to one another. The interfaces bound via |
38 // these InterfaceProviders are brokered by the shell according to the | 69 // these InterfaceProviders are brokered by the shell according to the |
39 // security policy defined by each application in its manifest . | 70 // security policy defined by each application in its manifest . |
40 // | 71 // |
41 // If the target application is not running, the shell will run it, calling | 72 // If the target application is not running, the shell will run it, calling |
42 // its Initialize() method before completing the connection. | 73 // its Initialize() method before completing the connection. |
43 // | 74 // |
44 // Parameters: | 75 // Parameters: |
45 // | 76 // |
46 // name | 77 // target |
47 // A mojo: or exe: name identifying the target application. | 78 // Identifies the target application instance to connect to. |
48 // | |
49 // user_id | |
50 // The user id of the target application instance to connect to. If no such | |
51 // instance exists, the shell may start one. This user id will be passed | |
52 // to the new instance via Initialize(). Applications must generally pass | |
53 // kInheritUserID for this value, and the shell will either connect to an | |
54 // existing instance matching the caller's user id, create a new instance | |
55 // matching the caller's user id, or connect to an existing instance | |
56 // running as kRootUserID. By default, applications do not have the ability | |
57 // to pass arbitrary values to this method, and doing so will result in a | |
58 // connection error on the remote service provider. An application with | |
59 // the ability to launch applications with arbitrary user ids (e.g. a login | |
60 // app) may set this value to something meaningful to it. The user id | |
61 // string is a valid guid of the form "%08X-%04X-%04X-%04X-%012llX", and | |
62 // (aside from the root user whose guid is defined above) intended to be | |
63 // not-guessable. | |
64 // | 79 // |
65 // remote_interfaces | 80 // remote_interfaces |
66 // Allows the source application access to interface implementations | 81 // Allows the source application access to interface implementations |
67 // exposed by the target application. The interfaces accessible via this | 82 // exposed by the target application. The interfaces accessible via this |
68 // InterfaceParameter are filtered by the security policy described by the | 83 // InterfaceParameter are filtered by the security policy described by the |
69 // source and target application manifests. | 84 // source and target application manifests. |
70 // | 85 // |
71 // local_interfaces | 86 // local_interfaces |
72 // Allows the remote application access to interface implementations | 87 // Allows the remote application access to interface implementations |
73 // exposed by the source application. The interfaces accessible via this | 88 // exposed by the source application. The interfaces accessible via this |
74 // InterfaceProvider are filtered by the security policy described by the | 89 // InterfaceProvider are filtered by the security policy described by the |
75 // source and target application manifests. | 90 // source and target application manifests. |
76 // | 91 // |
77 // Response parameters: | 92 // Response parameters: |
78 // | 93 // |
79 // result | 94 // result |
80 // Indicates the result of the Connect() operation. | 95 // Indicates the result of the Connect() operation. |
81 // | 96 // |
82 // user_id | 97 // user_id |
83 // The user id the shell ran the target application as. Typically a client | 98 // The user id the shell ran the target application as. Typically a client |
84 // passes kInheritUserID as the user id to Connect() which is resolved by | 99 // passes kInheritUserID as the user id to Connect() which is resolved by |
85 // the shell into a valid user id returned through this callback. | 100 // the shell into a valid user id returned through this callback. |
86 // | 101 // |
87 // application_id | 102 // application_id |
88 // A unique identifier for the instance that was connected to. | 103 // A unique identifier for the instance that was connected to. |
89 // | 104 // |
90 Connect(string name, | 105 Connect(Identity target, |
91 string user_id, | |
92 InterfaceProvider&? remote_interfaces, | 106 InterfaceProvider&? remote_interfaces, |
93 InterfaceProvider? local_interfaces) => (ConnectResult result, | 107 InterfaceProvider? local_interfaces) => (ConnectResult result, |
94 string user_id, | 108 string user_id, |
95 uint32 application_id); | 109 uint32 application_id); |
96 | 110 |
97 // Clones this Connector so it can be passed to another thread. | 111 // Clones this Connector so it can be passed to another thread. |
98 Clone(Connector& request); | 112 Clone(Connector& request); |
99 }; | 113 }; |
OLD | NEW |