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

Unified Diff: mojo/application/public/cpp/lib/service_registry.cc

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 side-by-side diff with in-line comments
Download patch
Index: mojo/application/public/cpp/lib/service_registry.cc
diff --git a/mojo/application/public/cpp/lib/service_registry.cc b/mojo/application/public/cpp/lib/service_registry.cc
index 911bbebae7a08d8a0db7e15061bd5a41758a9853..4f8e6e6565c1b6494daaac7c2fd8f372437caf23 100644
--- a/mojo/application/public/cpp/lib/service_registry.cc
+++ b/mojo/application/public/cpp/lib/service_registry.cc
@@ -16,35 +16,53 @@ ServiceRegistry::ServiceRegistry(
const std::string& connection_url,
const std::string& remote_url,
ServiceProviderPtr remote_services,
- InterfaceRequest<ServiceProvider> local_services)
+ InterfaceRequest<ServiceProvider> local_services,
+ const std::set<std::string>& allowed_interfaces)
: application_impl_(application_impl),
connection_url_(connection_url),
remote_url_(remote_url),
local_binding_(this),
- remote_service_provider_(remote_services.Pass()) {
+ remote_service_provider_(remote_services.Pass()),
+ allowed_interfaces_(allowed_interfaces),
+ allow_all_interfaces_(allowed_interfaces_.size() == 1 &&
+ allowed_interfaces_.count("*") == 1) {
if (local_services.is_pending())
local_binding_.Bind(local_services.Pass());
}
ServiceRegistry::ServiceRegistry()
- : application_impl_(nullptr), local_binding_(this) {
+ : application_impl_(nullptr),
+ local_binding_(this),
+ allow_all_interfaces_(true) {
}
void ServiceRegistry::SetServiceConnector(ServiceConnector* connector) {
service_connector_registry_.set_service_connector(connector);
}
-void ServiceRegistry::SetServiceConnectorForName(
+bool ServiceRegistry::SetServiceConnectorForName(
ServiceConnector* service_connector,
const std::string& interface_name) {
- service_connector_registry_.SetServiceConnectorForName(service_connector,
- interface_name);
+ if (allow_all_interfaces_ ||
+ allowed_interfaces_.count(interface_name)) {
+ service_connector_registry_.SetServiceConnectorForName(service_connector,
+ interface_name);
+ return true;
+ }
+ DVLOG(2) << "CapabilityFilter prevented connection to interface: " <<
+ interface_name;
+ return false;
}
ServiceProvider* ServiceRegistry::GetLocalServiceProvider() {
return this;
}
+void ServiceRegistry::SetRemoteServiceProviderConnectionErrorHandler(
+ const Closure& handler) {
+ remote_service_provider_.set_connection_error_handler(handler);
+}
+
void ServiceRegistry::RemoveServiceConnectorForName(
const std::string& interface_name) {
service_connector_registry_.RemoveServiceConnectorForName(interface_name);

Powered by Google App Engine
This is Rietveld 408576698