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
3 // found in the LICENSE file.
5 #ifndef MOJO_SHELL_CAPABILITY_FILTER_H_
6 #define MOJO_SHELL_CAPABILITY_FILTER_H_
11 #include "mojo/public/cpp/bindings/array.h"
14 // TODO(beng): upstream this into mojo repo, array.h so it can be shared with
15 // application_impl.cc.
16 // A |TypeConverter| that will create an |std::set<E>| containing a copy of
17 // the contents of an |Array<T>|, using |TypeConverter<E, T>| to copy each
18 // element. If the input array is null, the output set will be empty.
19 template <typename E
, typename T
>
20 struct TypeConverter
<std::set
<E
>, Array
<T
>> {
21 static std::set
<E
> Convert(const Array
<T
>& input
) {
23 if (!input
.is_null()) {
24 for (size_t i
= 0; i
< input
.size(); ++i
)
25 result
.insert(TypeConverter
<E
, T
>::Convert(input
[i
]));
31 template <typename T
, typename E
>
32 struct TypeConverter
<Array
<T
>, std::set
<E
>> {
33 static Array
<T
> Convert(const std::set
<E
>& input
) {
36 result
.push_back(TypeConverter
<T
, E
>::Convert(i
));
43 // A set of names of interfaces that may be exposed to an application.
44 using AllowedInterfaces
= std::set
<std::string
>;
45 // A map of allowed applications to allowed interface sets. See shell.mojom for
47 using CapabilityFilter
= std::map
<std::string
, AllowedInterfaces
>;
49 // Returns a capability filter that allows an application to connect to any
50 // other application and any service exposed by other applications.
51 CapabilityFilter
GetPermissiveCapabilityFilter();
57 #endif // MOJO_SHELL_CAPABILITY_FILTER_H_