| 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 15 matching lines...) Expand all Loading... |
| 26 #include "services/shell/public/cpp/names.h" | 26 #include "services/shell/public/cpp/names.h" |
| 27 #include "services/shell/public/cpp/service_context.h" | 27 #include "services/shell/public/cpp/service_context.h" |
| 28 #include "services/shell/public/interfaces/connector.mojom.h" | 28 #include "services/shell/public/interfaces/connector.mojom.h" |
| 29 #include "services/shell/public/interfaces/service.mojom.h" | 29 #include "services/shell/public/interfaces/service.mojom.h" |
| 30 #include "services/shell/public/interfaces/service_manager.mojom.h" | 30 #include "services/shell/public/interfaces/service_manager.mojom.h" |
| 31 | 31 |
| 32 namespace shell { | 32 namespace shell { |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 const char kCatalogName[] = "mojo:catalog"; | 36 const char kCatalogName[] = "service:catalog"; |
| 37 const char kServiceManagerName[] = "mojo:shell"; | 37 const char kServiceManagerName[] = "service:shell"; |
| 38 const char kCapabilityClass_UserID[] = "shell:user_id"; | 38 const char kCapabilityClass_UserID[] = "shell:user_id"; |
| 39 const char kCapabilityClass_ClientProcess[] = "shell:client_process"; | 39 const char kCapabilityClass_ClientProcess[] = "shell:client_process"; |
| 40 const char kCapabilityClass_InstanceName[] = "shell:instance_name"; | 40 const char kCapabilityClass_InstanceName[] = "shell:instance_name"; |
| 41 const char kCapabilityClass_AllUsers[] = "shell:all_users"; | 41 const char kCapabilityClass_AllUsers[] = "shell:all_users"; |
| 42 const char kCapabilityClass_ExplicitClass[] = "shell:explicit_class"; | 42 const char kCapabilityClass_ExplicitClass[] = "shell:explicit_class"; |
| 43 | 43 |
| 44 } // namespace | 44 } // namespace |
| 45 | 45 |
| 46 Identity CreateServiceManagerIdentity() { | 46 Identity CreateServiceManagerIdentity() { |
| 47 return Identity(kServiceManagerName, mojom::kRootUserID); | 47 return Identity(kServiceManagerName, mojom::kRootUserID); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 319 |
| 320 bool ValidateClientProcessConnection( | 320 bool ValidateClientProcessConnection( |
| 321 mojom::ClientProcessConnectionPtr* client_process_connection, | 321 mojom::ClientProcessConnectionPtr* client_process_connection, |
| 322 const Identity& target, | 322 const Identity& target, |
| 323 const ConnectCallback& callback) { | 323 const ConnectCallback& callback) { |
| 324 if (!client_process_connection->is_null()) { | 324 if (!client_process_connection->is_null()) { |
| 325 if (!HasClass(capability_spec_, kCapabilityClass_ClientProcess)) { | 325 if (!HasClass(capability_spec_, kCapabilityClass_ClientProcess)) { |
| 326 LOG(ERROR) << "Instance: " << identity_.name() << " attempting " | 326 LOG(ERROR) << "Instance: " << identity_.name() << " attempting " |
| 327 << "to register an instance for a process it created for " | 327 << "to register an instance for a process it created for " |
| 328 << "target: " << target.name() << " without the " | 328 << "target: " << target.name() << " without the " |
| 329 << "mojo:shell{client_process} capability class."; | 329 << "service:shell{client_process} capability class."; |
| 330 callback.Run(mojom::ConnectResult::ACCESS_DENIED, | 330 callback.Run(mojom::ConnectResult::ACCESS_DENIED, |
| 331 mojom::kInheritUserID); | 331 mojom::kInheritUserID); |
| 332 return false; | 332 return false; |
| 333 } | 333 } |
| 334 | 334 |
| 335 if (!(*client_process_connection)->service.is_valid() || | 335 if (!(*client_process_connection)->service.is_valid() || |
| 336 !(*client_process_connection)->pid_receiver_request.is_valid()) { | 336 !(*client_process_connection)->pid_receiver_request.is_valid()) { |
| 337 LOG(ERROR) << "Must supply both service AND " | 337 LOG(ERROR) << "Must supply both service AND " |
| 338 << "pid_receiver_request when sending " | 338 << "pid_receiver_request when sending " |
| 339 << "client_process_connection."; | 339 << "client_process_connection."; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 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 " |
| 378 << "mojo:shell{instance_name} capability class."; | 378 << "service:shell{instance_name} capability class."; |
| 379 callback.Run(mojom::ConnectResult::ACCESS_DENIED, mojom::kInheritUserID); | 379 callback.Run(mojom::ConnectResult::ACCESS_DENIED, mojom::kInheritUserID); |
| 380 return false; | 380 return false; |
| 381 | 381 |
| 382 } | 382 } |
| 383 | 383 |
| 384 if (allow_any_application_ || | 384 if (allow_any_application_ || |
| 385 capability_spec_.required.find(target.name()) != | 385 capability_spec_.required.find(target.name()) != |
| 386 capability_spec_.required.end()) { | 386 capability_spec_.required.end()) { |
| 387 return true; | 387 return true; |
| 388 } | 388 } |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 // Now that the instance has a Service, we can connect to it. | 849 // Now that the instance has a Service, we can connect to it. |
| 850 bool connected = instance->ConnectToService(¶ms); | 850 bool connected = instance->ConnectToService(¶ms); |
| 851 DCHECK(connected); | 851 DCHECK(connected); |
| 852 } | 852 } |
| 853 | 853 |
| 854 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() { | 854 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() { |
| 855 return weak_ptr_factory_.GetWeakPtr(); | 855 return weak_ptr_factory_.GetWeakPtr(); |
| 856 } | 856 } |
| 857 | 857 |
| 858 } // namespace shell | 858 } // namespace shell |
| OLD | NEW |