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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // mojom::InterfaceProvider: | 57 // mojom::InterfaceProvider: |
58 void InterfaceRegistry::GetInterface(const mojo::String& interface_name, | 58 void InterfaceRegistry::GetInterface(const mojo::String& interface_name, |
59 mojo::ScopedMessagePipeHandle handle) { | 59 mojo::ScopedMessagePipeHandle handle) { |
60 if (is_paused_) { | 60 if (is_paused_) { |
61 pending_interface_requests_.emplace(interface_name, std::move(handle)); | 61 pending_interface_requests_.emplace(interface_name, std::move(handle)); |
62 return; | 62 return; |
63 } | 63 } |
64 | 64 |
65 auto iter = name_to_binder_.find(interface_name); | 65 auto iter = name_to_binder_.find(interface_name); |
66 if (iter != name_to_binder_.end()) { | 66 if (iter != name_to_binder_.end()) { |
67 iter->second->BindInterface(connection_, interface_name, std::move(handle)); | 67 Identity remote_identity = |
| 68 connection_ ? connection_->GetRemoteIdentity() : Identity(); |
| 69 iter->second->BindInterface(remote_identity, |
| 70 interface_name, |
| 71 std::move(handle)); |
68 } else if (connection_ && !connection_->AllowsInterface(interface_name)) { | 72 } else if (connection_ && !connection_->AllowsInterface(interface_name)) { |
69 LOG(ERROR) << "Connection CapabilityFilter prevented binding to " | 73 LOG(ERROR) << "Connection CapabilityFilter prevented binding to " |
70 << "interface: " << interface_name << " connection_name:" | 74 << "interface: " << interface_name << " connection_name:" |
71 << connection_->GetConnectionName() << " remote_name:" | 75 << connection_->GetConnectionName() << " remote_name:" |
72 << connection_->GetRemoteIdentity().name(); | 76 << connection_->GetRemoteIdentity().name(); |
73 } else if (!default_binder_.is_null()) { | 77 } else if (!default_binder_.is_null()) { |
74 default_binder_.Run(interface_name, std::move(handle)); | 78 default_binder_.Run(interface_name, std::move(handle)); |
| 79 } else { |
| 80 LOG(ERROR) << "Failed to locate a binder for interface: " << interface_name; |
75 } | 81 } |
76 } | 82 } |
77 | 83 |
78 bool InterfaceRegistry::SetInterfaceBinderForName( | 84 bool InterfaceRegistry::SetInterfaceBinderForName( |
79 std::unique_ptr<InterfaceBinder> binder, | 85 std::unique_ptr<InterfaceBinder> binder, |
80 const std::string& interface_name) { | 86 const std::string& interface_name) { |
81 if (!connection_ || | 87 if (!connection_ || |
82 (connection_ && connection_->AllowsInterface(interface_name))) { | 88 (connection_ && connection_->AllowsInterface(interface_name))) { |
83 RemoveInterface(interface_name); | 89 RemoveInterface(interface_name); |
84 name_to_binder_[interface_name] = std::move(binder); | 90 name_to_binder_[interface_name] = std::move(binder); |
85 return true; | 91 return true; |
86 } | 92 } |
87 return false; | 93 return false; |
88 } | 94 } |
89 | 95 |
90 } // namespace shell | 96 } // namespace shell |
OLD | NEW |