Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Unified Diff: services/shell/service_manager.cc

Issue 2389133008: Mash: Replaces "exe:chrome" with "service:content_browser" (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« chrome/app/mash/mash_runner.cc ('K') | « services/shell/service_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/shell/service_manager.cc
diff --git a/services/shell/service_manager.cc b/services/shell/service_manager.cc
index 721640077631ab5e81053473ff5f8a1e4dbfcc74..256e132120b81c2c61edec5077f32d8151d09115 100644
--- a/services/shell/service_manager.cc
+++ b/services/shell/service_manager.cc
@@ -364,7 +364,7 @@ class ServiceManager::Instance
LOG(ERROR) << "Instance: " << identity_.name() << " running as: "
<< identity_.user_id() << " attempting to connect to: "
<< target.name() << " as: " << target.user_id() << " without "
- << " the mojo:shell{user_id} capability class.";
+ << " the service:shell{user_id} capability class.";
callback.Run(mojom::ConnectResult::ACCESS_DENIED,
mojom::kInheritUserID);
return false;
@@ -487,8 +487,13 @@ ServiceManager::ServiceManager(
weak_ptr_factory_(this) {
mojom::ServicePtr service;
mojom::ServiceRequest request = mojo::GetProxy(&service);
+
+ CapabilitySpec capabilities = GetPermissiveCapabilities();
+ capabilities.provided["control"].insert(
+ "shell::mojom::ServiceManagerControl");
+
service_manager_instance_ = CreateInstance(
- Identity(), CreateServiceManagerIdentity(), GetPermissiveCapabilities());
+ Identity(), CreateServiceManagerIdentity(), capabilities);
service_manager_instance_->StartWithService(std::move(service));
singletons_.insert(kServiceManagerName);
service_context_.reset(new ServiceContext(this, std::move(request)));
@@ -538,10 +543,11 @@ mojom::ServiceRequest ServiceManager::StartEmbedderService(
bool ServiceManager::OnConnect(const Identity& remote_identity,
InterfaceRegistry* registry) {
- // The only interface we expose is mojom::ServiceManager, and access to this
- // interface is brokered by a policy specific to each caller, managed by the
- // caller's instance. Here we look to see who's calling, and forward to the
- // caller's instance to continue.
+ registry->AddInterface<mojom::ServiceManagerControl>(this);
+
+ // Access to mojom::ServiceManager is brokered by a policy specific to each
+ // caller, managed by the caller's instance. Here we look to see who's
+ // calling, and forward to the caller's instance to continue.
Instance* instance = nullptr;
for (const auto& entry : identity_to_instance_) {
if (entry.first == remote_identity) {
@@ -554,18 +560,35 @@ bool ServiceManager::OnConnect(const Identity& remote_identity,
}
////////////////////////////////////////////////////////////////////////////////
+// ServiceManager, InterfaceFactory<mojom::ServiceManagerControl> implementation
+
+void ServiceManager::Create(const Identity& remote_identity,
+ mojom::ServiceManagerControlRequest request) {
+ control_bindings_.AddBinding(this, std::move(request));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// ServiceManager, ServiceManagerControl implementation
+
+void ServiceManager::OverridePackagePath(
+ const std::string& service_name,
+ const base::FilePath& path,
+ const OverridePackagePathCallback& callback) {
+ package_path_overrides_.insert(std::make_pair(service_name, path));
+ callback.Run();
+}
+
+////////////////////////////////////////////////////////////////////////////////
// ServiceManager, private:
void ServiceManager::InitCatalog(mojom::ServicePtr catalog) {
// TODO(beng): It'd be great to build this from the manifest, however there's
// a bit of a chicken-and-egg problem.
CapabilitySpec spec;
- Interfaces interfaces;
- interfaces.insert("filesystem::mojom::Directory");
- spec.provided["app"] = interfaces;
- Instance* instance = CreateInstance(CreateServiceManagerIdentity(),
- CreateCatalogIdentity(),
- spec);
+ spec.provided["app"].insert("filesystem::mojom::Directory");
+ spec.provided["control"].insert("catalog::mojom::CatalogControl");
+ Instance* instance = CreateInstance(
+ CreateServiceManagerIdentity(), CreateCatalogIdentity(), spec);
singletons_.insert(kCatalogName);
instance->StartWithService(std::move(catalog));
}
@@ -787,6 +810,10 @@ void ServiceManager::OnGotResolvedName(std::unique_ptr<ConnectParams> params,
Identity source = params->source();
+ auto override_iter = package_path_overrides_.find(target.name());
+ if (override_iter != package_path_overrides_.end())
+ result->package_path = override_iter->second;
+
// Services that request "all_users" class from the Service Manager are
// allowed to field connection requests from any user. They also run with a
// synthetic user id generated here. The user id provided via Connect() is
« chrome/app/mash/mash_runner.cc ('K') | « services/shell/service_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698