Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: mojo/shell/shell.h

Issue 1775113003: Morph CapabilityFilter into caps::Capabilities, which supports capability classes (yet unimplemente… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@44cattests
Patch Set: . Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/shell/public/interfaces/shell_resolver.mojom ('k') | mojo/shell/shell.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef MOJO_SHELL_SHELL_H_ 5 #ifndef MOJO_SHELL_SHELL_H_
6 #define MOJO_SHELL_SHELL_H_ 6 #define MOJO_SHELL_SHELL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "mojo/public/cpp/bindings/binding_set.h" 14 #include "mojo/public/cpp/bindings/binding_set.h"
15 #include "mojo/public/cpp/bindings/interface_ptr_set.h" 15 #include "mojo/public/cpp/bindings/interface_ptr_set.h"
16 #include "mojo/services/catalog/catalog.h" 16 #include "mojo/services/catalog/catalog.h"
17 #include "mojo/shell/connect_params.h" 17 #include "mojo/shell/connect_params.h"
18 #include "mojo/shell/loader.h" 18 #include "mojo/shell/loader.h"
19 #include "mojo/shell/native_runner.h" 19 #include "mojo/shell/native_runner.h"
20 #include "mojo/shell/public/cpp/capabilities.h"
20 #include "mojo/shell/public/cpp/identity.h" 21 #include "mojo/shell/public/cpp/identity.h"
21 #include "mojo/shell/public/cpp/interface_factory.h" 22 #include "mojo/shell/public/cpp/interface_factory.h"
22 #include "mojo/shell/public/cpp/shell_client.h" 23 #include "mojo/shell/public/cpp/shell_client.h"
23 #include "mojo/shell/public/interfaces/connector.mojom.h" 24 #include "mojo/shell/public/interfaces/connector.mojom.h"
24 #include "mojo/shell/public/interfaces/interface_provider.mojom.h" 25 #include "mojo/shell/public/interfaces/interface_provider.mojom.h"
25 #include "mojo/shell/public/interfaces/shell.mojom.h" 26 #include "mojo/shell/public/interfaces/shell.mojom.h"
26 #include "mojo/shell/public/interfaces/shell_client.mojom.h" 27 #include "mojo/shell/public/interfaces/shell_client.mojom.h"
27 #include "mojo/shell/public/interfaces/shell_client_factory.mojom.h" 28 #include "mojo/shell/public/interfaces/shell_client_factory.mojom.h"
28 #include "mojo/shell/public/interfaces/shell_resolver.mojom.h" 29 #include "mojo/shell/public/interfaces/shell_resolver.mojom.h"
29 30
30 namespace base { 31 namespace base {
31 class FilePath; 32 class FilePath;
32 class SequencedWorkerPool; 33 class SequencedWorkerPool;
33 } 34 }
34 35
35 namespace mojo { 36 namespace mojo {
36 class ShellConnection; 37 class ShellConnection;
37 namespace shell { 38 namespace shell {
38 39
39 // A set of names of interfaces that may be exposed to an application.
40 using AllowedInterfaces = std::set<std::string>;
41 // A map of allowed applications to allowed interface sets. See shell.mojom for
42 // more details.
43 using CapabilityFilter = std::map<std::string, AllowedInterfaces>;
44
45 // Creates an identity for the Shell, used when the Shell connects to 40 // Creates an identity for the Shell, used when the Shell connects to
46 // applications. 41 // applications.
47 Identity CreateShellIdentity(); 42 Identity CreateShellIdentity();
48 43
49 // Returns a capability filter that allows an application to connect to any
50 // other application and any service exposed by other applications.
51 CapabilityFilter GetPermissiveCapabilityFilter();
52
53 // Returns the set of interfaces that an application instance with |filter| is
54 // allowed to see from an instance with |identity|.
55 AllowedInterfaces GetAllowedInterfaces(const CapabilityFilter& filter,
56 const Identity& identity);
57
58 class Shell : public ShellClient { 44 class Shell : public ShellClient {
59 public: 45 public:
60 // API for testing. 46 // API for testing.
61 class TestAPI { 47 class TestAPI {
62 public: 48 public:
63 explicit TestAPI(Shell* shell); 49 explicit TestAPI(Shell* shell);
64 ~TestAPI(); 50 ~TestAPI();
65 51
66 // Returns true if there is a Instance for this name. 52 // Returns true if there is a Instance for this name.
67 bool HasRunningInstanceForName(const std::string& name) const; 53 bool HasRunningInstanceForName(const std::string& name) const;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 Instance* GetExistingOrRootInstance(const Identity& identity) const; 120 Instance* GetExistingOrRootInstance(const Identity& identity) const;
135 121
136 void NotifyPIDAvailable(uint32_t id, base::ProcessId pid); 122 void NotifyPIDAvailable(uint32_t id, base::ProcessId pid);
137 123
138 // Attempt to complete the connection requested by |params| by connecting to 124 // Attempt to complete the connection requested by |params| by connecting to
139 // an existing instance. If there is an existing instance, |params| is taken, 125 // an existing instance. If there is an existing instance, |params| is taken,
140 // and this function returns true. 126 // and this function returns true.
141 bool ConnectToExistingInstance(scoped_ptr<ConnectParams>* params); 127 bool ConnectToExistingInstance(scoped_ptr<ConnectParams>* params);
142 128
143 Instance* CreateInstance(const Identity& target_id, 129 Instance* CreateInstance(const Identity& target_id,
144 const CapabilityFilter& filter, 130 const CapabilitySpec& capabilities,
145 mojom::ShellClientRequest* request); 131 mojom::ShellClientRequest* request);
146 132
147 // Called from the instance implementing mojom::Shell. |user_id| must be
148 // resolved by the instance (i.e. must not be mojom::kInheritUserID).
149 void CreateInstanceForFactory(
150 mojom::ShellClientFactoryPtr factory,
151 const std::string& name,
152 const std::string& user_id,
153 mojom::CapabilityFilterPtr filter,
154 mojom::PIDReceiverRequest pid_receiver);
155 // Called from the instance implementing mojom::Shell. 133 // Called from the instance implementing mojom::Shell.
156 void AddInstanceListener(mojom::InstanceListenerPtr listener); 134 void AddInstanceListener(mojom::InstanceListenerPtr listener);
157 135
158 void CreateShellClient(const Identity& source, 136 void CreateShellClient(const Identity& source,
159 const Identity& shell_client_factory, 137 const Identity& shell_client_factory,
160 const std::string& name, 138 const std::string& name,
161 mojom::ShellClientRequest request); 139 mojom::ShellClientRequest request);
162 // Returns a running ShellClientFactory for |shell_client_factory_identity|, 140 // Returns a running ShellClientFactory for |shell_client_factory_identity|,
163 // if there is not one running one is started for |source_identity|. 141 // if there is not one running one is started for |source_identity|.
164 mojom::ShellClientFactory* GetShellClientFactory( 142 mojom::ShellClientFactory* GetShellClientFactory(
165 const Identity& shell_client_factory_identity, 143 const Identity& shell_client_factory_identity,
166 const Identity& source_identity); 144 const Identity& source_identity);
167 void OnShellClientFactoryLost(const Identity& which);; 145 void OnShellClientFactoryLost(const Identity& which);;
168 146
169 // Callback when remote Catalog resolves mojo:foo to mojo:bar. 147 // Callback when remote Catalog resolves mojo:foo to mojo:bar.
170 // |params| are the params passed to Connect(). 148 // |params| are the params passed to Connect().
171 // |resolved_name| is the mojo: name identifying the physical package 149 // |resolved_name| is the mojo: name identifying the physical package
172 // application. 150 // application.
173 // |file_url| is the resolved file:// URL of the physical package. 151 // |file_url| is the resolved file:// URL of the physical package.
174 // |base_filter| is the CapabilityFilter the requested application should be 152 // |base_filter| is the CapabilitySpecPtr the requested application should be
175 // run with, from its manifest. 153 // run with, from its manifest.
176 void OnGotResolvedName(scoped_ptr<ConnectParams> params, 154 void OnGotResolvedName(scoped_ptr<ConnectParams> params,
177 const String& resolved_name, 155 const String& resolved_name,
178 const String& resolved_instance, 156 const String& resolved_instance,
179 mojom::CapabilityFilterPtr base_filter, 157 mojom::CapabilitySpecPtr capabilities,
180 const String& file_url); 158 const String& file_url);
181 159
182 // Tries to load |target| with an Loader. Returns true if one was registered 160 // Tries to load |target| with an Loader. Returns true if one was registered
183 // and it was loaded, in which case |request| is taken. 161 // and it was loaded, in which case |request| is taken.
184 bool LoadWithLoader(const Identity& target, 162 bool LoadWithLoader(const Identity& target,
185 mojom::ShellClientRequest* request); 163 mojom::ShellClientRequest* request);
186 164
187 // Returns the appropriate loader for |name|, or the default loader if there 165 // Returns the appropriate loader for |name|, or the default loader if there
188 // is no loader configured for the name. 166 // is no loader configured for the name.
189 Loader* GetLoaderForName(const std::string& name); 167 Loader* GetLoaderForName(const std::string& name);
(...skipping 27 matching lines...) Expand all
217 195
218 DISALLOW_COPY_AND_ASSIGN(Shell); 196 DISALLOW_COPY_AND_ASSIGN(Shell);
219 }; 197 };
220 198
221 mojom::Connector::ConnectCallback EmptyConnectCallback(); 199 mojom::Connector::ConnectCallback EmptyConnectCallback();
222 200
223 } // namespace shell 201 } // namespace shell
224 } // namespace mojo 202 } // namespace mojo
225 203
226 #endif // MOJO_SHELL_SHELL_H_ 204 #endif // MOJO_SHELL_SHELL_H_
OLDNEW
« no previous file with comments | « mojo/shell/public/interfaces/shell_resolver.mojom ('k') | mojo/shell/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698