Add ICU message format support
[chromium-blink-merge.git] / mojo / shell / capability_filter.h
blob6d17cc316f60f10645b6dc7534ca50892e274f40
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_
8 #include <map>
9 #include <set>
11 #include "mojo/public/cpp/bindings/array.h"
13 namespace mojo {
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) {
22 std::set<E> result;
23 if (!input.is_null()) {
24 for (size_t i = 0; i < input.size(); ++i)
25 result.insert(TypeConverter<E, T>::Convert(input[i]));
27 return result;
31 template <typename T, typename E>
32 struct TypeConverter <Array<T>, std::set<E>> {
33 static Array<T> Convert(const std::set<E>& input) {
34 Array<T> result(0u);
35 for (auto i : input)
36 result.push_back(TypeConverter<T, E>::Convert(i));
37 return result.Pass();
41 namespace shell {
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
46 // more details.
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();
53 } // namespace shell
54 } // namespace mojo
57 #endif // MOJO_SHELL_CAPABILITY_FILTER_H_