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

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

Issue 1354003002: Make CapabilityFilter be part of Identity (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/identity.h ('k') | no next file » | 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/identity.h" 5 #include "mojo/shell/identity.h"
6 6
7 #include "mojo/shell/query_util.h" 7 #include "mojo/shell/query_util.h"
8 8
9 namespace mojo { 9 namespace mojo {
10 namespace shell { 10 namespace shell {
11 namespace {
12
13 // It's valid to specify mojo: URLs in the filter either as mojo:foo or
14 // mojo://foo/ - but we store the filter in the latter form.
15 CapabilityFilter CanonicalizeFilter(const CapabilityFilter& filter) {
16 CapabilityFilter canonicalized;
17 for (CapabilityFilter::const_iterator it = filter.begin();
18 it != filter.end();
19 ++it) {
20 if (it->first == "*")
21 canonicalized[it->first] = it->second;
22 else
23 canonicalized[GURL(it->first).spec()] = it->second;
24 }
25 return canonicalized;
26 }
27
28 } // namespace
11 29
12 Identity::Identity() {} 30 Identity::Identity() {}
13 31
14 Identity::Identity(const GURL& in_url, const std::string& in_qualifier) 32 Identity::Identity(const GURL& url)
15 : url(GetBaseURLAndQuery(in_url, nullptr)), 33 : url_(GetBaseURLAndQuery(url, nullptr)),
16 qualifier(in_qualifier.empty() ? url.spec() : in_qualifier) {} 34 qualifier_(url_.spec()) {}
17 35
18 // explicit 36 Identity::Identity(const GURL& url, const std::string& qualifier)
19 Identity::Identity(const GURL& in_url) 37 : url_(GetBaseURLAndQuery(url, nullptr)),
20 : url(GetBaseURLAndQuery(in_url, nullptr)), qualifier(url.spec()) {} 38 qualifier_(qualifier.empty() ? url_.spec() : qualifier) {}
39
40 Identity::Identity(const GURL& url,
41 const std::string& qualifier,
42 CapabilityFilter filter)
43 : url_(GetBaseURLAndQuery(url, nullptr)),
44 qualifier_(qualifier.empty() ? url_.spec() : qualifier),
45 filter_(CanonicalizeFilter(filter)) {}
46
47 Identity::~Identity() {}
21 48
22 bool Identity::operator<(const Identity& other) const { 49 bool Identity::operator<(const Identity& other) const {
23 if (url != other.url) 50 // We specifically don't include filter in the equivalence check because we
24 return url < other.url; 51 // don't quite know how this should work yet.
25 return qualifier < other.qualifier; 52 // TODO(beng): figure out how it should work.
53 if (url_ != other.url_)
54 return url_ < other.url_;
55 return qualifier_ < other.qualifier_;
26 } 56 }
27 57
28 } // namespace shell 58 } // namespace shell
29 } // namespace mojo 59 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/identity.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698