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

Unified Diff: mojo/shell/shell.cc

Issue 1783303002: Revert of Capability Classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@45class
Patch Set: Created 4 years, 9 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
« no previous file with comments | « mojo/shell/public/cpp/lib/shell_connection.cc ('k') | mojo/shell/tests/connect/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/shell.cc
diff --git a/mojo/shell/shell.cc b/mojo/shell/shell.cc
index e5c46b31dfea6e391769d259488e9d45968bd8f5..1daa93a4e8e963c96c8f019dc8f9c017ba58706a 100644
--- a/mojo/shell/shell.cc
+++ b/mojo/shell/shell.cc
@@ -55,37 +55,20 @@
return capabilities;
}
-CapabilityRequest GetCapabilityRequest(const CapabilitySpec& source_spec,
- const Identity& target) {
+CapabilityRequest GetCapabilityRequest(const CapabilitySpec& spec,
+ const Identity& identity) {
// Start by looking for specs specific to the supplied identity.
- auto it = source_spec.required.find(target.name());
- if (it != source_spec.required.end())
+ auto it = spec.required.find(identity.name());
+ if (it != spec.required.end())
return it->second;
// Fall back to looking for a wildcard rule.
- it = source_spec.required.find("*");
- if (source_spec.required.size() == 1 && it != source_spec.required.end())
+ it = spec.required.find("*");
+ if (spec.required.size() == 1 && it != spec.required.end())
return it->second;
// Finally, nothing is allowed.
return CapabilityRequest();
-}
-
-CapabilityRequest GenerateCapabilityRequestForConnection(
- const CapabilitySpec& source_spec,
- const Identity& target,
- const CapabilitySpec& target_spec) {
- CapabilityRequest request = GetCapabilityRequest(source_spec, target);
- // Flatten all interfaces from classes requested by the source into the
- // allowed interface set in the request.
- for (const auto& class_name : request.classes) {
- auto it = target_spec.provided.find(class_name);
- if (it != target_spec.provided.end()) {
- for (const auto& interface_name : it->second)
- request.interfaces.insert(interface_name);
- }
- }
- return request;
}
// Encapsulates a connection to an instance of an application, tracked by the
@@ -99,13 +82,13 @@
Instance(mojom::ShellClientPtr shell_client,
mojo::shell::Shell* shell,
const Identity& identity,
- const CapabilitySpec& capability_spec)
+ const CapabilitySpec& capabilities)
: shell_(shell),
id_(GenerateUniqueID()),
identity_(identity),
- capability_spec_(capability_spec),
- allow_any_application_(capability_spec.required.size() == 1 &&
- capability_spec.required.count("*") == 1),
+ capabilities_(capabilities),
+ allow_any_application_(capabilities.required.size() == 1 &&
+ capabilities.required.count("*") == 1),
shell_client_(std::move(shell_client)),
pid_receiver_binding_(this),
weak_factory_(this) {
@@ -134,8 +117,7 @@
spec.interfaces.insert("*");
Instance* source = shell_->GetExistingInstance(params->source());
if (source) {
- spec = GenerateCapabilityRequestForConnection(
- source->capability_spec_, identity_, capability_spec_);
+ spec = GetCapabilityRequest(source->capabilities_, identity_);
source_id = source->id();
}
shell_client_->AcceptConnection(
@@ -285,8 +267,8 @@
bool ValidateCapabilities(const Identity& target,
const ConnectCallback& callback) {
if (allow_any_application_ ||
- capability_spec_.required.find(target.name()) !=
- capability_spec_.required.end()) {
+ capabilities_.required.find(target.name()) !=
+ capabilities_.required.end()) {
return true;
}
LOG(ERROR) << "Capabilities prevented connection from: " <<
@@ -314,7 +296,7 @@
// process is launched.
const uint32_t id_;
const Identity identity_;
- const CapabilitySpec capability_spec_;
+ const CapabilitySpec capabilities_;
const bool allow_any_application_;
mojom::ShellClientPtr shell_client_;
Binding<mojom::PIDReceiver> pid_receiver_binding_;
« no previous file with comments | « mojo/shell/public/cpp/lib/shell_connection.cc ('k') | mojo/shell/tests/connect/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698