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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 const ConnectCallback& callback) { | 357 const ConnectCallback& callback) { |
358 // TODO(beng): Need to do the following additional policy validation of | 358 // TODO(beng): Need to do the following additional policy validation of |
359 // whether this instance is allowed to connect using: | 359 // whether this instance is allowed to connect using: |
360 // - a non-null client_process_connection. | 360 // - a non-null client_process_connection. |
361 if (target.user_id() != identity_.user_id() && | 361 if (target.user_id() != identity_.user_id() && |
362 target.user_id() != mojom::kRootUserID && | 362 target.user_id() != mojom::kRootUserID && |
363 !HasClass(capability_spec_, kCapabilityClass_UserID)) { | 363 !HasClass(capability_spec_, kCapabilityClass_UserID)) { |
364 LOG(ERROR) << "Instance: " << identity_.name() << " running as: " | 364 LOG(ERROR) << "Instance: " << identity_.name() << " running as: " |
365 << identity_.user_id() << " attempting to connect to: " | 365 << identity_.user_id() << " attempting to connect to: " |
366 << target.name() << " as: " << target.user_id() << " without " | 366 << target.name() << " as: " << target.user_id() << " without " |
367 << " the mojo:shell{user_id} capability class."; | 367 << " the service:shell{user_id} capability class."; |
368 callback.Run(mojom::ConnectResult::ACCESS_DENIED, | 368 callback.Run(mojom::ConnectResult::ACCESS_DENIED, |
369 mojom::kInheritUserID); | 369 mojom::kInheritUserID); |
370 return false; | 370 return false; |
371 } | 371 } |
372 if (!target.instance().empty() && | 372 if (!target.instance().empty() && |
373 target.instance() != GetNamePath(target.name()) && | 373 target.instance() != GetNamePath(target.name()) && |
374 !HasClass(capability_spec_, kCapabilityClass_InstanceName)) { | 374 !HasClass(capability_spec_, kCapabilityClass_InstanceName)) { |
375 LOG(ERROR) << "Instance: " << identity_.name() << " attempting to " | 375 LOG(ERROR) << "Instance: " << identity_.name() << " attempting to " |
376 << "connect to " << target.name() << " using Instance name: " | 376 << "connect to " << target.name() << " using Instance name: " |
377 << target.instance() << " without the " | 377 << target.instance() << " without the " |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 return instance->OnConnect(remote_identity, registry); | 553 return instance->OnConnect(remote_identity, registry); |
554 } | 554 } |
555 | 555 |
556 //////////////////////////////////////////////////////////////////////////////// | 556 //////////////////////////////////////////////////////////////////////////////// |
557 // ServiceManager, private: | 557 // ServiceManager, private: |
558 | 558 |
559 void ServiceManager::InitCatalog(mojom::ServicePtr catalog) { | 559 void ServiceManager::InitCatalog(mojom::ServicePtr catalog) { |
560 // TODO(beng): It'd be great to build this from the manifest, however there's | 560 // TODO(beng): It'd be great to build this from the manifest, however there's |
561 // a bit of a chicken-and-egg problem. | 561 // a bit of a chicken-and-egg problem. |
562 CapabilitySpec spec; | 562 CapabilitySpec spec; |
563 Interfaces interfaces; | 563 spec.provided["app"].insert("filesystem::mojom::Directory"); |
564 interfaces.insert("filesystem::mojom::Directory"); | 564 spec.provided["control"].insert("catalog::mojom::CatalogControl"); |
565 spec.provided["app"] = interfaces; | 565 Instance* instance = CreateInstance( |
566 Instance* instance = CreateInstance(CreateServiceManagerIdentity(), | 566 CreateServiceManagerIdentity(), CreateCatalogIdentity(), spec); |
567 CreateCatalogIdentity(), | |
568 spec); | |
569 singletons_.insert(kCatalogName); | 567 singletons_.insert(kCatalogName); |
570 instance->StartWithService(std::move(catalog)); | 568 instance->StartWithService(std::move(catalog)); |
571 } | 569 } |
572 | 570 |
573 mojom::Resolver* ServiceManager::GetResolver(const Identity& identity) { | 571 mojom::Resolver* ServiceManager::GetResolver(const Identity& identity) { |
574 auto iter = identity_to_resolver_.find(identity); | 572 auto iter = identity_to_resolver_.find(identity); |
575 if (iter != identity_to_resolver_.end()) | 573 if (iter != identity_to_resolver_.end()) |
576 return iter->second.get(); | 574 return iter->second.get(); |
577 | 575 |
578 mojom::ResolverPtr resolver_ptr; | 576 mojom::ResolverPtr resolver_ptr; |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 // Now that the instance has a Service, we can connect to it. | 847 // Now that the instance has a Service, we can connect to it. |
850 bool connected = instance->ConnectToService(¶ms); | 848 bool connected = instance->ConnectToService(¶ms); |
851 DCHECK(connected); | 849 DCHECK(connected); |
852 } | 850 } |
853 | 851 |
854 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() { | 852 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() { |
855 return weak_ptr_factory_.GetWeakPtr(); | 853 return weak_ptr_factory_.GetWeakPtr(); |
856 } | 854 } |
857 | 855 |
858 } // namespace shell | 856 } // namespace shell |
OLD | NEW |