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

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 contains only
30 // the string value "*" all interfaces may be exposed.
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 SetRemoteServiceProviderConnectionErrorHandler(
47 const Closure& handler) override;
41 48
42 void RemoveServiceConnectorForName(const std::string& interface_name); 49 void RemoveServiceConnectorForName(const std::string& interface_name);
43 50
44 private: 51 private:
45 ~ServiceRegistry() override; 52 ~ServiceRegistry() override;
46 53
47 // ApplicationConnection overrides. 54 // ApplicationConnection overrides.
48 void OnCloseConnection() override; 55 void OnCloseConnection() override;
49 56
50 // ServiceProvider method. 57 // ServiceProvider method.
51 void ConnectToService(const mojo::String& service_name, 58 void ConnectToService(const mojo::String& service_name,
52 ScopedMessagePipeHandle client_handle) override; 59 ScopedMessagePipeHandle client_handle) override;
53 60
54 ApplicationImpl* application_impl_; 61 ApplicationImpl* application_impl_;
55 const std::string connection_url_; 62 const std::string connection_url_;
56 const std::string remote_url_; 63 const std::string remote_url_;
57 Binding<ServiceProvider> local_binding_; 64 Binding<ServiceProvider> local_binding_;
58 ServiceProviderPtr remote_service_provider_; 65 ServiceProviderPtr remote_service_provider_;
59 ServiceConnectorRegistry service_connector_registry_; 66 ServiceConnectorRegistry service_connector_registry_;
67 const std::set<std::string> allowed_interfaces_;
68 const bool allow_all_interfaces_;
60 69
61 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceRegistry); 70 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceRegistry);
62 }; 71 };
63 72
64 } // namespace internal 73 } // namespace internal
65 } // namespace mojo 74 } // namespace mojo
66 75
67 #endif // MOJO_APPLICATION_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_ 76 #endif // MOJO_APPLICATION_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698