Roll src/third_party/skia 2440fcd:4de8c3a
[chromium-blink-merge.git] / mojo / shell / capability_filter.cc
blob77cc61d093e5b2494b31c3fc01a96219930f1780
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 #include "mojo/shell/capability_filter.h"
7 #include "mojo/shell/identity.h"
9 namespace mojo {
10 namespace shell {
12 CapabilityFilter GetPermissiveCapabilityFilter() {
13 CapabilityFilter filter;
14 AllowedInterfaces interfaces;
15 interfaces.insert("*");
16 filter["*"] = interfaces;
17 return filter;
20 AllowedInterfaces GetAllowedInterfaces(const CapabilityFilter& filter,
21 const Identity& identity) {
22 // Start by looking for interfaces specific to the supplied identity.
23 auto it = filter.find(identity.url().spec());
24 if (it != filter.end())
25 return it->second;
27 // Fall back to looking for a wildcard rule.
28 it = filter.find("*");
29 if (filter.size() == 1 && it != filter.end())
30 return it->second;
32 // Finally, nothing is allowed.
33 return AllowedInterfaces();
36 } // namespace shell
37 } // namespace mojo