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 17 matching lines...) Expand all Loading... |
28 mojom::InterfaceProviderPtr InterfaceRegistry::TakeClientHandle() { | 28 mojom::InterfaceProviderPtr InterfaceRegistry::TakeClientHandle() { |
29 return std::move(client_handle_); | 29 return std::move(client_handle_); |
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 { | |
41 LOG(ERROR) << "Connection CapabilityFilter prevented binding to interface: " | |
42 << interface_name << " connection_name:" | |
43 << connection_->GetConnectionName() << " remote_name:" | |
44 << connection_->GetRemoteIdentity().name(); | |
45 } | |
46 } | 40 } |
47 | 41 |
48 bool InterfaceRegistry::SetInterfaceBinderForName( | 42 bool InterfaceRegistry::SetInterfaceBinderForName( |
49 InterfaceBinder* binder, | 43 InterfaceBinder* binder, |
50 const std::string& interface_name) { | 44 const std::string& interface_name) { |
51 if (!connection_ || | 45 if (!connection_ || |
52 (connection_ && connection_->AllowsInterface(interface_name))) { | 46 (connection_ && connection_->AllowsInterface(interface_name))) { |
53 RemoveInterfaceBinderForName(interface_name); | 47 RemoveInterfaceBinderForName(interface_name); |
54 name_to_binder_[interface_name] = binder; | 48 name_to_binder_[interface_name] = binder; |
55 return true; | 49 return true; |
56 } | 50 } |
| 51 LOG(WARNING) << "Connection CapabilityFilter prevented binding to interface: " |
| 52 << interface_name << " connection_name:" |
| 53 << connection_->GetConnectionName() << " remote_name:" |
| 54 << connection_->GetRemoteIdentity().name(); |
57 return false; | 55 return false; |
58 } | 56 } |
59 | 57 |
60 void InterfaceRegistry::RemoveInterfaceBinderForName( | 58 void InterfaceRegistry::RemoveInterfaceBinderForName( |
61 const std::string& interface_name) { | 59 const std::string& interface_name) { |
62 NameToInterfaceBinderMap::iterator it = name_to_binder_.find(interface_name); | 60 NameToInterfaceBinderMap::iterator it = name_to_binder_.find(interface_name); |
63 if (it == name_to_binder_.end()) | 61 if (it == name_to_binder_.end()) |
64 return; | 62 return; |
65 delete it->second; | 63 delete it->second; |
66 name_to_binder_.erase(it); | 64 name_to_binder_.erase(it); |
67 } | 65 } |
68 | 66 |
69 } // namespace shell | 67 } // namespace shell |
OLD | NEW |