OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/service_manager.h" | 5 #include "services/shell/service_manager.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 const char kCatalogName[] = "mojo:catalog"; | 35 const char kCatalogName[] = "mojo:catalog"; |
36 const char kServiceManagerName[] = "mojo:shell"; | 36 const char kServiceManagerName[] = "mojo:shell"; |
37 const char kCapabilityClass_UserID[] = "shell:user_id"; | 37 const char kCapabilityClass_UserID[] = "shell:user_id"; |
38 const char kCapabilityClass_ClientProcess[] = "shell:client_process"; | 38 const char kCapabilityClass_ClientProcess[] = "shell:client_process"; |
39 const char kCapabilityClass_InstanceName[] = "shell:instance_name"; | 39 const char kCapabilityClass_InstanceName[] = "shell:instance_name"; |
40 const char kCapabilityClass_AllUsers[] = "shell:all_users"; | 40 const char kCapabilityClass_AllUsers[] = "shell:all_users"; |
41 const char kCapabilityClass_ExplicitClass[] = "shell:explicit_class"; | 41 const char kCapabilityClass_ExplicitClass[] = "shell:explicit_class"; |
42 const char kCapabilityClass_Unsandboxed[] = "shell:unsandboxed"; | |
43 | 42 |
44 } // namespace | 43 } // namespace |
45 | 44 |
46 Identity CreateServiceManagerIdentity() { | 45 Identity CreateServiceManagerIdentity() { |
47 return Identity(kServiceManagerName, mojom::kRootUserID); | 46 return Identity(kServiceManagerName, mojom::kRootUserID); |
48 } | 47 } |
49 | 48 |
50 Identity CreateCatalogIdentity() { | 49 Identity CreateCatalogIdentity() { |
51 return Identity(kCatalogName, mojom::kRootUserID); | 50 return Identity(kCatalogName, mojom::kRootUserID); |
52 } | 51 } |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 void StartWithClientProcessConnection( | 209 void StartWithClientProcessConnection( |
211 mojom::ClientProcessConnectionPtr client_process_connection) { | 210 mojom::ClientProcessConnectionPtr client_process_connection) { |
212 mojom::ServicePtr service; | 211 mojom::ServicePtr service; |
213 service.Bind(mojom::ServicePtrInfo( | 212 service.Bind(mojom::ServicePtrInfo( |
214 std::move(client_process_connection->service), 0)); | 213 std::move(client_process_connection->service), 0)); |
215 pid_receiver_binding_.Bind( | 214 pid_receiver_binding_.Bind( |
216 std::move(client_process_connection->pid_receiver_request)); | 215 std::move(client_process_connection->pid_receiver_request)); |
217 StartWithService(std::move(service)); | 216 StartWithService(std::move(service)); |
218 } | 217 } |
219 | 218 |
220 void StartWithFilePath(const base::FilePath& path, bool unsandboxed) { | 219 void StartWithFilePath(const base::FilePath& path) { |
221 CHECK(!service_); | 220 CHECK(!service_); |
222 runner_ = service_manager_->native_runner_factory_->Create(path); | 221 runner_ = service_manager_->native_runner_factory_->Create(path); |
223 bool start_sandboxed = !unsandboxed; | 222 bool start_sandboxed = false; |
224 mojom::ServicePtr service = runner_->Start( | 223 mojom::ServicePtr service = runner_->Start( |
225 path, identity_, start_sandboxed, | 224 path, identity_, start_sandboxed, |
226 base::Bind(&Instance::PIDAvailable, weak_factory_.GetWeakPtr()), | 225 base::Bind(&Instance::PIDAvailable, weak_factory_.GetWeakPtr()), |
227 base::Bind(&Instance::OnRunnerCompleted, weak_factory_.GetWeakPtr())); | 226 base::Bind(&Instance::OnRunnerCompleted, weak_factory_.GetWeakPtr())); |
228 StartWithService(std::move(service)); | 227 StartWithService(std::move(service)); |
229 } | 228 } |
230 | 229 |
231 mojom::ServiceInfoPtr CreateServiceInfo() const { | 230 mojom::ServiceInfoPtr CreateServiceInfo() const { |
232 mojom::ServiceInfoPtr info(mojom::ServiceInfo::New()); | 231 mojom::ServiceInfoPtr info(mojom::ServiceInfo::New()); |
233 info->id = id_; | 232 info->id = id_; |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 // Otherwise we create a new Service pipe. | 814 // Otherwise we create a new Service pipe. |
816 mojom::ServiceRequest request = GetProxy(&service); | 815 mojom::ServiceRequest request = GetProxy(&service); |
817 CHECK(!result->package_path.empty() && result->capabilities.has_value()); | 816 CHECK(!result->package_path.empty() && result->capabilities.has_value()); |
818 | 817 |
819 if (target.name() != result->resolved_name) { | 818 if (target.name() != result->resolved_name) { |
820 instance->StartWithService(std::move(service)); | 819 instance->StartWithService(std::move(service)); |
821 Identity factory(result->resolved_name, target.user_id(), | 820 Identity factory(result->resolved_name, target.user_id(), |
822 instance_name); | 821 instance_name); |
823 CreateServiceWithFactory(factory, target.name(), std::move(request)); | 822 CreateServiceWithFactory(factory, target.name(), std::move(request)); |
824 } else { | 823 } else { |
825 bool unsandboxed = HasClass(capabilities, kCapabilityClass_Unsandboxed); | 824 instance->StartWithFilePath(result->package_path); |
826 instance->StartWithFilePath(result->package_path, unsandboxed); | |
827 } | 825 } |
828 } | 826 } |
829 | 827 |
830 // Now that the instance has a Service, we can connect to it. | 828 // Now that the instance has a Service, we can connect to it. |
831 bool connected = instance->ConnectToService(¶ms); | 829 bool connected = instance->ConnectToService(¶ms); |
832 DCHECK(connected); | 830 DCHECK(connected); |
833 } | 831 } |
834 | 832 |
835 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() { | 833 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() { |
836 return weak_ptr_factory_.GetWeakPtr(); | 834 return weak_ptr_factory_.GetWeakPtr(); |
837 } | 835 } |
838 | 836 |
839 } // namespace shell | 837 } // namespace shell |
OLD | NEW |