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

Unified Diff: mojo/shell/identity.cc

Issue 1769163002: Add a instance groups to Connect(), and introduce an Identity struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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/identity.h ('k') | mojo/shell/native_runner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/identity.cc
diff --git a/mojo/shell/identity.cc b/mojo/shell/identity.cc
deleted file mode 100644
index 243565a91f4650685859a15c2d35b8db948dcadb..0000000000000000000000000000000000000000
--- a/mojo/shell/identity.cc
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/shell/identity.h"
-
-#include "mojo/shell/public/cpp/names.h"
-#include "mojo/shell/public/interfaces/connector.mojom.h"
-
-namespace mojo {
-namespace shell {
-
-Identity::Identity() {}
-
-Identity::Identity(const std::string& name)
- : Identity(name, GetNamePath(name), mojom::kRootUserID) {}
-
-Identity::Identity(const std::string& name, const std::string& qualifier,
- const std::string& user_id)
- : name_(name),
- qualifier_(qualifier.empty() ? GetNamePath(name_) : qualifier),
- user_id_(user_id) {}
-
-Identity::Identity(const Identity& other) = default;
-
-Identity::~Identity() {}
-
-bool Identity::operator<(const Identity& other) const {
- // We specifically don't include filter in the equivalence check because we
- // don't quite know how this should work yet.
- // TODO(beng): figure out how it should work.
- if (name_ != other.name_)
- return name_ < other.name_;
- if (qualifier_ != other.qualifier_)
- return qualifier_ < other.qualifier_;
- return user_id_ < other.user_id_;
-}
-
-bool Identity::operator==(const Identity& other) const {
- // We specifically don't include filter in the equivalence check because we
- // don't quite know how this should work yet.
- // TODO(beng): figure out how it should work.
- return other.name_ == name_ && other.qualifier_ == qualifier_ &&
- other.user_id_ == user_id_;
-}
-
-Identity CreateShellIdentity() {
- Identity id = Identity("mojo:shell", "", mojom::kRootUserID);
- id.set_filter(GetPermissiveCapabilityFilter());
- return id;
-}
-
-CapabilityFilter GetPermissiveCapabilityFilter() {
- CapabilityFilter filter;
- AllowedInterfaces interfaces;
- interfaces.insert("*");
- filter["*"] = interfaces;
- return filter;
-}
-
-AllowedInterfaces GetAllowedInterfaces(const CapabilityFilter& filter,
- const Identity& identity) {
- // Start by looking for interfaces specific to the supplied identity.
- auto it = filter.find(identity.name());
- if (it != filter.end())
- return it->second;
-
- // Fall back to looking for a wildcard rule.
- it = filter.find("*");
- if (filter.size() == 1 && it != filter.end())
- return it->second;
-
- // Finally, nothing is allowed.
- return AllowedInterfaces();
-}
-
-} // namespace shell
-} // namespace mojo
« no previous file with comments | « mojo/shell/identity.h ('k') | mojo/shell/native_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698