Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / mojo / application / public / cpp / lib / service_registry.h
blob8cb1d1b411c7e1aa092a9b604c82f726f9dbf737
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
3 // found in the LICENSE file.
5 #ifndef MOJO_APPLICATION_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_
6 #define MOJO_APPLICATION_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_
8 #include <set>
9 #include <string>
11 #include "mojo/application/public/cpp/application_connection.h"
12 #include "mojo/application/public/cpp/lib/service_connector_registry.h"
13 #include "mojo/application/public/interfaces/service_provider.mojom.h"
14 #include "mojo/public/cpp/bindings/binding.h"
16 namespace mojo {
17 namespace internal {
19 // A ServiceRegistry represents each half of a connection between two
20 // applications, allowing customization of which services are published to the
21 // other.
22 class ServiceRegistry : public ServiceProvider, public ApplicationConnection {
23 public:
24 ServiceRegistry();
25 // |allowed_interfaces| are the set of interfaces that the shell has allowed
26 // an application to expose to another application. If this set contains only
27 // the string value "*" all interfaces may be exposed.
28 ServiceRegistry(const std::string& connection_url,
29 const std::string& remote_url,
30 ServiceProviderPtr remote_services,
31 InterfaceRequest<ServiceProvider> local_services,
32 const std::set<std::string>& allowed_interfaces);
33 ~ServiceRegistry() override;
35 // ApplicationConnection overrides.
36 void SetServiceConnector(ServiceConnector* service_connector) override;
37 bool SetServiceConnectorForName(ServiceConnector* service_connector,
38 const std::string& interface_name) override;
39 const std::string& GetConnectionURL() override;
40 const std::string& GetRemoteApplicationURL() override;
41 ServiceProvider* GetServiceProvider() override;
42 ServiceProvider* GetLocalServiceProvider() override;
43 void SetRemoteServiceProviderConnectionErrorHandler(
44 const Closure& handler) override;
45 base::WeakPtr<ApplicationConnection> GetWeakPtr() override;
47 void RemoveServiceConnectorForName(const std::string& interface_name);
49 private:
50 // ServiceProvider method.
51 void ConnectToService(const mojo::String& service_name,
52 ScopedMessagePipeHandle client_handle) override;
54 const std::string connection_url_;
55 const std::string remote_url_;
56 Binding<ServiceProvider> local_binding_;
57 ServiceProviderPtr remote_service_provider_;
58 ServiceConnectorRegistry service_connector_registry_;
59 const std::set<std::string> allowed_interfaces_;
60 const bool allow_all_interfaces_;
61 base::WeakPtrFactory<ApplicationConnection> weak_factory_;
63 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceRegistry);
66 } // namespace internal
67 } // namespace mojo
69 #endif // MOJO_APPLICATION_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_