OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/application_instance.h" | 5 #include "mojo/shell/application_instance.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/atomic_sequence_num.h" | 11 #include "base/atomic_sequence_num.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "mojo/common/common_type_converters.h" | 14 #include "mojo/common/common_type_converters.h" |
15 #include "mojo/common/url_type_converters.h" | 15 #include "mojo/common/url_type_converters.h" |
16 #include "mojo/shell/application_manager.h" | 16 #include "mojo/shell/application_manager.h" |
| 17 #include "mojo/shell/capability_filter.h" |
17 | 18 |
18 namespace mojo { | 19 namespace mojo { |
19 namespace shell { | 20 namespace shell { |
20 | 21 |
21 ApplicationInstance::ApplicationInstance( | 22 ApplicationInstance::ApplicationInstance( |
22 mojom::ShellClientPtr shell_client, | 23 mojom::ShellClientPtr shell_client, |
23 ApplicationManager* manager, | 24 ApplicationManager* manager, |
24 const Identity& identity) | 25 const Identity& identity) |
25 : manager_(manager), | 26 : manager_(manager), |
26 id_(GenerateUniqueID()), | 27 id_(GenerateUniqueID()), |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 base::Bind(&ApplicationInstance::OnQuitRequestedResult, | 78 base::Bind(&ApplicationInstance::OnQuitRequestedResult, |
78 base::Unretained(this))); | 79 base::Unretained(this))); |
79 } | 80 } |
80 | 81 |
81 // Connector implementation: | 82 // Connector implementation: |
82 void ApplicationInstance::Connect( | 83 void ApplicationInstance::Connect( |
83 const String& app_url, | 84 const String& app_url, |
84 uint32_t user_id, | 85 uint32_t user_id, |
85 shell::mojom::InterfaceProviderRequest remote_interfaces, | 86 shell::mojom::InterfaceProviderRequest remote_interfaces, |
86 shell::mojom::InterfaceProviderPtr local_interfaces, | 87 shell::mojom::InterfaceProviderPtr local_interfaces, |
87 mojom::CapabilityFilterPtr filter, | |
88 const ConnectCallback& callback) { | 88 const ConnectCallback& callback) { |
89 GURL url = app_url.To<GURL>(); | 89 GURL url = app_url.To<GURL>(); |
90 if (!url.is_valid()) { | 90 if (!url.is_valid()) { |
91 LOG(ERROR) << "Error: invalid URL: " << app_url; | 91 LOG(ERROR) << "Error: invalid URL: " << app_url; |
92 callback.Run(kInvalidApplicationID); | 92 callback.Run(kInvalidApplicationID); |
93 return; | 93 return; |
94 } | 94 } |
95 if (allow_any_application_ || | 95 if (allow_any_application_ || |
96 identity_.filter().find(url.spec()) != identity_.filter().end()) { | 96 identity_.filter().find(url.spec()) != identity_.filter().end()) { |
97 CapabilityFilter capability_filter = GetPermissiveCapabilityFilter(); | |
98 if (!filter.is_null()) | |
99 capability_filter = filter->filter.To<CapabilityFilter>(); | |
100 | |
101 scoped_ptr<ConnectParams> params(new ConnectParams); | 97 scoped_ptr<ConnectParams> params(new ConnectParams); |
102 params->set_source(identity_); | 98 params->set_source(identity_); |
103 params->set_target( | 99 params->set_target(Identity(url, std::string(), user_id)); |
104 Identity(url, std::string(), user_id, capability_filter)); | |
105 params->set_remote_interfaces(std::move(remote_interfaces)); | 100 params->set_remote_interfaces(std::move(remote_interfaces)); |
106 params->set_local_interfaces(std::move(local_interfaces)); | 101 params->set_local_interfaces(std::move(local_interfaces)); |
107 params->set_connect_callback(callback); | 102 params->set_connect_callback(callback); |
108 manager_->Connect(std::move(params)); | 103 manager_->Connect(std::move(params)); |
109 } else { | 104 } else { |
110 LOG(WARNING) << "CapabilityFilter prevented connection from: " << | 105 LOG(WARNING) << "CapabilityFilter prevented connection from: " << |
111 identity_.url() << " to: " << url.spec(); | 106 identity_.url() << " to: " << url.spec(); |
112 callback.Run(kInvalidApplicationID); | 107 callback.Run(kInvalidApplicationID); |
113 } | 108 } |
114 } | 109 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 160 |
166 queue_requests_ = false; | 161 queue_requests_ = false; |
167 for (auto request : queued_client_requests_) | 162 for (auto request : queued_client_requests_) |
168 CallAcceptConnection(make_scoped_ptr(request)); | 163 CallAcceptConnection(make_scoped_ptr(request)); |
169 | 164 |
170 queued_client_requests_.clear(); | 165 queued_client_requests_.clear(); |
171 } | 166 } |
172 | 167 |
173 } // namespace shell | 168 } // namespace shell |
174 } // namespace mojo | 169 } // namespace mojo |
OLD | NEW |