Chromium Code Reviews| 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 #include "mojo/application/public/cpp/lib/service_registry.h" | 5 #include "mojo/application/public/cpp/lib/service_registry.h" |
| 6 | 6 |
| 7 #include "mojo/application/public/cpp/application_connection.h" | 7 #include "mojo/application/public/cpp/application_connection.h" |
| 8 #include "mojo/application/public/cpp/application_impl.h" | 8 #include "mojo/application/public/cpp/application_impl.h" |
| 9 #include "mojo/application/public/cpp/service_connector.h" | 9 #include "mojo/application/public/cpp/service_connector.h" |
| 10 | 10 |
| 11 namespace mojo { | 11 namespace mojo { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 ServiceRegistry::ServiceRegistry( | 14 ServiceRegistry::ServiceRegistry( |
| 15 ApplicationImpl* application_impl, | 15 ApplicationImpl* application_impl, |
| 16 const std::string& connection_url, | 16 const std::string& connection_url, |
| 17 const std::string& remote_url, | 17 const std::string& remote_url, |
| 18 ServiceProviderPtr remote_services, | 18 ServiceProviderPtr remote_services, |
| 19 InterfaceRequest<ServiceProvider> local_services) | 19 InterfaceRequest<ServiceProvider> local_services, |
| 20 std::set<std::string> allowed_interfaces) | |
| 20 : application_impl_(application_impl), | 21 : application_impl_(application_impl), |
| 21 connection_url_(connection_url), | 22 connection_url_(connection_url), |
| 22 remote_url_(remote_url), | 23 remote_url_(remote_url), |
| 23 local_binding_(this), | 24 local_binding_(this), |
| 24 remote_service_provider_(remote_services.Pass()) { | 25 remote_service_provider_(remote_services.Pass()), |
| 26 allowed_interfaces_(allowed_interfaces) { | |
| 25 if (local_services.is_pending()) | 27 if (local_services.is_pending()) |
| 26 local_binding_.Bind(local_services.Pass()); | 28 local_binding_.Bind(local_services.Pass()); |
| 27 } | 29 } |
| 28 | 30 |
| 29 ServiceRegistry::ServiceRegistry() | 31 ServiceRegistry::ServiceRegistry() |
| 30 : application_impl_(nullptr), local_binding_(this) { | 32 : application_impl_(nullptr), local_binding_(this) { |
| 31 } | 33 } |
| 32 | 34 |
| 33 void ServiceRegistry::SetServiceConnector(ServiceConnector* connector) { | 35 void ServiceRegistry::SetServiceConnector(ServiceConnector* connector) { |
| 34 service_connector_registry_.set_service_connector(connector); | 36 service_connector_registry_.set_service_connector(connector); |
| 35 } | 37 } |
| 36 | 38 |
| 37 void ServiceRegistry::SetServiceConnectorForName( | 39 void ServiceRegistry::SetServiceConnectorForName( |
| 38 ServiceConnector* service_connector, | 40 ServiceConnector* service_connector, |
| 39 const std::string& interface_name) { | 41 const std::string& interface_name) { |
| 40 service_connector_registry_.SetServiceConnectorForName(service_connector, | 42 if (allowed_interfaces_.empty() || |
|
yzshen1
2015/07/22 17:53:58
Please see my comment in the shell.mojom.
| |
| 41 interface_name); | 43 allowed_interfaces_.count(interface_name)) { |
| 44 service_connector_registry_.SetServiceConnectorForName(service_connector, | |
| 45 interface_name); | |
| 46 } | |
| 42 } | 47 } |
| 43 | 48 |
| 44 ServiceProvider* ServiceRegistry::GetLocalServiceProvider() { | 49 ServiceProvider* ServiceRegistry::GetLocalServiceProvider() { |
| 45 return this; | 50 return this; |
| 46 } | 51 } |
| 47 | 52 |
| 48 void ServiceRegistry::RemoveServiceConnectorForName( | 53 void ServiceRegistry::RemoveServiceConnectorForName( |
| 49 const std::string& interface_name) { | 54 const std::string& interface_name) { |
| 50 service_connector_registry_.RemoveServiceConnectorForName(interface_name); | 55 service_connector_registry_.RemoveServiceConnectorForName(interface_name); |
| 51 if (service_connector_registry_.empty()) | 56 if (service_connector_registry_.empty()) |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 73 } | 78 } |
| 74 | 79 |
| 75 void ServiceRegistry::ConnectToService(const mojo::String& service_name, | 80 void ServiceRegistry::ConnectToService(const mojo::String& service_name, |
| 76 ScopedMessagePipeHandle client_handle) { | 81 ScopedMessagePipeHandle client_handle) { |
| 77 service_connector_registry_.ConnectToService(this, service_name, | 82 service_connector_registry_.ConnectToService(this, service_name, |
| 78 client_handle.Pass()); | 83 client_handle.Pass()); |
| 79 } | 84 } |
| 80 | 85 |
| 81 } // namespace internal | 86 } // namespace internal |
| 82 } // namespace mojo | 87 } // namespace mojo |
| OLD | NEW |