| 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 import "mojo/shell/public/interfaces/shell.mojom"; | 8 import "mojo/shell/public/interfaces/shell.mojom"; |
| 9 | 9 |
| 10 // TODO(beng): rewrite these comments. | 10 // Implemented by something "known to" the Mojo Shell (e.g. an application or |
| 11 // This is the primary interface implemented by every Mojo application. It | 11 // service), for which an instance is tracked. It allows the implementor to |
| 12 // allows the application to receive its startup arguments from the shell, and | 12 // receive lifecycle events and service inbound connection attempts. |
| 13 // to be notified of events that occur during its execution. | |
| 14 // | |
| 15 // TODO(aa): It would be good to reorder the parameters once we have interface | |
| 16 // versioning. | |
| 17 interface ShellClient { | 13 interface ShellClient { |
| 18 // Initializes the application with the specified arguments. This method is | 14 // Called by the shell once an instance for this application has been created. |
| 19 // guaranteed to be called before any other method is called, and will only be | 15 // This method will be called exactly once before any other method is called. |
| 20 // called once. | |
| 21 // | 16 // |
| 22 // The |url| parameter is the identity of the application as far as the shell | 17 // Parameters: |
| 23 // is concerned. This will be the URL the application was found at, after all | 18 // |
| 24 // mappings, resolution, and redirects. And it will not include the | 19 // shell |
| 25 // querystring, since the querystring is not part of an application's | 20 // An interface back to the shell by which new connections may be |
| 26 // identity. | 21 // established. |
| 27 // | 22 // |
| 28 // The |id| parameter is the identifier of the instance in the | 23 // url |
| 29 // ApplicationManager. It can be passed to other shell interfaces that request | 24 // The resolved URL used in the connection request that resulted in this |
| 30 // an instance identifier. | 25 // application being initialized. |
| 31 Initialize(Shell shell, string url, uint32 id); | 26 // |
| 27 // id |
| 28 // A unique identifier used by the shell to identify this instance. |
| 29 // |
| 30 // user_id |
| 31 // Identifies the user this instance is run as in the shell. This may |
| 32 // differ from the user the application that caused this application to be |
| 33 // instantiated is run as. This will always be a valid user id, never |
| 34 // Shell::kUserInherit. |
| 35 // |
| 36 Initialize(Shell shell, string url, uint32 id, uint32 user_id); |
| 32 | 37 |
| 33 // Called when another application (identified by |requestor_url|) attempts to | 38 // Called when another application attempts to open a connection to this |
| 34 // open a connection to this application. | 39 // application. An application implements this method to complete the exchange |
| 40 // of interface implementations with the remote application. See also |
| 41 // documentation in shell.mojom for Connect(). The application originating |
| 42 // the request is referred to as the "source" and the one receiving the |
| 43 // "target". |
| 35 // | 44 // |
| 36 // If the other application wants to request services from this application, | 45 // Parameters: |
| 37 // it will have passed a valid interface request through the |services| | |
| 38 // parameter (i.e. one containing a valid message pipe endpoint). This | |
| 39 // application may then bind an implementation of |InterfaceProvider| to that | |
| 40 // request in order to make services available to the other application. | |
| 41 // | 46 // |
| 42 // If the other application wants to offer services to this application, it | 47 // requestor_url |
| 43 // will have passed a bound interface through the |exposed_services| | 48 // The URL of the source application. |
| 44 // parameter. This application may then request services through that | |
| 45 // interface. | |
| 46 // | 49 // |
| 47 // It is possible that both parameters will be valid/bound if the other | 50 // requestor_id |
| 48 // application wants to both request services from and offer services to this | 51 // A unique identifier used by the shell to identify the source |
| 49 // application. | 52 // application's instance. |
| 50 // | 53 // |
| 51 // This application is free to ignore the |services| or |exposed_services| | 54 // requestor_user_id |
| 52 // parameters if it does not wish to offer or request services. | 55 // An identifier for the user the source application is run as. This may |
| 56 // differ from the application the target is run as (i.e. the one received |
| 57 // via Initialize() above). This will always be a valid user id, never |
| 58 // Shell::kUserInherit. |
| 53 // | 59 // |
| 54 // |allowed_interfaces| is a set of interface names that the shell has | 60 // local_interfaces |
| 55 // determined can be exposed by this application to the connecting | 61 // A request for an InterfaceProvider by which the source application may |
| 56 // application. When this parameter is empty, this application should expose | 62 // seek to bind interface implementations exported by the target. |
| 57 // no services to the connecting application. When this parameter contains | |
| 58 // only the single string value "*" the application may expose all of its | |
| 59 // services to the connecting application. | |
| 60 // | 63 // |
| 61 // |resolved_url| is the URL that was requested to create this connection, | 64 // remote_interfaces |
| 62 // after all mappings, resolutions, and redirects. This will include any | 65 // An InterfaceProvider by which the target application may bind interface |
| 63 // querystring that was part of the request. | 66 // implementations exported by the source. |
| 67 // |
| 68 // allowed_interfaces |
| 69 // A whitelist of interface names that should be exported to the source, |
| 70 // according to the security policy described by the source and target's |
| 71 // manifests. Attempts to bind interfaces not in this whitelist must not be |
| 72 // fulfilled. |
| 73 // |
| 74 // resolved_url |
| 75 // The resolved URL used to complete this connection. |
| 64 // | 76 // |
| 65 AcceptConnection(string requestor_url, | 77 AcceptConnection(string requestor_url, |
| 66 uint32 requestor_id, | 78 uint32 requestor_id, |
| 79 uint32 requestor_user_id, |
| 67 InterfaceProvider&? local_interfaces, | 80 InterfaceProvider&? local_interfaces, |
| 68 InterfaceProvider? remote_interfaces, | 81 InterfaceProvider? remote_interfaces, |
| 69 array<string> allowed_interfaces, | 82 array<string> allowed_interfaces, |
| 70 string resolved_url); | 83 string resolved_url); |
| 71 | 84 |
| 72 // Called by the shell in response to calling Shell's QuitApplication. The | 85 // Called by the shell in response to calling Shell's QuitApplication. The |
| 73 // application should run the callback with true if shutdown can proceed. | 86 // application should run the callback with true if shutdown can proceed. |
| 74 // See Shell::QuitApplication for details about shutdown workflow. | 87 // See Shell::QuitApplication for details about shutdown workflow. |
| 75 OnQuitRequested() => (bool can_quit); | 88 OnQuitRequested() => (bool can_quit); |
| 76 }; | 89 }; |
| OLD | NEW |