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 26 matching lines...) Expand all Loading... |
37 if (it != name_to_binder_.end()) | 37 if (it != name_to_binder_.end()) |
38 name_to_binder_.erase(it); | 38 name_to_binder_.erase(it); |
39 } | 39 } |
40 | 40 |
41 // mojom::InterfaceProvider: | 41 // mojom::InterfaceProvider: |
42 void InterfaceRegistry::GetInterface(const mojo::String& interface_name, | 42 void InterfaceRegistry::GetInterface(const mojo::String& interface_name, |
43 mojo::ScopedMessagePipeHandle handle) { | 43 mojo::ScopedMessagePipeHandle handle) { |
44 auto iter = name_to_binder_.find(interface_name); | 44 auto iter = name_to_binder_.find(interface_name); |
45 if (iter != name_to_binder_.end()) { | 45 if (iter != name_to_binder_.end()) { |
46 iter->second->BindInterface(connection_, interface_name, std::move(handle)); | 46 iter->second->BindInterface(connection_, interface_name, std::move(handle)); |
47 } else if (connection_ && connection_->AllowsInterface(interface_name)) { | 47 } else if (connection_ && !connection_->AllowsInterface(interface_name)) { |
48 LOG(ERROR) << "Connection CapabilityFilter prevented binding to " | 48 LOG(ERROR) << "Connection CapabilityFilter prevented binding to " |
49 << "interface: " << interface_name << " connection_name:" | 49 << "interface: " << interface_name << " connection_name:" |
50 << connection_->GetConnectionName() << " remote_name:" | 50 << connection_->GetConnectionName() << " remote_name:" |
51 << connection_->GetRemoteIdentity().name(); | 51 << connection_->GetRemoteIdentity().name(); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 bool InterfaceRegistry::SetInterfaceBinderForName( | 55 bool InterfaceRegistry::SetInterfaceBinderForName( |
56 std::unique_ptr<InterfaceBinder> binder, | 56 std::unique_ptr<InterfaceBinder> binder, |
57 const std::string& interface_name) { | 57 const std::string& interface_name) { |
58 if (!connection_ || | 58 if (!connection_ || |
59 (connection_ && connection_->AllowsInterface(interface_name))) { | 59 (connection_ && connection_->AllowsInterface(interface_name))) { |
60 RemoveInterface(interface_name); | 60 RemoveInterface(interface_name); |
61 name_to_binder_[interface_name] = std::move(binder); | 61 name_to_binder_[interface_name] = std::move(binder); |
62 return true; | 62 return true; |
63 } | 63 } |
64 return false; | 64 return false; |
65 } | 65 } |
66 | 66 |
67 } // namespace shell | 67 } // namespace shell |
OLD | NEW |