Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(692)

Side by Side Diff: mojo/shell/capability_filter.cc

Issue 1307273004: Group ConnectToApplication-related info into a params struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/shell/capability_filter.h ('k') | mojo/shell/connect_to_application_params.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
8
7 namespace mojo { 9 namespace mojo {
8 namespace shell { 10 namespace shell {
9 11
10 CapabilityFilter GetPermissiveCapabilityFilter() { 12 CapabilityFilter GetPermissiveCapabilityFilter() {
11 CapabilityFilter filter; 13 CapabilityFilter filter;
12 AllowedInterfaces interfaces; 14 AllowedInterfaces interfaces;
13 interfaces.insert("*"); 15 interfaces.insert("*");
14 filter["*"] = interfaces; 16 filter["*"] = interfaces;
15 return filter; 17 return filter;
16 } 18 }
17 19
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;
26
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;
31
32 // Finally, nothing is allowed.
33 return AllowedInterfaces();
34 }
35
18 } // namespace shell 36 } // namespace shell
19 } // namespace mojo 37 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/capability_filter.h ('k') | mojo/shell/connect_to_application_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698