OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/shell/public/cpp/interface_registry.h" | 5 #include "services/shell/public/cpp/interface_registry.h" |
6 | 6 |
7 #include "services/shell/public/cpp/connection.h" | 7 #include "services/shell/public/cpp/connection.h" |
8 | 8 |
9 namespace shell { | 9 namespace shell { |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 } | 30 } |
31 | 31 |
32 // mojom::InterfaceProvider: | 32 // mojom::InterfaceProvider: |
33 void InterfaceRegistry::GetInterface(const mojo::String& interface_name, | 33 void InterfaceRegistry::GetInterface(const mojo::String& interface_name, |
34 mojo::ScopedMessagePipeHandle handle) { | 34 mojo::ScopedMessagePipeHandle handle) { |
35 auto iter = name_to_binder_.find(interface_name); | 35 auto iter = name_to_binder_.find(interface_name); |
36 InterfaceBinder* binder = iter != name_to_binder_.end() ? iter->second : | 36 InterfaceBinder* binder = iter != name_to_binder_.end() ? iter->second : |
37 default_binder_; | 37 default_binder_; |
38 if (binder) { | 38 if (binder) { |
39 binder->BindInterface(connection_, interface_name, std::move(handle)); | 39 binder->BindInterface(connection_, interface_name, std::move(handle)); |
40 } else { | 40 } else if (connection_ && !connection_->AllowsInterface(interface_name)) { |
41 LOG(WARNING) << "Connection CapabilityFilter prevented binding to " | 41 LOG(ERROR) << "CapabilitySpec of: " |
42 << "interface: " << interface_name << " connection_name:" | 42 << connection_->GetRemoteIdentity().name() |
43 << connection_->GetConnectionName() << " remote_name:" | 43 << " prevented binding interface: " << interface_name |
44 << connection_->GetRemoteIdentity().name(); | 44 << " provided by: " << connection_->GetConnectionName(); |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
48 bool InterfaceRegistry::SetInterfaceBinderForName( | 48 bool InterfaceRegistry::SetInterfaceBinderForName( |
49 InterfaceBinder* binder, | 49 InterfaceBinder* binder, |
50 const std::string& interface_name) { | 50 const std::string& interface_name) { |
51 if (!connection_ || | 51 if (!connection_ || |
52 (connection_ && connection_->AllowsInterface(interface_name))) { | 52 (connection_ && connection_->AllowsInterface(interface_name))) { |
53 RemoveInterfaceBinderForName(interface_name); | 53 RemoveInterfaceBinderForName(interface_name); |
54 name_to_binder_[interface_name] = binder; | 54 name_to_binder_[interface_name] = binder; |
55 return true; | 55 return true; |
56 } | 56 } |
57 return false; | 57 return false; |
58 } | 58 } |
59 | 59 |
60 void InterfaceRegistry::RemoveInterfaceBinderForName( | 60 void InterfaceRegistry::RemoveInterfaceBinderForName( |
61 const std::string& interface_name) { | 61 const std::string& interface_name) { |
62 NameToInterfaceBinderMap::iterator it = name_to_binder_.find(interface_name); | 62 NameToInterfaceBinderMap::iterator it = name_to_binder_.find(interface_name); |
63 if (it == name_to_binder_.end()) | 63 if (it == name_to_binder_.end()) |
64 return; | 64 return; |
65 delete it->second; | 65 delete it->second; |
66 name_to_binder_.erase(it); | 66 name_to_binder_.erase(it); |
67 } | 67 } |
68 | 68 |
69 } // namespace shell | 69 } // namespace shell |
OLD | NEW |