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