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

Unified 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 side-by-side diff with in-line comments
Download patch
« mojo/shell/identity.h ('K') | « mojo/shell/identity.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/identity.cc
diff --git a/mojo/shell/identity.cc b/mojo/shell/identity.cc
index b3d045094ae16f63fa3c8b11a7726b8bad9a60b5..b7f094c479936522f76dc7b0175ca3b6d2fcae64 100644
--- a/mojo/shell/identity.cc
+++ b/mojo/shell/identity.cc
@@ -8,21 +8,53 @@
namespace mojo {
namespace shell {
+namespace {
+
+// It's valid to specify mojo: URLs in the filter either as mojo:foo or
+// mojo://foo/ - but we store the filter in the latter form.
+CapabilityFilter CanonicalizeFilter(const CapabilityFilter& filter) {
+ CapabilityFilter canonicalized;
+ for (CapabilityFilter::const_iterator it = filter.begin();
+ it != filter.end();
+ ++it) {
+ if (it->first == "*")
+ canonicalized[it->first] = it->second;
+ else
+ canonicalized[GURL(it->first).spec()] = it->second;
+ }
+ return canonicalized;
+}
+
+} // namespace
Identity::Identity() {}
-Identity::Identity(const GURL& in_url, const std::string& in_qualifier)
- : url(GetBaseURLAndQuery(in_url, nullptr)),
- qualifier(in_qualifier.empty() ? url.spec() : in_qualifier) {}
+Identity::Identity(const GURL& url)
+ : url_(GetBaseURLAndQuery(url, nullptr)),
+ qualifier_(GetBaseURLAndQuery(url, nullptr).spec()) {}
yzshen1 2015/09/18 21:44:04 nit: it seems safe to use |url_| instead of |GetBa
+
+Identity::Identity(const GURL& url, const std::string& qualifier)
+ : url_(GetBaseURLAndQuery(url, nullptr)),
+ qualifier_(qualifier.empty() ? GetBaseURLAndQuery(url, nullptr).spec()
+ : qualifier) {}
+
+Identity::Identity(const GURL& url,
+ const std::string& qualifier,
+ CapabilityFilter filter)
+ : url_(GetBaseURLAndQuery(url, nullptr)),
+ qualifier_(qualifier.empty() ? GetBaseURLAndQuery(url, nullptr).spec()
+ : qualifier),
+ filter_(CanonicalizeFilter(filter)) {}
-// explicit
-Identity::Identity(const GURL& in_url)
- : url(GetBaseURLAndQuery(in_url, nullptr)), qualifier(url.spec()) {}
+Identity::~Identity() {}
bool Identity::operator<(const Identity& other) const {
- if (url != other.url)
- return url < other.url;
- return qualifier < other.qualifier;
+ // We specifically don't include filter in the equivalence check because we
+ // don't quite know how this should work yet.
+ // TODO(beng): figure out how it should work.
+ if (url_ != other.url_)
+ return url_ < other.url_;
+ return qualifier_ < other.qualifier_;
}
} // namespace shell
« mojo/shell/identity.h ('K') | « mojo/shell/identity.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698