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

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

Issue 1351443004: Revert of 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
29 11
30 Identity::Identity() {} 12 Identity::Identity() {}
31 13
32 Identity::Identity(const GURL& url) 14 Identity::Identity(const GURL& in_url, const std::string& in_qualifier)
33 : url_(GetBaseURLAndQuery(url, nullptr)), 15 : url(GetBaseURLAndQuery(in_url, nullptr)),
34 qualifier_(url_.spec()) {} 16 qualifier(in_qualifier.empty() ? url.spec() : in_qualifier) {}
35 17
36 Identity::Identity(const GURL& url, const std::string& qualifier) 18 // explicit
37 : url_(GetBaseURLAndQuery(url, nullptr)), 19 Identity::Identity(const GURL& in_url)
38 qualifier_(qualifier.empty() ? url_.spec() : qualifier) {} 20 : url(GetBaseURLAndQuery(in_url, nullptr)), qualifier(url.spec()) {}
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() {}
48 21
49 bool Identity::operator<(const Identity& other) const { 22 bool Identity::operator<(const Identity& other) const {
50 // We specifically don't include filter in the equivalence check because we 23 if (url != other.url)
51 // don't quite know how this should work yet. 24 return url < other.url;
52 // TODO(beng): figure out how it should work. 25 return qualifier < other.qualifier;
53 if (url_ != other.url_)
54 return url_ < other.url_;
55 return qualifier_ < other.qualifier_;
56 } 26 }
57 27
58 } // namespace shell 28 } // namespace shell
59 } // namespace mojo 29 } // 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