| 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 "mojo/shell/public/cpp/lib/connector_impl.h" | 5 #include "mojo/shell/public/cpp/lib/connector_impl.h" |
| 6 | 6 |
| 7 #include "mojo/shell/public/cpp/lib/connection_impl.h" | 7 #include "mojo/shell/public/cpp/lib/connection_impl.h" |
| 8 | 8 |
| 9 namespace mojo { | 9 namespace mojo { |
| 10 | 10 |
| 11 Connector::ConnectParams::ConnectParams(const std::string& url) | 11 Connector::ConnectParams::ConnectParams(const std::string& url) |
| 12 : url_(url), | 12 : url_(url), |
| 13 filter_(shell::mojom::CapabilityFilter::New()), | |
| 14 user_id_(shell::mojom::Connector::kUserInherit) { | 13 user_id_(shell::mojom::Connector::kUserInherit) { |
| 15 filter_->filter.SetToEmpty(); | |
| 16 } | 14 } |
| 17 Connector::ConnectParams::~ConnectParams() {} | 15 Connector::ConnectParams::~ConnectParams() {} |
| 18 | 16 |
| 19 ConnectorImpl::ConnectorImpl(shell::mojom::ConnectorPtrInfo unbound_state) | 17 ConnectorImpl::ConnectorImpl(shell::mojom::ConnectorPtrInfo unbound_state) |
| 20 : unbound_state_(std::move(unbound_state)) {} | 18 : unbound_state_(std::move(unbound_state)) {} |
| 21 ConnectorImpl::~ConnectorImpl() {} | 19 ConnectorImpl::~ConnectorImpl() {} |
| 22 | 20 |
| 23 scoped_ptr<Connection> ConnectorImpl::Connect(const std::string& url) { | 21 scoped_ptr<Connection> ConnectorImpl::Connect(const std::string& url) { |
| 24 ConnectParams params(url); | 22 ConnectParams params(url); |
| 25 params.set_filter(CreatePermissiveCapabilityFilter()); | |
| 26 return Connect(¶ms); | 23 return Connect(¶ms); |
| 27 } | 24 } |
| 28 | 25 |
| 29 scoped_ptr<Connection> ConnectorImpl::Connect(ConnectParams* params) { | 26 scoped_ptr<Connection> ConnectorImpl::Connect(ConnectParams* params) { |
| 30 // Bind this object to the current thread the first time it is used to | 27 // Bind this object to the current thread the first time it is used to |
| 31 // connect. | 28 // connect. |
| 32 if (!connector_.is_bound()) { | 29 if (!connector_.is_bound()) { |
| 33 if (!unbound_state_.is_valid()) | 30 if (!unbound_state_.is_valid()) |
| 34 return nullptr; | 31 return nullptr; |
| 35 connector_.Bind(std::move(unbound_state_)); | 32 connector_.Bind(std::move(unbound_state_)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 52 shell::mojom::InterfaceProviderRequest remote_request = | 49 shell::mojom::InterfaceProviderRequest remote_request = |
| 53 GetProxy(&remote_interfaces); | 50 GetProxy(&remote_interfaces); |
| 54 scoped_ptr<internal::ConnectionImpl> registry(new internal::ConnectionImpl( | 51 scoped_ptr<internal::ConnectionImpl> registry(new internal::ConnectionImpl( |
| 55 application_url, application_url, | 52 application_url, application_url, |
| 56 shell::mojom::Connector::kInvalidApplicationID, params->user_id(), | 53 shell::mojom::Connector::kInvalidApplicationID, params->user_id(), |
| 57 std::move(remote_interfaces), std::move(local_request), allowed)); | 54 std::move(remote_interfaces), std::move(local_request), allowed)); |
| 58 connector_->Connect(application_url, | 55 connector_->Connect(application_url, |
| 59 params->user_id(), | 56 params->user_id(), |
| 60 std::move(remote_request), | 57 std::move(remote_request), |
| 61 std::move(local_interfaces), | 58 std::move(local_interfaces), |
| 62 params->TakeFilter(), | |
| 63 registry->GetConnectCallback()); | 59 registry->GetConnectCallback()); |
| 64 return std::move(registry); | 60 return std::move(registry); |
| 65 } | 61 } |
| 66 | 62 |
| 67 scoped_ptr<Connector> ConnectorImpl::Clone() { | 63 scoped_ptr<Connector> ConnectorImpl::Clone() { |
| 68 shell::mojom::ConnectorPtr connector; | 64 shell::mojom::ConnectorPtr connector; |
| 69 connector_->Clone(GetProxy(&connector)); | 65 connector_->Clone(GetProxy(&connector)); |
| 70 return make_scoped_ptr( | 66 return make_scoped_ptr( |
| 71 new ConnectorImpl(connector.PassInterface())); | 67 new ConnectorImpl(connector.PassInterface())); |
| 72 } | 68 } |
| 73 | 69 |
| 74 } // namespace mojo | 70 } // namespace mojo |
| OLD | NEW |