OLD | NEW |
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 #ifndef MOJO_SHELL_IDENTITY_H_ | 5 #ifndef MOJO_SHELL_IDENTITY_H_ |
6 #define MOJO_SHELL_IDENTITY_H_ | 6 #define MOJO_SHELL_IDENTITY_H_ |
7 | 7 |
8 #include "mojo/shell/capability_filter.h" | 8 #include "mojo/shell/capability_filter.h" |
9 #include "url/gurl.h" | |
10 | 9 |
11 namespace mojo { | 10 namespace mojo { |
12 namespace shell { | 11 namespace shell { |
13 | 12 |
14 // Represents the identity of an application. | 13 // Represents the identity of an application. |
15 // |url| is the URL of the application. | 14 // |name| is the structured name of the application. |
16 // |qualifier| is a string that allows to tie a specific instance of an | 15 // |qualifier| is a string that allows to tie a specific instance of an |
17 // application to another. A typical use case of qualifier is to control process | 16 // application to another. A typical use case of qualifier is to control process |
18 // grouping for a given application URL. For example, the core services are | 17 // grouping for a given application name. For example, the core services are |
19 // grouped into "Core"/"Files"/"Network"/etc. using qualifier; content handler's | 18 // grouped into "Core"/"Files"/"Network"/etc. using qualifier; content handler's |
20 // qualifier is derived from the origin of the content. | 19 // qualifier is derived from the origin of the content. |
21 class Identity { | 20 class Identity { |
22 public: | 21 public: |
23 Identity(); | 22 Identity(); |
24 // Assumes user = mojom::Connector::kUserRoot. | 23 // Assumes user = mojom::Connector::kUserRoot. |
25 // Used in tests or for shell-initiated connections. | 24 // Used in tests or for shell-initiated connections. |
26 explicit Identity(const GURL& in_url); | 25 explicit Identity(const std::string& in_name); |
27 Identity(const GURL& in_url, | 26 Identity(const std::string& in_name, |
28 const std::string& in_qualifier, | 27 const std::string& in_qualifier, |
29 uint32_t user_id); | 28 uint32_t user_id); |
30 ~Identity(); | 29 ~Identity(); |
31 | 30 |
32 bool operator<(const Identity& other) const; | 31 bool operator<(const Identity& other) const; |
33 bool is_null() const { return url_.is_empty(); } | 32 bool is_null() const { return name_.empty(); } |
34 bool operator==(const Identity& other) const; | 33 bool operator==(const Identity& other) const; |
35 | 34 |
36 const GURL& url() const { return url_; } | 35 const std::string& name() const { return name_; } |
37 uint32_t user_id() const { return user_id_; } | 36 uint32_t user_id() const { return user_id_; } |
38 void set_user_id(uint32_t user_id) { user_id_ = user_id; } | 37 void set_user_id(uint32_t user_id) { user_id_ = user_id; } |
39 const std::string& qualifier() const { return qualifier_; } | 38 const std::string& qualifier() const { return qualifier_; } |
40 void SetFilter(const CapabilityFilter& filter); | 39 void set_filter(const CapabilityFilter& filter) { filter_ = filter; } |
41 const CapabilityFilter& filter() const { return filter_; } | 40 const CapabilityFilter& filter() const { return filter_; } |
42 | 41 |
43 private: | 42 private: |
44 GURL url_; | 43 std::string name_; |
45 std::string qualifier_; | 44 std::string qualifier_; |
46 | 45 |
47 uint32_t user_id_; | 46 uint32_t user_id_; |
48 | 47 |
49 // TODO(beng): CapabilityFilter is not currently included in equivalence | 48 // TODO(beng): CapabilityFilter is not currently included in equivalence |
50 // checks for Identity since we're not currently clear on the | 49 // checks for Identity since we're not currently clear on the |
51 // policy for instance disambiguation. Need to figure this out. | 50 // policy for instance disambiguation. Need to figure this out. |
52 // This field is supplied because it is logically part of the | 51 // This field is supplied because it is logically part of the |
53 // instance identity of an application. | 52 // instance identity of an application. |
54 CapabilityFilter filter_; | 53 CapabilityFilter filter_; |
55 }; | 54 }; |
56 | 55 |
57 // Creates an identity for the Shell, used when the Shell connects to | 56 // Creates an identity for the Shell, used when the Shell connects to |
58 // applications. | 57 // applications. |
59 Identity CreateShellIdentity(); | 58 Identity CreateShellIdentity(); |
60 | 59 |
61 } // namespace shell | 60 } // namespace shell |
62 } // namespace mojo | 61 } // namespace mojo |
63 | 62 |
64 #endif // MOJO_SHELL_IDENTITY_H_ | 63 #endif // MOJO_SHELL_IDENTITY_H_ |
OLD | NEW |