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

Side by Side Diff: mojo/shell/identity.cc

Issue 1770533002: Change userid from a uint32_t to a string guid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@33connector
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 unified diff | Download patch
« no previous file with comments | « mojo/shell/identity.h ('k') | mojo/shell/public/cpp/application_test_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mojo/shell/identity.h" 5 #include "mojo/shell/identity.h"
6 6
7 #include "mojo/shell/public/cpp/names.h" 7 #include "mojo/shell/public/cpp/names.h"
8 #include "mojo/shell/public/interfaces/connector.mojom.h" 8 #include "mojo/shell/public/interfaces/connector.mojom.h"
9 9
10 namespace mojo { 10 namespace mojo {
11 namespace shell { 11 namespace shell {
12 12
13 Identity::Identity() {} 13 Identity::Identity() {}
14 14
15 Identity::Identity(const std::string& name) 15 Identity::Identity(const std::string& name)
16 : Identity(name, GetNamePath(name), mojom::Connector::kUserRoot) {} 16 : Identity(name, GetNamePath(name), mojom::kRootUserID) {}
17 17
18 Identity::Identity(const std::string& name, const std::string& qualifier, 18 Identity::Identity(const std::string& name, const std::string& qualifier,
19 uint32_t user_id) 19 const std::string& user_id)
20 : name_(name), 20 : name_(name),
21 qualifier_(qualifier.empty() ? GetNamePath(name_) : qualifier), 21 qualifier_(qualifier.empty() ? GetNamePath(name_) : qualifier),
22 user_id_(user_id) {} 22 user_id_(user_id) {}
23 23
24 Identity::Identity(const Identity& other) = default; 24 Identity::Identity(const Identity& other) = default;
25 25
26 Identity::~Identity() {} 26 Identity::~Identity() {}
27 27
28 bool Identity::operator<(const Identity& other) const { 28 bool Identity::operator<(const Identity& other) const {
29 // We specifically don't include filter in the equivalence check because we 29 // We specifically don't include filter in the equivalence check because we
30 // don't quite know how this should work yet. 30 // don't quite know how this should work yet.
31 // TODO(beng): figure out how it should work. 31 // TODO(beng): figure out how it should work.
32 if (name_ != other.name_) 32 if (name_ != other.name_)
33 return name_ < other.name_; 33 return name_ < other.name_;
34 if (qualifier_ != other.qualifier_) 34 if (qualifier_ != other.qualifier_)
35 return qualifier_ < other.qualifier_; 35 return qualifier_ < other.qualifier_;
36 return user_id_ < other.user_id_; 36 return user_id_ < other.user_id_;
37 } 37 }
38 38
39 bool Identity::operator==(const Identity& other) const { 39 bool Identity::operator==(const Identity& other) const {
40 // We specifically don't include filter in the equivalence check because we 40 // We specifically don't include filter in the equivalence check because we
41 // don't quite know how this should work yet. 41 // don't quite know how this should work yet.
42 // TODO(beng): figure out how it should work. 42 // TODO(beng): figure out how it should work.
43 return other.name_ == name_ && other.qualifier_ == qualifier_ && 43 return other.name_ == name_ && other.qualifier_ == qualifier_ &&
44 other.user_id_ == user_id_; 44 other.user_id_ == user_id_;
45 } 45 }
46 46
47 Identity CreateShellIdentity() { 47 Identity CreateShellIdentity() {
48 Identity id = Identity("mojo:shell", "", mojom::Connector::kUserRoot); 48 Identity id = Identity("mojo:shell", "", mojom::kRootUserID);
49 id.set_filter(GetPermissiveCapabilityFilter()); 49 id.set_filter(GetPermissiveCapabilityFilter());
50 return id; 50 return id;
51 } 51 }
52 52
53 CapabilityFilter GetPermissiveCapabilityFilter() { 53 CapabilityFilter GetPermissiveCapabilityFilter() {
54 CapabilityFilter filter; 54 CapabilityFilter filter;
55 AllowedInterfaces interfaces; 55 AllowedInterfaces interfaces;
56 interfaces.insert("*"); 56 interfaces.insert("*");
57 filter["*"] = interfaces; 57 filter["*"] = interfaces;
58 return filter; 58 return filter;
(...skipping 10 matching lines...) Expand all
69 it = filter.find("*"); 69 it = filter.find("*");
70 if (filter.size() == 1 && it != filter.end()) 70 if (filter.size() == 1 && it != filter.end())
71 return it->second; 71 return it->second;
72 72
73 // Finally, nothing is allowed. 73 // Finally, nothing is allowed.
74 return AllowedInterfaces(); 74 return AllowedInterfaces();
75 } 75 }
76 76
77 } // namespace shell 77 } // namespace shell
78 } // namespace mojo 78 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/identity.h ('k') | mojo/shell/public/cpp/application_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698