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 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 70 } |
71 | 71 |
72 void ApplicationInstance::BindPIDReceiver( | 72 void ApplicationInstance::BindPIDReceiver( |
73 InterfaceRequest<mojom::PIDReceiver> pid_receiver) { | 73 InterfaceRequest<mojom::PIDReceiver> pid_receiver) { |
74 pid_receiver_binding_.Bind(std::move(pid_receiver)); | 74 pid_receiver_binding_.Bind(std::move(pid_receiver)); |
75 } | 75 } |
76 | 76 |
77 // Shell implementation: | 77 // Shell implementation: |
78 void ApplicationInstance::ConnectToApplication( | 78 void ApplicationInstance::ConnectToApplication( |
79 URLRequestPtr app_request, | 79 URLRequestPtr app_request, |
80 InterfaceRequest<ServiceProvider> services, | 80 InterfaceRequest<InterfaceProvider> remote_interfaces, |
81 ServiceProviderPtr exposed_services, | 81 InterfaceProviderPtr local_interfaces, |
82 mojom::CapabilityFilterPtr filter, | 82 mojom::CapabilityFilterPtr filter, |
83 const ConnectToApplicationCallback& callback) { | 83 const ConnectToApplicationCallback& callback) { |
84 std::string url_string = app_request->url.To<std::string>(); | 84 std::string url_string = app_request->url.To<std::string>(); |
85 GURL url(url_string); | 85 GURL url(url_string); |
86 if (!url.is_valid()) { | 86 if (!url.is_valid()) { |
87 LOG(ERROR) << "Error: invalid URL: " << url_string; | 87 LOG(ERROR) << "Error: invalid URL: " << url_string; |
88 callback.Run(kInvalidApplicationID, kInvalidApplicationID); | 88 callback.Run(kInvalidApplicationID, kInvalidApplicationID); |
89 return; | 89 return; |
90 } | 90 } |
91 if (allow_any_application_ || | 91 if (allow_any_application_ || |
92 identity_.filter().find(url.spec()) != identity_.filter().end()) { | 92 identity_.filter().find(url.spec()) != identity_.filter().end()) { |
93 CapabilityFilter capability_filter = GetPermissiveCapabilityFilter(); | 93 CapabilityFilter capability_filter = GetPermissiveCapabilityFilter(); |
94 if (!filter.is_null()) | 94 if (!filter.is_null()) |
95 capability_filter = filter->filter.To<CapabilityFilter>(); | 95 capability_filter = filter->filter.To<CapabilityFilter>(); |
96 | 96 |
97 scoped_ptr<ConnectToApplicationParams> params( | 97 scoped_ptr<ConnectToApplicationParams> params( |
98 new ConnectToApplicationParams); | 98 new ConnectToApplicationParams); |
99 params->SetSource(this); | 99 params->SetSource(this); |
100 GURL app_url(app_request->url.get()); | 100 GURL app_url(app_request->url.get()); |
101 params->SetTargetURLRequest( | 101 params->SetTargetURLRequest( |
102 std::move(app_request), | 102 std::move(app_request), |
103 Identity(app_url, std::string(), capability_filter)); | 103 Identity(app_url, std::string(), capability_filter)); |
104 params->set_services(std::move(services)); | 104 params->set_remote_interfaces(std::move(remote_interfaces)); |
105 params->set_exposed_services(std::move(exposed_services)); | 105 params->set_local_interfaces(std::move(local_interfaces)); |
106 params->set_connect_callback(callback); | 106 params->set_connect_callback(callback); |
107 manager_->ConnectToApplication(std::move(params)); | 107 manager_->ConnectToApplication(std::move(params)); |
108 } else { | 108 } else { |
109 LOG(WARNING) << "CapabilityFilter prevented connection from: " << | 109 LOG(WARNING) << "CapabilityFilter prevented connection from: " << |
110 identity_.url() << " to: " << url.spec(); | 110 identity_.url() << " to: " << url.spec(); |
111 callback.Run(kInvalidApplicationID, kInvalidApplicationID); | 111 callback.Run(kInvalidApplicationID, kInvalidApplicationID); |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 void ApplicationInstance::QuitApplication() { | 115 void ApplicationInstance::QuitApplication() { |
(...skipping 20 matching lines...) Expand all Loading... |
136 params->connect_callback().Run(id_, requesting_content_handler_id_); | 136 params->connect_callback().Run(id_, requesting_content_handler_id_); |
137 AllowedInterfaces interfaces; | 137 AllowedInterfaces interfaces; |
138 interfaces.insert("*"); | 138 interfaces.insert("*"); |
139 if (!params->source().is_null()) | 139 if (!params->source().is_null()) |
140 interfaces = GetAllowedInterfaces(params->source().filter(), identity_); | 140 interfaces = GetAllowedInterfaces(params->source().filter(), identity_); |
141 | 141 |
142 ApplicationInstance* source = | 142 ApplicationInstance* source = |
143 manager_->GetApplicationInstance(params->source()); | 143 manager_->GetApplicationInstance(params->source()); |
144 uint32_t source_id = source ? source->id() : Shell::kInvalidApplicationID; | 144 uint32_t source_id = source ? source->id() : Shell::kInvalidApplicationID; |
145 shell_client_->AcceptConnection( | 145 shell_client_->AcceptConnection( |
146 params->source().url().spec(), source_id, params->TakeServices(), | 146 params->source().url().spec(), source_id, params->TakeRemoteInterfaces(), |
147 params->TakeExposedServices(), Array<String>::From(interfaces), | 147 params->TakeLocalInterfaces(), Array<String>::From(interfaces), |
148 params->target().url().spec()); | 148 params->target().url().spec()); |
149 } | 149 } |
150 | 150 |
151 void ApplicationInstance::OnConnectionError() { | 151 void ApplicationInstance::OnConnectionError() { |
152 std::vector<ConnectToApplicationParams*> queued_client_requests; | 152 std::vector<ConnectToApplicationParams*> queued_client_requests; |
153 queued_client_requests_.swap(queued_client_requests); | 153 queued_client_requests_.swap(queued_client_requests); |
154 auto manager = manager_; | 154 auto manager = manager_; |
155 manager_->OnApplicationInstanceError(this); | 155 manager_->OnApplicationInstanceError(this); |
156 //|this| is deleted. | 156 //|this| is deleted. |
157 | 157 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 queue_requests_ = false; | 192 queue_requests_ = false; |
193 for (auto request : queued_client_requests_) | 193 for (auto request : queued_client_requests_) |
194 CallAcceptConnection(make_scoped_ptr(request)); | 194 CallAcceptConnection(make_scoped_ptr(request)); |
195 | 195 |
196 queued_client_requests_.clear(); | 196 queued_client_requests_.clear(); |
197 } | 197 } |
198 | 198 |
199 } // namespace shell | 199 } // namespace shell |
200 } // namespace mojo | 200 } // namespace mojo |
OLD | NEW |