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

Side by Side Diff: mojo/application/public/cpp/lib/service_registry.h

Issue 1244233002: Allow trusted brokers to restrict connections for spawned applications to whitelisted applications … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 5 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
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_APPLICATION_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_ 5 #ifndef MOJO_APPLICATION_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_
6 #define MOJO_APPLICATION_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_ 6 #define MOJO_APPLICATION_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_
7 7
8 #include <set>
8 #include <string> 9 #include <string>
9 10
10 #include "mojo/application/public/cpp/application_connection.h" 11 #include "mojo/application/public/cpp/application_connection.h"
11 #include "mojo/application/public/cpp/lib/service_connector_registry.h" 12 #include "mojo/application/public/cpp/lib/service_connector_registry.h"
12 #include "mojo/application/public/interfaces/service_provider.mojom.h" 13 #include "mojo/application/public/interfaces/service_provider.mojom.h"
13 14
14 namespace mojo { 15 namespace mojo {
15 16
16 class Application; 17 class Application;
17 class ApplicationImpl; 18 class ApplicationImpl;
18 19
19 namespace internal { 20 namespace internal {
20 21
21 // A ServiceRegistry represents each half of a connection between two 22 // A ServiceRegistry represents each half of a connection between two
22 // applications, allowing customization of which services are published to the 23 // applications, allowing customization of which services are published to the
23 // other. 24 // other.
24 class ServiceRegistry : public ServiceProvider, public ApplicationConnection { 25 class ServiceRegistry : public ServiceProvider, public ApplicationConnection {
25 public: 26 public:
26 ServiceRegistry(); 27 ServiceRegistry();
28 // |allowed_interfaces| are the set of interfaces that the shell has allowed
29 // an application to expose to another application. If this set is empty, the
sky 2015/07/24 15:36:55 Isn't allow_all only true if the set contains "*"?
30 // application is allowed to expose all of its interfaces.
27 ServiceRegistry(ApplicationImpl* application_impl, 31 ServiceRegistry(ApplicationImpl* application_impl,
28 const std::string& connection_url, 32 const std::string& connection_url,
29 const std::string& remote_url, 33 const std::string& remote_url,
30 ServiceProviderPtr remote_services, 34 ServiceProviderPtr remote_services,
31 InterfaceRequest<ServiceProvider> local_services); 35 InterfaceRequest<ServiceProvider> local_services,
36 const std::set<std::string>& allowed_interfaces);
32 37
33 // ApplicationConnection overrides. 38 // ApplicationConnection overrides.
34 void SetServiceConnector(ServiceConnector* service_connector) override; 39 void SetServiceConnector(ServiceConnector* service_connector) override;
35 void SetServiceConnectorForName(ServiceConnector* service_connector, 40 bool SetServiceConnectorForName(ServiceConnector* service_connector,
36 const std::string& interface_name) override; 41 const std::string& interface_name) override;
37 const std::string& GetConnectionURL() override; 42 const std::string& GetConnectionURL() override;
38 const std::string& GetRemoteApplicationURL() override; 43 const std::string& GetRemoteApplicationURL() override;
39 ServiceProvider* GetServiceProvider() override; 44 ServiceProvider* GetServiceProvider() override;
40 ServiceProvider* GetLocalServiceProvider() override; 45 ServiceProvider* GetLocalServiceProvider() override;
46 void SetConnectionErrorHandler(const Closure& handler) override;
41 47
42 void RemoveServiceConnectorForName(const std::string& interface_name); 48 void RemoveServiceConnectorForName(const std::string& interface_name);
43 49
44 private: 50 private:
45 ~ServiceRegistry() override; 51 ~ServiceRegistry() override;
46 52
47 // ApplicationConnection overrides. 53 // ApplicationConnection overrides.
48 void OnCloseConnection() override; 54 void OnCloseConnection() override;
49 55
50 // ServiceProvider method. 56 // ServiceProvider method.
51 void ConnectToService(const mojo::String& service_name, 57 void ConnectToService(const mojo::String& service_name,
52 ScopedMessagePipeHandle client_handle) override; 58 ScopedMessagePipeHandle client_handle) override;
53 59
54 ApplicationImpl* application_impl_; 60 ApplicationImpl* application_impl_;
55 const std::string connection_url_; 61 const std::string connection_url_;
56 const std::string remote_url_; 62 const std::string remote_url_;
57 Binding<ServiceProvider> local_binding_; 63 Binding<ServiceProvider> local_binding_;
58 ServiceProviderPtr remote_service_provider_; 64 ServiceProviderPtr remote_service_provider_;
59 ServiceConnectorRegistry service_connector_registry_; 65 ServiceConnectorRegistry service_connector_registry_;
66 const std::set<std::string> allowed_interfaces_;
67 const bool allow_all_interfaces_;
sky 2015/07/24 15:36:55 nit: As you can calculate allow_all_interfaces_ fr
60 68
61 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceRegistry); 69 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceRegistry);
62 }; 70 };
63 71
64 } // namespace internal 72 } // namespace internal
65 } // namespace mojo 73 } // namespace mojo
66 74
67 #endif // MOJO_APPLICATION_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_ 75 #endif // MOJO_APPLICATION_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698