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 #include "mojo/shell/capability_filter.h" | 5 #include "mojo/shell/capability_filter.h" |
6 | 6 |
7 #include "mojo/shell/identity.h" | 7 #include "mojo/shell/identity.h" |
8 | 8 |
9 namespace mojo { | 9 namespace mojo { |
10 namespace shell { | 10 namespace shell { |
11 | 11 |
12 CapabilityFilter GetPermissiveCapabilityFilter() { | 12 CapabilityFilter GetPermissiveCapabilityFilter() { |
13 CapabilityFilter filter; | 13 CapabilityFilter filter; |
14 AllowedInterfaces interfaces; | 14 AllowedInterfaces interfaces; |
15 interfaces.insert("*"); | 15 interfaces.insert("*"); |
16 filter["*"] = interfaces; | 16 filter["*"] = interfaces; |
17 return filter; | 17 return filter; |
18 } | 18 } |
19 | 19 |
20 AllowedInterfaces GetAllowedInterfaces(const CapabilityFilter& filter, | 20 AllowedInterfaces GetAllowedInterfaces(const CapabilityFilter& filter, |
21 const Identity& identity) { | 21 const Identity& identity) { |
22 // Start by looking for interfaces specific to the supplied identity. | 22 // Start by looking for interfaces specific to the supplied identity. |
23 auto it = filter.find(identity.url().spec()); | 23 auto it = filter.find(identity.url.spec()); |
24 if (it != filter.end()) | 24 if (it != filter.end()) |
25 return it->second; | 25 return it->second; |
26 | 26 |
27 // Fall back to looking for a wildcard rule. | 27 // Fall back to looking for a wildcard rule. |
28 it = filter.find("*"); | 28 it = filter.find("*"); |
29 if (filter.size() == 1 && it != filter.end()) | 29 if (filter.size() == 1 && it != filter.end()) |
30 return it->second; | 30 return it->second; |
31 | 31 |
32 // Finally, nothing is allowed. | 32 // Finally, nothing is allowed. |
33 return AllowedInterfaces(); | 33 return AllowedInterfaces(); |
34 } | 34 } |
35 | 35 |
36 } // namespace shell | 36 } // namespace shell |
37 } // namespace mojo | 37 } // namespace mojo |
OLD | NEW |